Bug 24375

Summary: Casting of primitive final fields to its own type causes VerifyError
Product: [Eclipse Project] JDT Reporter: Csaba Horvath <hcs333>
Component: CoreAssignee: Philipe Mulet <philippe_mulet>
Status: RESOLVED DUPLICATE QA Contact:
Severity: normal    
Priority: P3 CC: max
Version: 2.0.1   
Target Milestone: 2.1 M2   
Hardware: PC   
OS: Windows 2000   
Whiteboard:

Description Csaba Horvath CLA 2002-10-04 02:57:18 EDT
The following code throws a VerifyError when compiling in Eclipse 2.0.1 (JDK 
1.3.1_04, Windows 2000):

class Recipient
{
    private short statusCode = 0;

    public void setStatusCode(short statusCode)
    {
       this.statusCode = statusCode;
    }
}

public class JavaBug
{
    public final short RECIPIENT_ACTIVE = 1;

    public void reactivateAccount()
    {
        Recipient r = new Recipient();
        r.setStatusCode((short) this.RECIPIENT_ACTIVE);
    }

    public static void main(String[] args)
    {
       JavaBug jb = new JavaBug();
       jb.reactivateAccount();
    }
}

It seems that casting primitive final fields to its own type causes this error. 
If you remove final before RECIPIENT_ACTIVE or change the cast line to
        r.setStatusCode((short) ((int) this.RECIPIENT_ACTIVE));
The error is not occured.
Comment 1 Philipe Mulet CLA 2002-10-04 05:05:03 EDT
Szia Csaba,

We fixed this defect which was affecting all identical cast applied to base 
type constants (see bug 22673).

This issue is resolved in 2.1 integration builds. You may alternatively want to 
download our 2.0.2 patch preview which contains the fix (see 
http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout%7E/jdt-core-
home/r2.0/main.html#updates). Now after having installed the patch, you will 
need to edit the org.eclipse.jdt.core/plugin.xml to change its version ID 
from "2.0.2" down to "2.0.1" in order for it to work properly with a 2.0.1 
build.
Comment 2 Philipe Mulet CLA 2002-10-04 05:05:24 EDT

*** This bug has been marked as a duplicate of 22673 ***