Community
Participate
Working Groups
Found on 3.1, still present in 3.2M3 (Nov 02). public class Foo { public static float f0; public static void main(String[] args) { long l11 = -26; System.out.println( (((l11 < f0++) || true) != ((true && true) && (!(false || true))))); } } java reports: java.lang.VerifyError: (class: Foo, method: main signature: ([Ljava/lang/String;)V) Expecting to find integer on stack At offset 22, there should be a PrintStream and an int (boolean) on the stack, but there is only a PrintStream: public static void main(java.lang.String[]); Code: 0: ldc2_w #15; //long -26l 3: lstore_1 4: getstatic #17; //Field java/lang/System.out:Ljava/io/PrintStream; 7: lload_1 8: l2f 9: getstatic #23; //Field f0:F 12: dup 13: fconst_1 14: fadd 15: putstatic #23; //Field f0:F 18: fcmpg 19: iflt 22 22: invokevirtual #25; //Method java/io/PrintStream.println:(Z)V 25: return
FWIW, Jikes elides the floating-point compare entirely since it has no bearing on the value of the expression, which is always true: 0: ldc2_w #11; //long -26l 3: lstore_1 4: getstatic #18; //Field java/lang/System.out:Ljava/io/PrintStream; 7: getstatic #20; //Field f0:F 10: fconst_1 11: fadd 12: putstatic #20; //Field f0:F 15: iconst_1 16: invokevirtual #26; //Method java/io/PrintStream.println:(Z)V 19: return Javac does this (correct, but amusing): ... 18: fcmpg 19: iflt 22 // if less, goto 22, else goto 22 anyway 22: iconst_1 // put 1 on the stack ... 23: ifeq 30 // ... and see if it's equal to zero 26: iconst_1 27: goto 31 30: iconst_0 // this is unreachable 31: invokevirtual #6; //Method java/io/PrintStream.println:(Z)V
Added BooleanTest#test018
Indeed, our boolean optimization failed in this case. Tuned implementation and now we produce same as jikes: public static void main(String[] args); 0 ldc2_w <Long -26> [18] 3 lstore_1 [l11] 4 getstatic System.out : PrintStream [20] 7 getstatic X.f0 : float [26] 10 fconst_1 11 fadd 12 putstatic X.f0 : float [26] 15 iconst_1 16 invokevirtual PrintStream.println(boolean) : void [28] 19 return
Created attachment 30549 [details] patch for HEAD
Added BooleanTest#test018-test030
Fixed both in HEAD and 3.1.2 stream. Rewrote boolean codegen to take out the flag OnlyValueRequiredMASK which was causing grief.
Verified for 3.2M4 in I20051212-2000
Verified for 3.1.2 in M20060109-0800.