-
Bug
-
Resolution: Unresolved
-
P4
-
8, 9
-
generic
-
generic
These issues are found by using 9b60 JDK to run Java8ElementTests suite
of ECJ: The assignee of this task may want to split the tasks into unit level
tickets or in some cases close them as duplicates of existing defects.
(Type is a type annotation)
(1) Given the following snippet:
@Deprecated @Type("m") String foo() {
return null;
}
if method is the ExecutableElement for foo(), then
method.getReturnType().getAnnotation(Type.class) comes out as null.
(2) Given,
@Type("f") String _field = null;
if field is the VariableElement for _field
then
field.asType().getAnnotation(Type.class) comes out as null.
(3) Given:
public <@Type("mp1") T, @Type("mp2") U> void foo() {}
and typeParam is the TypeParameterElement for T then
typeParam.asType().getAnnotationMirrors() is 0, should be 1.
(4) Same problem as (3) for a generic class's type parameter.
(5) Given:
public static void main(String[] args) {}
if main is the ExecutableElement for main(), then
main.getReceiverType() should not be null, but is null.
I believe it should answer a type mirror which should return TypeKind.NONE for getKind().
Likewise these assertions should not fail, but they do.
ExecutableType type = (ExecutableType) main.asType();
typeMirror = type.getReceiverType();
assertNotNull("TypeMirror should not be null", typeMirror);
assertSame("Should be no type", TypeKind.NONE, typeMirror.getKind());
(6) Same problem as (5) for constructors seen with:
public class X {
public X(){}
}
Also these assertions should not fail, but they do:
(where constr is the ExecutableElement for the constructor)
type = (ExecutableType) constr.asType();
typeMirror = type.getReceiverType();
assertNotNull("TypeMirror should not be null", typeMirror);
assertSame("Should be no type", TypeKind.NONE, typeMirror.getKind());
(7) Problem seen with repeating annotations on type parameter:
Given:
@Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER }) @interface MarkerContainer {Marker[] value();}
@Repeatable(MarkerContainer .class)
@Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER }) @interface Marker {}
class Test {
<@Marker() @Marker() T> T foo() { return null; }
}
public class TypeParameterTest {
}
if tParam is the TypeParameterElement for foo()'s type variable T, then
tParam.getAnnotationMirrors() returns nothing, it should return
"@MarkerContainer(value=[@targets.model8.a.Marker, @targets.model8.a.Marker])"}
(8) I found it difficult to come up with a test that without borrowing significant chunks of code
from ECJ suites, so here is a description instead: If in round 0, a package-info.class gets
generated, then the subsequent round's roundEnv.getRootElements() should contain the
PackageElement, it does not seem to.
(9) Given:
package org.eclipse.jdt.compiler.apt.tests.annotations;
import java.lang.annotation.Repeatable;
@Repeatable(FooContainer.class)
public @interface Foo {
// ...
}
and
public @interface FooContainer {
Foo [] value();
}
some source being:
@Foo
public class JEP120_5 {
@TFoo @TFoo @Foo String field;
}
and field being the VariableElement that corresponds to field
then:
TypeMirror mirror = field.asType();
annot = mirror.getAnnotation(TFooContainer.class);
assertNotNull("Container missing", annot);
this assertion fails.
Also
mirror.getAnnotationsByType(TFooContainer.class); is empty.
Also
mirror.getAnnotationsByType(TFoo.class); should return 2, but does not
of ECJ: The assignee of this task may want to split the tasks into unit level
tickets or in some cases close them as duplicates of existing defects.
(Type is a type annotation)
(1) Given the following snippet:
@Deprecated @Type("m") String foo() {
return null;
}
if method is the ExecutableElement for foo(), then
method.getReturnType().getAnnotation(Type.class) comes out as null.
(2) Given,
@Type("f") String _field = null;
if field is the VariableElement for _field
then
field.asType().getAnnotation(Type.class) comes out as null.
(3) Given:
public <@Type("mp1") T, @Type("mp2") U> void foo() {}
and typeParam is the TypeParameterElement for T then
typeParam.asType().getAnnotationMirrors() is 0, should be 1.
(4) Same problem as (3) for a generic class's type parameter.
(5) Given:
public static void main(String[] args) {}
if main is the ExecutableElement for main(), then
main.getReceiverType() should not be null, but is null.
I believe it should answer a type mirror which should return TypeKind.NONE for getKind().
Likewise these assertions should not fail, but they do.
ExecutableType type = (ExecutableType) main.asType();
typeMirror = type.getReceiverType();
assertNotNull("TypeMirror should not be null", typeMirror);
assertSame("Should be no type", TypeKind.NONE, typeMirror.getKind());
(6) Same problem as (5) for constructors seen with:
public class X {
public X(){}
}
Also these assertions should not fail, but they do:
(where constr is the ExecutableElement for the constructor)
type = (ExecutableType) constr.asType();
typeMirror = type.getReceiverType();
assertNotNull("TypeMirror should not be null", typeMirror);
assertSame("Should be no type", TypeKind.NONE, typeMirror.getKind());
(7) Problem seen with repeating annotations on type parameter:
Given:
@Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER }) @interface MarkerContainer {Marker[] value();}
@Repeatable(MarkerContainer .class)
@Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER }) @interface Marker {}
class Test {
<@Marker() @Marker() T> T foo() { return null; }
}
public class TypeParameterTest {
}
if tParam is the TypeParameterElement for foo()'s type variable T, then
tParam.getAnnotationMirrors() returns nothing, it should return
"@MarkerContainer(value=[@targets.model8.a.Marker, @targets.model8.a.Marker])"}
(8) I found it difficult to come up with a test that without borrowing significant chunks of code
from ECJ suites, so here is a description instead: If in round 0, a package-info.class gets
generated, then the subsequent round's roundEnv.getRootElements() should contain the
PackageElement, it does not seem to.
(9) Given:
package org.eclipse.jdt.compiler.apt.tests.annotations;
import java.lang.annotation.Repeatable;
@Repeatable(FooContainer.class)
public @interface Foo {
// ...
}
and
public @interface FooContainer {
Foo [] value();
}
some source being:
@Foo
public class JEP120_5 {
@TFoo @TFoo @Foo String field;
}
and field being the VariableElement that corresponds to field
then:
TypeMirror mirror = field.asType();
annot = mirror.getAnnotation(TFooContainer.class);
assertNotNull("Container missing", annot);
this assertion fails.
Also
mirror.getAnnotationsByType(TFooContainer.class); is empty.
Also
mirror.getAnnotationsByType(TFoo.class); should return 2, but does not