-
Bug
-
Resolution: Unresolved
-
P4
-
8u20, 9
-
generic
-
generic
Executable.getParameters()[0].getAnnotaetdType() has no type annotations for an annotated receiver.
Minimized repro:
----- 8< ------
import java.lang.annotation.*;
import java.lang.reflect.*;
import java.util.Arrays;
public class IsRecvAParam {
@Target(ElementType.TYPE_USE)
@Retention(RetentionPolicy.RUNTIME)
@interface A {
}
class Foo {
Foo(@A IsRecvAParam IsRecvAParam.this) {
}
}
public static void main(String args[]) {
Constructor<?> cons = IsRecvAParam.Foo.class.getDeclaredConstructors()[0];
System.out.println("TypeAnnotations on:");
System.out.println("getAnnotatedParameterTypes()[0]: " + Arrays.asList(cons.getAnnotatedParameterTypes()[0].getAnnotations()) +
" //correct no type annotation here");
System.out.println("getAnnotatedReciver(): " + Arrays.asList(cons.getAnnotatedReceiverType().getAnnotations()) + " //correct");
System.out.println("getParameters()[0].getAnnotatedType(): " + Arrays.asList(cons.getParameters()[0].getAnnotatedType().getAnnotations()) +
" //error");
}
}
----- 8< ------
Minimized repro:
----- 8< ------
import java.lang.annotation.*;
import java.lang.reflect.*;
import java.util.Arrays;
public class IsRecvAParam {
@Target(ElementType.TYPE_USE)
@Retention(RetentionPolicy.RUNTIME)
@interface A {
}
class Foo {
Foo(@A IsRecvAParam IsRecvAParam.this) {
}
}
public static void main(String args[]) {
Constructor<?> cons = IsRecvAParam.Foo.class.getDeclaredConstructors()[0];
System.out.println("TypeAnnotations on:");
System.out.println("getAnnotatedParameterTypes()[0]: " + Arrays.asList(cons.getAnnotatedParameterTypes()[0].getAnnotations()) +
" //correct no type annotation here");
System.out.println("getAnnotatedReciver(): " + Arrays.asList(cons.getAnnotatedReceiverType().getAnnotations()) + " //correct");
System.out.println("getParameters()[0].getAnnotatedType(): " + Arrays.asList(cons.getParameters()[0].getAnnotatedType().getAnnotations()) +
" //error");
}
}
----- 8< ------
- clones
-
JDK-8057898 Annotations on receiver type's type arguments are lost
- Open
- is blocked by
-
JDK-8062582 Classfile format contains insufficent information for implementing parts of the reflection API
- Open
- relates to
-
JDK-8029012 parameter_index for type annotation not updated after outer.this added
- Closed
-
JDK-8039916 AnnotatedType.getType() of a Executable parameters may return wrong type
- Closed