Bug 99428 - [1.5][compiler] enum classes created without final accessFlag
Summary: [1.5][compiler] enum classes created without final accessFlag
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.1   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.1 RC3   Edit
Assignee: Kent Johnson CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-06-10 14:24 EDT by Peter Shipton CLA
Modified: 2005-06-16 14:14 EDT (History)
1 user (show)

See Also:


Attachments
enum test case (5.29 KB, application/octet-stream)
2005-06-10 17:01 EDT, Peter Shipton CLA
no flags Details
Fix the final bit issue. (2.05 KB, patch)
2005-06-13 10:23 EDT, Olivier Thomann CLA
no flags Details | Diff
This is the right patch (3.03 KB, patch)
2005-06-13 14:19 EDT, Olivier Thomann CLA
no flags Details | Diff
Patch for the test094 (1.20 KB, patch)
2005-06-13 14:39 EDT, Olivier Thomann CLA
no flags Details | Diff
Simplified patch (2.90 KB, patch)
2005-06-13 14:39 EDT, Olivier Thomann CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Peter Shipton CLA 2005-06-10 14:24:16 EDT
This problem occurs in Eclipse 3.1RC1.

Compile the following enum using Eclipse 3.1RC1, and Enum1 has the
accessFlags: 0x4021

Compile the enum using JDK 1.5 javac, and Enum1 has the accessFlags: 0x4031

The difference is the FINAL access flag.


public enum Enum1 {

	ONE,
	TWO;

public static void main(String[] args) throws Exception  {
	System.out.println(Integer.toHexString(Enum1.class.getModifiers()));
}
}
Comment 1 Olivier Thomann CLA 2005-06-10 16:59:15 EDT
I get 0x4001 using RC1 or any version of javac 1.5.
Comment 2 Peter Shipton CLA 2005-06-10 17:01:29 EDT
Created attachment 22842 [details]
enum test case

This is the test case that found the problem. The test passes on JDK when its
been compiled with javac.
Comment 3 Peter Shipton CLA 2005-06-10 17:07:52 EDT
This is the javac I'm using:

javac 1.5.0_03-ea

java version "1.5.0_03-ea"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_03-ea-b04)
Java HotSpot(TM) Client VM (build 1.5.0_03-ea-b04, mixed mode)

Comment 4 Philipe Mulet CLA 2005-06-13 06:39:02 EDT
+1 for RC3

Dani - would you pls cast a vote on it ? Our compiler isn't producing valid
files without it.
Comment 5 Dani Megert CLA 2005-06-13 06:42:57 EDT
+1 for 3.1 RC3.
Comment 6 Olivier Thomann CLA 2005-06-13 09:22:36 EDT
Indeed an enum type is implicitely final if none of its constants has a body.

So the first example:

public enum X {
	ONE, TWO
}

leads to a final bit set in the classfile.

Whereas the classfile for 

public enum X {

	ONE() {
		public String toString() {
			return "1";
		}
	},
	TWO;
}

doesn't have the final bit set.
Comment 7 Olivier Thomann CLA 2005-06-13 10:23:17 EDT
Created attachment 22923 [details]
Fix the final bit issue.
Comment 8 Olivier Thomann CLA 2005-06-13 14:19:06 EDT
Created attachment 22952 [details]
This is the right patch
Comment 9 Olivier Thomann CLA 2005-06-13 14:39:04 EDT
Created attachment 22953 [details]
Patch for the test094
Comment 10 Olivier Thomann CLA 2005-06-13 14:39:48 EDT
Created attachment 22954 [details]
Simplified patch
Comment 11 Kent Johnson CLA 2005-06-15 10:16:12 EDT
Added EnumTest test114
Comment 12 Olivier Thomann CLA 2005-06-16 14:14:52 EDT
Output is now:
// Compiled from X.java (version 1.5 : 49.0, super bit)
// Signature: Ljava/lang/Enum<LX;>;
public final enum X extends java.lang.Enum {
...

Verified using N20050616-0010 + JDT/Core HEAD