Bug 141155

Summary: [1.5][compiler] Enum valueOf(String) method should not be final
Product: [Eclipse Project] JDT Reporter: Olivier Thomann <Olivier_Thomann>
Component: CoreAssignee: Philipe Mulet <philippe_mulet>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: daniel_megert, martinae
Version: 3.2   
Target Milestone: 3.2 RC4   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
Proposed fix
none
New patch
none
Updated regression tests none

Description Olivier Thomann CLA 2006-05-10 16:56:15 EDT
Compiling this code with Eclipse compiler:

public enum X {
	A, B, C;
}

produces a valueOf(String) method that is final.

javac doesn't set it as final.
Also the java.lang.Thread.State enum doesn't set its valueOf(String) method as final.
Comment 1 Olivier Thomann CLA 2006-05-10 17:02:27 EDT
Created attachment 41041 [details]
Proposed fix
Comment 2 Philipe Mulet CLA 2006-05-10 17:10:24 EDT
Ok for fixing SyntheticMethodBinding. According to JLS 8.9, both methods should be not final. Not only one, as Thread.State seems to expect.
Comment 3 Philipe Mulet CLA 2006-05-10 17:11:18 EDT
I'd be tempted to fix both cases (VALUES and VALUEOF). Not just one.
Now, I don't think this is critical for RC4.
Comment 4 Philipe Mulet CLA 2006-05-10 17:20:33 EDT
javac 1.6 b82 makes #values final still...
Comment 5 Olivier Thomann CLA 2006-05-10 17:29:29 EDT
Created attachment 41049 [details]
New patch

Remove final for both values() and valueOf(String) to match the JLS3
Comment 6 Olivier Thomann CLA 2006-05-10 17:32:11 EDT
Created attachment 41052 [details]
Updated regression tests
Comment 7 Philipe Mulet CLA 2006-05-11 03:19:26 EDT
Re: comment 4. This got confirmed as a bug in javac:
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6424358
Comment 8 Philipe Mulet CLA 2006-05-11 03:21:15 EDT
Given this is a trivial fix, and it may impact JCL team (since modifier is made visible in generated javadoc), I am proposing to fix this for RC4.


+1 for 3.2RC4

Dani/Martin: pls cast your vote
Comment 9 Philipe Mulet CLA 2006-05-11 03:21:37 EDT
Martin - pls vote
Comment 10 Philipe Mulet CLA 2006-05-11 03:25:50 EDT
Tuned EnumTest#test079,test094 to remove "final" expectations
Comment 11 Philipe Mulet CLA 2006-05-11 04:05:44 EDT
Added EnumTest#test129
Comment 12 Dani Megert CLA 2006-05-11 04:41:36 EDT
Patch is OK - approving for 3.2 RC4.
Comment 13 Martin Aeschlimann CLA 2006-05-11 05:25:42 EDT
+1 for 3.2RC4
Comment 14 Philipe Mulet CLA 2006-05-11 05:44:05 EDT
Fix released.
Comment 15 Olivier Thomann CLA 2006-05-11 22:23:19 EDT
Verified with I20060511-2000 for 3.2RC4