Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 420852

Summary: Enclosed elements are returned in alpha order, not in source code order
Product: [Eclipse Project] JDT Reporter: Stefan Ocke <stefan.ocke>
Component: APTAssignee: Generic inbox for the JDT-APT component <jdt-apt-inbox>
Status: CLOSED DUPLICATE QA Contact:
Severity: normal    
Priority: P3 CC: eclipse
Version: 4.3.1   
Target Milestone: ---   
Hardware: PC   
OS: Windows 7   
Whiteboard:

Description Stefan Ocke CLA 2013-11-01 05:34:11 EDT

    
Comment 1 Stefan Ocke CLA 2013-11-01 05:39:07 EDT
The javadoc of javax.lang.model.element.TypeElement.getEnclosedElements() says:

"Note that as a particular instance of the general accuracy requirements and the ordering behavior required of this interface, the list of enclosed elements will be returned in the natural order for the originating source of information about the type. For example, if the information about the type is originating from a source file, the elements will be returned in source code order. (However, in that case the the ordering of synthesized elements, such as a default constructor, is not specified.)"

I read this as "enclosed elements must be returned in source code order".

But Eclipse always returns the elements in alphabetical order, which is against the specification. (This is at least the case for fields. For methods, I have not yet tested.)
Comment 2 Walter Harley CLA 2013-11-01 12:44:34 EDT

*** This bug has been marked as a duplicate of bug 300408 ***