Bug 24375 - Casting of primitive final fields to its own type causes VerifyError
Summary: Casting of primitive final fields to its own type causes VerifyError
Status: RESOLVED DUPLICATE of bug 22673
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 2.0.1   Edit
Hardware: PC Windows 2000
: P3 normal (vote)
Target Milestone: 2.1 M2   Edit
Assignee: Philipe Mulet CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2002-10-04 02:57 EDT by Csaba Horvath CLA
Modified: 2002-10-04 05:05 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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 ***