Bug 239594

Summary: "Double cast" in source code results in a java.lang.VerifyError
Product: [Eclipse Project] JDT Reporter: BoD <bod-keyword-eclipse.d2716d>
Component: CoreAssignee: JDT-Core-Inbox <jdt-core-inbox>
Status: VERIFIED DUPLICATE QA Contact:
Severity: major    
Priority: P3 CC: jerome_lanneluc, philippe_mulet
Version: 3.4   
Target Milestone: 3.4.1   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description BoD CLA 2008-07-04 06:52:19 EDT
Build ID: I20080617-2000

Steps To Reproduce:
Compile and run this simple class:

public class Test {
    static int problem(long x) {
        return (int) (long) x;
    }

    public static void main(String[] av) {
        System.out.println(Test.problem(42L));
    }
}

This results in 
java.lang.VerifyError: (class: Test, method: problem signature: (J)I) Expecting to find long on stack

More information:
I suspect the generated class is invalid.
Decompiling it with jad gives a double int cast.

The problem doesn't exist with eclipse 3.3.

The problem disappears when removing the unnecessary long cast.

Important note: I could not reproduce this on a coworker's PC with the same version of eclipse, the same OS (windows xp) and a very similar hardware.
I reproduce it on my machine 100% of the time.
Comment 1 Philipe Mulet CLA 2008-07-04 08:40:47 EDT
This is a dup of bug 239305. See workaround there.
Fix is available, and released for inclusion in 3.4.1 service release.
Check the eclipse download page for access to early 3.4.1 builds.

*** This bug has been marked as a duplicate of bug 239305 ***
Comment 2 Kent Johnson CLA 2008-08-06 15:04:50 EDT
Verified for 3.5M1 using I20080805-1307
Comment 3 Jerome Lanneluc CLA 2008-08-28 15:35:32 EDT
I cannot reproduce either using I20080617-2000. I tried with a 1.4.2 VM, a 1.5.0 VM and a 1.6 VM, but they were all able to run the compiled class without verify error. So I cannot verify the bug.
Comment 4 Jerome Lanneluc CLA 2008-08-28 16:00:53 EDT
Actually I was able to reproduce: you have to enable the "Unecessary cast or 'instanceof' expression" warning to see the verify error.

Verified for 3.4.1 using M20080827-2000