Community
Participate
Working Groups
Created attachment 106339 [details] Sample project Build ID: I20080617-2000 Steps To Reproduce: 1. Import attached sample project 2. Debug or Run the project through Eclipse, get VerifyError 3. Compile and run from command line, no error More information: Problem found when running on Mac OS X Leopard (10.5.4) Java version: Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_13-b05-237) Java HotSpot(TM) Client VM (build 1.5.0_13-119, mixed mode, sharing) The code compiles in Eclipse, but when run or debugged gives the error: Exception in thread "main" java.lang.VerifyError: (class: CastingVerifyError, method: castLongToInt signature: (J)I) Expecting to find long on stack When compiled with javac and run from command line, no error occurs The code also compiled and ran without errors in Eclipse 3.3
This works for me on XP and Mac OS 10.5.3 (using the same VM as shown below).
Decompiling the .class files (javap -private -c CastingVerifyError) gives the following: .class file created by Eclipse compiler (error case): Compiled from "CastingVerifyError.java" public class CastingVerifyError extends java.lang.Object{ public CastingVerifyError(); Code: 0: aload_0 1: invokespecial #8; //Method java/lang/Object."<init>":()V 4: return public static void main(java.lang.String[]); Code: 0: return private static int castLongToInt(long); Code: 0: lload_0 1: l2i 2: l2i 3: ireturn } .class file created by default javac command line (working case): Compiled from "CastingVerifyError.java" public class CastingVerifyError extends java.lang.Object{ public CastingVerifyError(); Code: 0: aload_0 1: invokespecial #1; //Method java/lang/Object."<init>":()V 4: return public static void main(java.lang.String[]); Code: 0: return private static int castLongToInt(long); Code: 0: lload_0 1: l2i 2: ireturn }
Moving to JCORE for comment.
Reproduced in latest.
Only occurs if enabling the diagnosis for unnecessary cast (-warn:+uselessTypeCheck)
Regression over 3.3.2, introduced during 3.4M7
Problem comes from a side-effect on implicitConversion performed by alternate cast check (as part of diagnosis for unused cast).
Workaround is to disable the optional warning for unnecessary cast.
Added CastTest#test045
Created attachment 106523 [details] Proposed patch
Created attachment 106564 [details] Better patch
Created attachment 106565 [details] Patch for 3.4.x
Released for 3.4.1
Released for 3.5M1. Fixed
*** Bug 239594 has been marked as a duplicate of this bug. ***
Re: comment 8. BTW a better workaround is simply to remove the unnecessary cast (to long in this case).
Verified for 3.5M1 using I20080805-1307
Verified for 3.4.1 using M20080827-2000