#1191 False positive (or misleading description) on inefficient access in nested inner class

3.0.0
closed-fixed
None
5
2014-06-20
2013-06-20
arrenlex
No

The following small test case triggers an IMA_INEFFICIENT_MEMBER_ACCESS warning:

public class Test {
  public void doSomething() {}

  public class TestInnerClass {
    public void doSomethingInnerClass() {
      new Runnable() {
        @Override
          public void run() {
            doSomething();
          }
        }.run();
    }
  }
}

Bug: Test$TestInnerClass$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)
Pattern: IMA_INEFFICIENT_MEMBER_ACCESS
Type: IMA, Category: PERFORMANCE (Performance)

The problem description doesn't seem to apply, as I don't have any member variables at all, and no private methods at all.

I use this pattern when I need to dispatch GUI calls (SwingUtilities.runLater(Runnable)) from inside a worker thread which is nested inside a GUI class.

FindBugs version: 2.0.2, eclipse plugin

JDK/JRE version: OpenJDK Runtime Environment (IcedTea6 1.12.5) (6b27-1.12.5-1ubuntu1), OpenJDK 64-Bit Server VM (build 20.0-b12, mixed mode)

Operating system: Ubuntu 13.04 64-bit

1 Attachments

Discussion

  • William Pugh

    William Pugh - 2013-10-16
    • status: open --> pending
    • assigned_to: William Pugh
     
  • William Pugh

    William Pugh - 2013-10-16

    I can't replicate this. I've tried both the head version and 2.0.2, both on the supplied classes and on newly written classes, using either the eclipse plugin or the command line tool.

    Can you export the xml from the analysis and attach it?

     
  • William Pugh

    William Pugh - 2013-10-16
    • status: pending --> pending-works-for-me
     
  • William Pugh

    William Pugh - 2013-10-21
    • status: pending-works-for-me --> closed-works-for-me
     
  • Andrey Loskutov

    Andrey Loskutov - 2014-06-20
    • status: closed-works-for-me --> closed-fixed
    • assigned_to: William Pugh --> Andrey Loskutov
    • Group: 2.0.3 --> 3.0.0
     

Log in to post a comment.

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

Sign up for the SourceForge newsletter:





No, thanks