Bug 141155 - [1.5][compiler] Enum valueOf(String) method should not be final
Summary: [1.5][compiler] Enum valueOf(String) method should not be final
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.2   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.2 RC4   Edit
Assignee: Philipe Mulet CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-05-10 16:56 EDT by Olivier Thomann CLA
Modified: 2006-05-11 22:23 EDT (History)
2 users (show)

See Also:


Attachments
Proposed fix (1.35 KB, patch)
2006-05-10 17:02 EDT, Olivier Thomann CLA
no flags Details | Diff
New patch (1.14 KB, patch)
2006-05-10 17:29 EDT, Olivier Thomann CLA
no flags Details | Diff
Updated regression tests (1.75 KB, patch)
2006-05-10 17:32 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 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