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)
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
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
Test case: https://code.google.com/p/findbugs/source/detail?r=81d70ebd6b95e0387e3b7d3768d72fabe84c7f6c
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.
I've committed the possible fix but I'm wondering why the code works under Java 7 target.
Bill,
can you please check: https://code.google.com/p/findbugs/source/detail?r=23084f477a3611f70f2f0c32f7908b659edad9e6
Regards,
Andrey