Community
Participate
Working Groups
Exception: java.lang.VerifyError: (class: A, method: e signature: ()Ljava/lang/Object;) Wrong return type in function Testcase: public class A { Object e() { return "".compareTo("") > 0; } public static void main(String[] args) { System.out.println(new A().e()); } } Bytecode: java.lang.Object e(); Code: 0: ldc #17; //String 2: ldc #17; //String 4: invokevirtual #23; //Method java/lang/String.compareTo:(Ljava/lang/String;)I 7: ifle 12 10: iconst_1 11: ireturn 12: iconst_0 13: invokestatic #29; //Method java/lang/Boolean.valueOf:(Z)Ljava/lang/Boolean; 16: areturn The "ireturn" at position 11 is obviously wrong. A "goto 13" should be created (as javac does). A workaround is to help the compiler by using a redundant cast: return (Boolean) (... > 0);
The ireturn is fine as long as the implicit conversion is generated. Doing this, the ireturn would be replaced with: invokestatic #29; //Method java/lang/Boolean.valueOf:(Z)Ljava/lang/Boolean; areturn
Created attachment 17018 [details] Apply on HEAD Regression test in AutoBoxingTest.
The 'ireturn' bytecode is wrong; it should indeed to the boxing in this situation. Problem comes from the bytecode optimization for 'ReturnTypeIDMASK' which isn't properly handling boxing situations.
Offending bytecode optimization is actually: 'ValueForReturnMASK'.
Fixed in latest. Added regression tests: AutoboxingTest#test074-077
Verified in I20050214