Menu

#1307 False positive for UWF_UNWRITTEN_FIELD on Java 8 compiled code

3.0.1
closed-fixed
None
5
2015-03-08
2014-10-05
No
public final class Test {

  private static final String BUG = "bug";

  public static boolean bug(String s) {
    return "bug".equals(s.isEmpty() ? BUG : s);
  }

  private Test() {}
}
<plugin>
  <groupId>org.codehaus.mojo</groupId>
  <artifactId>findbugs-maven-plugin</artifactId>
  <version>3.0.0</version>
</plugin>
$ mvn -version
Apache Maven 3.2.3 (33f8c3e1027c3ddde99d3cdebad2656a31e8fdf4; 2014-08-11T22:58:10+02:00)
Maven home: /usr/local/opt/maven/libexec
Java version: 1.8.0_20, vendor: Oracle Corporation
Java home: /Library/Java/JavaVirtualMachines/jdk1.8.0_20.jdk/Contents/Home/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "mac os x", version: "10.9.5", arch: "x86_64", family: "mac"
$ java -version
java version "1.8.0_20"
Java(TM) SE Runtime Environment (build 1.8.0_20-b26)
Java HotSpot(TM) 64-Bit Server VM (build 25.20-b23, mixed mode)

Discussion

  • Andrey Loskutov

    Andrey Loskutov - 2014-11-09

    I can't reproduce. Can you check this with Eclipse or ant? I don't trust maven :-) You never know why it doesn't work if it doesn't work.

    Regards,
    Andrey

     
  • Andrey Loskutov

    Andrey Loskutov - 2014-11-09
    • status: open --> pending-works-for-me
    • assigned_to: Andrey Loskutov
     
  • Andrey Loskutov

    Andrey Loskutov - 2014-11-09

    Sorry,
    I've tried code compiled with Java 7 where we see no issues. Compiling code with Java 8 shows an issue!
    So this must be Java 8 specific bug.
    Regards,
    Andrey

     
  • Andrey Loskutov

    Andrey Loskutov - 2014-11-09
    • status: pending-works-for-me --> open-accepted
    • Group: 3.x --> 3.0.1
     
  • Andrey Loskutov

    Andrey Loskutov - 2014-11-09
    • summary: False positive for UWF_UNWRITTEN_FIELD --> False positive for UWF_UNWRITTEN_FIELD on Java 8 compiled code
     
  • Andrey Loskutov

    Andrey Loskutov - 2014-11-09

    The main difference is that javac with target 8 generates "getstatic" where target 7 "ldc" while accessing NOBUG constant. See attached javap outputs for two different targets produced with javac from JDK 8.

     
  • Andrey Loskutov

    Andrey Loskutov - 2014-11-09
    • status: open-accepted --> pending-fixed
    • assigned_to: Andrey Loskutov --> William Pugh
     
  • Andrey Loskutov

    Andrey Loskutov - 2015-03-08
    • status: pending-fixed --> closed-fixed
     

Log in to post a comment.

Auth0 Logo