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

Bug 210427

Summary: [compiler] Missing syntax error on invalid annotation
Product: [Eclipse Project] JDT Reporter: Philipe Mulet <philippe_mulet>
Component: CoreAssignee: 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:
Description Flags
Possible Patch none

Description Philipe Mulet CLA 2007-11-20 13:05:28 EST
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();
}
Comment 1 Philipe Mulet CLA 2007-11-21 04:39:43 EST
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).
Comment 2 Philipe Mulet CLA 2007-11-21 04:40:32 EST
1.6 compliance exhibits the same behavior as 1.7.
Comment 3 Philipe Mulet CLA 2007-11-21 04:43:09 EST
Couldn't reproduce the problem in IDE. 
David: run Crap/Compile to reproduce
Comment 4 Philipe Mulet CLA 2007-11-21 04:47:49 EST
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
----------
Comment 5 Philipe Mulet CLA 2007-11-21 04:48:55 EST
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
----------
Comment 6 Philipe Mulet CLA 2007-11-21 05:29:00 EST
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.
Comment 7 Philipe Mulet CLA 2007-11-21 05:47:12 EST
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.

Comment 8 Philipe Mulet CLA 2007-11-21 05:47:57 EST
Created attachment 83417 [details]
Possible Patch
Comment 9 Philipe Mulet CLA 2007-11-21 06:14:27 EST
Released patch to HEAD. David pls take over.
Wondering if this shouldn't be backported to 3.3.2 ?
Comment 10 Aaron Digulla CLA 2012-10-16 06:16:29 EDT
Since patch has been released to HEAD: Can this bug be closed?
Comment 11 Eclipse Genie CLA 2020-03-01 17:43:58 EST
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.