| Summary: | [compiler] Missing syntax error on invalid annotation | ||||||
|---|---|---|---|---|---|---|---|
| Product: | [Eclipse Project] JDT | Reporter: | Philipe Mulet <philippe_mulet> | ||||
| Component: | Core | Assignee: | David Audel <david_audel> | ||||
| Status: | CLOSED WONTFIX | QA Contact: | |||||
| Severity: | normal | ||||||
| Priority: | P3 | CC: | digulla | ||||
| Version: | 3.4 | ||||||
| Target Milestone: | --- | ||||||
| Hardware: | PC | ||||||
| OS: | Windows XP | ||||||
| Whiteboard: | stalebug | ||||||
| Attachments: |
|
||||||
When running batch compiler in 1.5 mode, I see syntax errors. When running batch compiler in 1.7 mode, then no syntax error is surfaced (unless an extra '#' is appended at the end). 1.6 compliance exhibits the same behavior as 1.7. Couldn't reproduce the problem in IDE. David: run Crap/Compile to reproduce When running with 1.6/1.7 compliance, only get these problems:
----------
1. WARNING in d:\eclipse\workspaces\dev3.4\plugins\Crap\src\X.java (at line 3)
public final class X implements Serializable {
^
The serializable class X does not declare a static final serialVersionUID field of type long
----------
2. ERROR in d:\eclipse\workspaces\dev3.4\plugins\Crap\src\X.java (at line 5)
class SMember extends String {}
^^^^^^
The type SMember cannot subclass the final class String
----------
3. ERROR in d:\eclipse\workspaces\dev3.4\plugins\Crap\src\X.java (at line 7)
@Annot(value = new SMember())
^^^^^^^^^^^^^
Type mismatch: cannot convert from X.SMember to String
----------
In 1.6/1.7 mode, with extra '#' at the end of the code, I get:
----------
1. WARNING in d:\eclipse\workspaces\dev3.4\plugins\Crap\src\X.java (at line 3)
public final class X implements Serializable {
^
The serializable class X does not declare a static final serialVersionUID field of type long
----------
2. ERROR in d:\eclipse\workspaces\dev3.4\plugins\Crap\src\X.java (at line 5)
class SMember extends String {}
^^^^^^
The type SMember cannot subclass the final class String
----------
3. ERROR in d:\eclipse\workspaces\dev3.4\plugins\Crap\src\X.java (at line 7)
@Annot(value = new SMember())
^^^^^^^^^^^^^
Type mismatch: cannot convert from X.SMember to String
----------
4. ERROR in d:\eclipse\workspaces\dev3.4\plugins\Crap\src\X.java (at line 8)
void bar() {}
^
Syntax error on token "}", delete this token
----------
5. ERROR in d:\eclipse\workspaces\dev3.4\plugins\Crap\src\X.java (at line 17)
}
^
Syntax error, insert "}" to complete ClassBody
----------
6. ERROR in d:\eclipse\workspaces\dev3.4\plugins\Crap\src\X.java (at line 17)
}
^
Syntax error, insert ")" to complete Modifiers
----------
7. ERROR in d:\eclipse\workspaces\dev3.4\plugins\Crap\src\X.java (at line 17)
}
^
Syntax error, insert "enum Identifier" to complete EnumHeader
----------
8. ERROR in d:\eclipse\workspaces\dev3.4\plugins\Crap\src\X.java (at line 17)
}
^
Syntax error, insert "EnumBody" to complete BlockStatements
----------
9. ERROR in d:\eclipse\workspaces\dev3.4\plugins\Crap\src\X.java (at line 24)
#
^
Syntax error on token "Invalid Character", delete this token
----------
Seems that problem comes from MethodDeclaration#ignoreFurtherInvestigation being set to false when about to parse method body for #bar(). If clearing the test, then errors are reported correctly. 1.6/1.7 differences comes from APT enabling through batch compiler, which triggers some resolution before method bodies get parsed. This could in theory also occur with no APT, when a unit gets requested ahead, and queued (no method body), resolved in diet form to compile against it. Later on, when processed ignoreFurtherInvestigation would end up being set. Created attachment 83417 [details]
Possible Patch
Released patch to HEAD. David pls take over. Wondering if this shouldn't be backported to 3.3.2 ? Since patch has been released to HEAD: Can this bug be closed? This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. As such, we're closing this bug. If you have further information on the current state of the bug, please add it and reopen this bug. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant. -- The automated Eclipse Genie. |
Build 3.4M3 On following code, I'd expect a syntax error on #foo() annotation (missing closing parenthesis). import java.io.Serializable; public final class X implements Serializable { class SMember extends String {} @Annot(value = new SMember()) void bar() {} @Annot(value = new X(){ ZorkAnonymous1 z; void foo() { this.bar(); Zork2 z; } } void foo() {} } @interface Annot { String value(); }