Bug 25800 - Class file editor uses non-standard modifier order
Summary: Class file editor uses non-standard modifier order
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 2.1   Edit
Hardware: All All
: P3 minor (vote)
Target Milestone: 3.1 M5   Edit
Assignee: Olivier Thomann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2002-11-06 15:46 EST by Jim des Rivieres CLA
Modified: 2005-02-16 12:22 EST (History)
0 users

See Also:


Attachments
Reorder the modifiers and a bit of clean-up (12.52 KB, patch)
2005-01-20 10:46 EST, Michael Fraenkel CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jim des Rivieres CLA 2002-11-06 15:46:26 EST
The class file editor uses a non-standard modifier order.  For instance,
    final public class java.lang.System extends java.lang.Object {
        final public static java.io.InputStream in;
        native private static void registerNatives();
        ...
It should instead read:
    public final class java.lang.System extends java.lang.Object {
        public static final java.io.InputStream in;
        private static native void registerNatives();
        ...

So says the Java Language Spec:
Section 8.1.1
http://java.sun.com/docs/books/jls/second_edition/html/classes.doc.html#21613

"ClassModifier: one of
	public protected private
	abstract static final strictfp

[...] If two or more class modifiers appear in a class declaration, then it is 
customary, though not required, that they appear in the order consistent with 
that shown above in the production for ClassModifier."

Section 8.3.1
http://java.sun.com/docs/books/jls/second_edition/html/classes.doc.html#78091

"FieldModifier: one of
	public protected private
	static final transient volatile

[...] If two or more (distinct) field modifiers appear in a field declaration, 
it is customary, though not required, that they appear in the order consistent 
with that shown above in the production for FieldModifier."

Section 8.4.3
http://java.sun.com/docs/books/jls/second_edition/html/classes.doc.html#78188

"MethodModifier: one of
	public protected private abstract static
	final synchronized native strictfp

[...] If two or more method modifiers appear in a method declaration, it is 
customary, though not required, that they appear in the order consistent with 
that shown above in the production for MethodModifier."
Comment 1 Dani Megert CLA 2002-11-07 04:13:55 EST
It's the editor which shows up when no source is attached.
Decreasing severity to 'minor'.
Comment 2 Dani Megert CLA 2005-01-20 05:12:46 EST
This is provided by the Disassembler:

String content= null;
int flags= IClassFileReader.FIELD_INFOS | IClassFileReader.METHOD_INFOS |
IClassFileReader.SUPER_INTERFACES | IClassFileReader.METHOD_BODIES;

IClassFileReader classFileReader= 
                   ToolFactory.createDefaultClassFileReader(classFile, flags);
if (classFileReader != null) {
  IClassFileDisassembler disassembler= 
                             ToolFactory.createDefaultClassFileDisassembler();
  content= disassembler.disassemble(classFileReader, "\n"); //$NON-NLS-1$
}
Comment 3 Michael Fraenkel CLA 2005-01-20 10:46:05 EST
Created attachment 17335 [details]
Reorder the modifiers and a bit of clean-up

Reordered the modifiers according to JLS.
Cleaned the code a bit by extracting a common routine.
Comment 4 Olivier Thomann CLA 2005-01-20 10:54:43 EST
I will review it. Thanks for the patch.
Comment 5 Olivier Thomann CLA 2005-01-20 15:00:58 EST
Fixed and released in HEAD.
Updated existing regression tests.
Comment 6 David Audel CLA 2005-02-16 12:22:28 EST
Verified in I20050215-2300