#1226 [patch] IMA_INEFFICIENT_MEMBER_ACCESS: Misleading message

patch (11)

Consider the following code:

// a/Super.java
package a;
public class Super {
protected String field = "test";

// b/Child.java
package b;
import a.Super;

public class Child extends Super {
public String run() {
new Runnable()
public void run()
field = field.substring(1);
return field;

Bug report (FB 2.0.2) in Eclipse says:

Bug: b.Child$1.run() accesses to a private member variable of owning class

This method of an inner class reads from or writes to a private member
variable of the owning class, or calls a private method of the owning
class. The compiler must generate a special method to access this private
member, causing this to be less efficient. Relaxing the protection of the
member variable or method will allow the compiler to treat this as a
normal access.

Confidence: Low, Rank: Of Concern (20)
Type: IMA, Category: PERFORMANCE (Performance)

However "field" is not a private, but protected and provided advice also helps little: I should make this field public to make it working. To solve this problem I can create protected methods in Child which will get/set the field, but this is exactly the same that autogenerated accessor methods do, thus it will not improve the performance. I think that either there should be separate pattern for this case or such bug report should be removed at all.

1 Attachments


  • Tagir Valeev

    Tagir Valeev - 2013-11-24

    I examined the code of this detector. It's probably not very easy to fix this for method access, because InnerClassAccess doesn't contain references to method accessors. However it's rather easy to support fields: we just have to compare the class name of accessor method and the class name of the field it accesses. If it accesses the field from the different class, then it's the case I've described above. Please check my patch. As a free bonus field name is displayed when the bug is reported. It's convenient as source line may refer to several fields.

    Last edit: Tagir Valeev 2013-11-24
  • Andrey Loskutov

    Andrey Loskutov - 2014-06-19
    • labels: --> patch
    • summary: IMA_INEFFICIENT_MEMBER_ACCESS: Misleading message --> [patch] IMA_INEFFICIENT_MEMBER_ACCESS: Misleading message
    • assigned_to: Andrey Loskutov
    • Group: 2.0.3 --> 3.x
  • Andrey Loskutov

    Andrey Loskutov - 2014-06-20
    • status: open --> closed-fixed
    • Group: 3.x --> 3.0.0

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks