Summary: | [compiler] Self-assignment on declaration (_Can_ reference a field before it is defined) | ||
---|---|---|---|
Product: | [Eclipse Project] JDT | Reporter: | Mattias <hibernate> |
Component: | Core | Assignee: | Srikanth Sankaran <srikanth_sankaran> |
Status: | VERIFIED INVALID | QA Contact: | |
Severity: | minor | ||
Priority: | P3 | CC: | eclipse, Olivier_Thomann, satyam.kandula, stephan.herrmann |
Version: | 3.6 | ||
Target Milestone: | 3.6 RC4 | ||
Hardware: | PC | ||
OS: | Windows 7 | ||
Whiteboard: |
Description
Mattias
2010-05-20 09:14:05 EDT
This also compiles without error in javac. I suspect you've hit on a corner case in the Java Language Spec, but I'll leave it to the JDT Core folks to determine. Checking http://java.sun.com/docs/books/jls/third_edition/html/classes.html#8.3.2.3 it appears that qualified references are accepted. Only simple references are rejected. Srikanth, last word to you. (In reply to comment #2) > Checking > http://java.sun.com/docs/books/jls/third_edition/html/classes.html#8.3.2.3 it > appears that qualified references are accepted. > Only simple references are rejected. Isn't there a bug even in the JLS? The first sentence states that checking for this particular problem is only performed if all four requirements are met. Thus if any of the four requirements is not met we're good without checking textual order. The next sentence says: "A compile-time error occurs if any of the four requirements above are not met." which to me sounds like a contradiction. Should we silently ignore that sentence? (In reply to comment #2) > Checking > http://java.sun.com/docs/books/jls/third_edition/html/classes.html#8.3.2.3 it > appears that qualified references are accepted. > Only simple references are rejected. Indeed, there is even an example that explicitly legitimizes the qualified name usage: int z = UseBeforeDeclaration.x * 2; // ok - not accessed via simple name (In reply to comment #3) > (In reply to comment #2) > > Checking > > http://java.sun.com/docs/books/jls/third_edition/html/classes.html#8.3.2.3 it > > appears that qualified references are accepted. > > Only simple references are rejected. > > Isn't there a bug even in the JLS? > The first sentence states that checking for this particular problem is > only performed if all four requirements are met. Thus if any of the four > requirements is not met we're good without checking textual order. > > The next sentence says: > "A compile-time error occurs if any of the four requirements above are not > met." > which to me sounds like a contradiction. > > Should we silently ignore that sentence? I agree that the last sentence does sound contradictory and yes IMO it is completely superfluous and should be ignored. The right interpretation is clear from examples and such. Verified for 3.6RC4 |