Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 391315 - [1.8][compiler] Compiler rejects annotations with valid target type
Summary: [1.8][compiler] Compiler rejects annotations with valid target type
Status: RESOLVED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.8   Edit
Hardware: All All
: P3 enhancement (vote)
Target Milestone: BETA J8   Edit
Assignee: Jay Arthanareeswaran CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 287648
  Show dependency tree
 
Reported: 2012-10-07 05:13 EDT by Srikanth Sankaran CLA
Modified: 2012-10-15 00:26 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Srikanth Sankaran CLA 2012-10-07 05:13:42 EDT
BETA_JAVA8:

The following program refuses to compile, while it should:

// ----
public class X<T> { 
	X<@Marker ?> l;
	class Y {
		void Y1(Y this) {
			
		}
	}
}

@java.lang.annotation.Target (java.lang.annotation.ElementType.TYPE_PARAMETER)
@interface Marker { 
}

Per EDR section 2.3:

"ElementType.TYPE PARAMETER stands for a type parameter — that is, 
the declaration of a type variable. Examples are in generic class 
declarations class MyClass<T> {...}, generic method declarations 
<T> foo(...) {...}, and wildcards List<?>, which declare an anonymous
type variable."
Comment 1 Jay Arthanareeswaran CLA 2012-10-09 10:45:10 EDT
Fixed along with the fix for bug 391201 via commit:

http://git.eclipse.org/c/jdt/eclipse.jdt.core.git/commit/?h=BETA_JAVA8&id=5aa22ef02c63418c06be6cd6a1ebf3ebbd649c6f
Comment 2 Srikanth Sankaran CLA 2012-10-13 15:45:18 EDT
Jay, could you add a test for the following case please ?

// ---
public class X<@Marker T> {
	@Marker T t;
	T t2 = (@Marker T) null;
}

class X2<@Marker2 T> {
	@Marker2 T t;
	T t2 = (@Marker2 T) null;
}

@java.lang.annotation.Target (java.lang.annotation.ElementType.TYPE_USE)
@interface Marker {
}

@java.lang.annotation.Target (java.lang.annotation.ElementType.TYPE_PARAMETER)
@interface Marker2 {
}
// ----

We report 2 errors, javac reports 3. I think our behavior is correct - do you
agree ?
Comment 3 Jay Arthanareeswaran CLA 2012-10-15 00:26:30 EDT
(In reply to comment #2)
> Jay, could you add a test for the following case please ?
> ...
> We report 2 errors, javac reports 3. I think our behavior is correct - do you
> agree ?

Yes, there should only be two errors. I have added new test to capture that.

Here's the commit: 
http://git.eclipse.org/c/jdt/eclipse.jdt.core.git/commit/?h=BETA_JAVA8&id=4a9e81e0cc6daa6012c6270605219e05cb35a33d