Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 394356 - [1.8][compiler] Type Annotations before package names should be rejected
Summary: [1.8][compiler] Type Annotations before package names should be rejected
Status: RESOLVED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 4.3   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: BETA J8   Edit
Assignee: Jay Arthanareeswaran CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 287648
  Show dependency tree
 
Reported: 2012-11-14 23:53 EST by Srikanth Sankaran CLA
Modified: 2013-04-02 12:40 EDT (History)
2 users (show)

See Also:


Attachments
Fix with updated tests (12.05 KB, patch)
2012-11-15 01:42 EST, Jay Arthanareeswaran CLA
no flags Details | Diff
Updated patch (14.73 KB, patch)
2012-11-28 05:02 EST, Jay Arthanareeswaran CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Srikanth Sankaran CLA 2012-11-14 23:53:19 EST
The latest spec for JSR308 requires annotations on qualified types
to be placed before the type name. i.e In a qualified type, the type annotations appear before the simple name, not before the package names. For example, a programmer writes package1.package2. @Annotation SimpleName rather than @Annotation package1.package2.SimpleName. 

We should reject misplaced annotations with a clear (if needed new)
message.
Comment 1 Jay Arthanareeswaran CLA 2012-11-15 01:42:20 EST
Created attachment 223585 [details]
Fix with updated tests

Patch alters some of the code released as part of fix to bug 390882. I treat this case same as the one where annotations are used on sub packages in a qualified type. I am doing this simply because the fix is simple. All Java 8 tests pass.

Let me know if you would prefer a specific error message, something like this:

"Annotations on a qualified type must be placed before the type name and not the package names."
Comment 2 Srikanth Sankaran CLA 2012-11-27 03:36:42 EST
The attached patch seems to reject java.lang.@Marker Integer ?
Please add a positive test for the new syntax (which could be
overall negative test due to some other error introduced.) Also
a test for acceptance of annotations at a nested type as well
as outer type would be good.
Comment 3 Srikanth Sankaran CLA 2012-11-27 03:39:29 EST
(In reply to comment #2)
> The attached patch seems to reject java.lang.@Marker Integer ?
> Please add a positive test for the new syntax (which could be
> overall negative test due to some other error introduced.) Also
> a test for acceptance of annotations at a nested type as well
> as outer type would be good.

Otherwise patch looks good.
Comment 4 Jay Arthanareeswaran CLA 2012-11-28 05:02:01 EST
Created attachment 224040 [details]
Updated patch

There was a silly error in the previous patch, which I have corrected in this.

Stephan, I had to make some adjustments to some tests in NullTypeAnnotationTest. In short, I am using the simple name for java.lang.Object and java.util.List instead of the fully qualified name. Are you fine with this? If so, I will release this patch.
Comment 5 Jay Arthanareeswaran CLA 2012-12-03 00:01:41 EST
Released the fix via commit:

http://git.eclipse.org/c/jdt/eclipse.jdt.core.git/commit/?h=BETA_JAVA8&id=a8944173670c6319cce2438add6b3e87f478a46c

Stephan, please let me know if you think about the test changes I mentioned in comment #4.
Comment 6 Jay Arthanareeswaran CLA 2012-12-07 00:28:52 EST
I have been asking Stephan for his comments without Copying him on this bug! :(
Comment 7 Stephan Herrmann CLA 2012-12-11 05:16:47 EST
(In reply to comment #6)
> I have been asking Stephan for his comments without Copying him on this bug!
> :(

The changes per se are good.
I'll re-introduce some syntactic variance via bug 396258.