Community
Participate
Working Groups
See the following program: public class MyClass { public static final boolean flag = true; public boolean getFlag() { if (this.flag) return true; else return false; } public static void main(String[] args) { System.out.println("It worked."); } } When we try to compile/execute it in Eclipse 3.2RC7 (JDK1.4.2) we get the following error: "java.lang.VerifyError: (class:pack/MyClass, method:getFlag signature: ()Z) Illegal target for jump or branch" It works with Eclipse 3.0.2
Reproduced
Problem comes from prefixing the static with a receiver. i.e. workaround is to remove unnecessary "this." qualification to "flag" field access in IF statement. public boolean getFlag() { if (flag) return true; else return false; } Note that a warning is emitted to signal that the static field should be accessed in a static way.
boolean code generation got reworked during 3.2 cycle to address other issues and make it more optimized. However, it was lacking optimization in this particular scenario, since the prefix of a static field access is optimized more aggressively nowadays. Fix released for 3.2.1 (TARGET_321) Fix released for 3.3M1 (HEAD) Added BooleanTest#test037
Created attachment 44913 [details] Proposed patch
Verified for 3.3 M1 using build I20060807-2000. Note that I could not reproduce using 3.2 build (M20060629-1905) but only with 3.2 RC7...
Verified for 3.2.1 using build M20060908-1655
*** Bug 159350 has been marked as a duplicate of this bug. ***