Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 419331 - [1.8][compiler] Weird error on forward reference to type annotations from type parameter declarations
Summary: [1.8][compiler] Weird error on forward reference to type annotations from typ...
Status: RESOLVED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 4.4   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: BETA J8   Edit
Assignee: Srikanth Sankaran CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 419821 (view as bug list)
Depends on:
Blocks: 287648 427468
  Show dependency tree
 
Reported: 2013-10-13 22:06 EDT by Srikanth Sankaran CLA
Modified: 2014-05-20 09:26 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Srikanth Sankaran CLA 2013-10-13 22:06:41 EDT
BETA_JAVA8:

The following program fails to compile. We get:
Type mismatch: cannot convert from Class<TC> to Class<? extends Annotation>

// --
import java.lang.annotation.Annotation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Target;

@R(TC.class)
@Target(ElementType.TYPE_PARAMETER)
@interface T {
}

interface I<@T K> {
}

@Deprecated
@interface TC {

}

@Target(ElementType.ANNOTATION_TYPE)
@interface R {
    Class<? extends Annotation> value();
}

I have released a test TypeAnnotationTest.testForwardReference() encoding
the wrong behavior - The test needs to fixed along with the problem.
Comment 1 Srikanth Sankaran CLA 2013-10-14 09:16:37 EDT
This problem is not related to JEP120 per se, but I think we will
hit in that context as users try the feature. Jesper, thanks for
taking a look at this.
Comment 2 Manoj N Palat CLA 2013-10-18 05:49:57 EDT
*** Bug 419821 has been marked as a duplicate of this bug. ***
Comment 3 Srikanth Sankaran CLA 2013-10-18 07:34:07 EDT
Sorry for grabbing this one, As we are preparing for an early access release
early next week, I wanted to close out on a bunch of items. Thanks.

Fix and tests released here: http://git.eclipse.org/c/jdt/eclipse.jdt.core.git/commit/?h=BETA_JAVA8&id=2a851009aaa407c5e4c32cb132dfb84271f2e7fd
Comment 4 Alex Lara Garachana CLA 2014-05-20 09:26:58 EDT
This bug seems to be present at JDT 4.4 M7 compiling with JDK 1.7.55

--- The annotation: 
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
public @interface XmlReadTransformer {
	@SuppressWarnings("rawtypes")
	Class<? extends XmlReadCustomTransformer> using();
}
--- The interface
public static interface XmlWriteCustomTransformer {
    public String xmlFromBean(Object bean);
}
--- The implementation
public class MyTransformer
  implements XmlWriteCustomTransformer {
     public String xmlFromBean(Object bean) {
        ....
     }
}
--- The place where it does NOT compile:
@XmlReadTransformer(using=MyTransformer.class)  <<<<< COMPILE ERROR!!
public class MyTransformedType {
   ....
}