-
Bug
-
Resolution: Unresolved
-
P4
-
8
From Joe Darcy:
In the course of working on 8035781: Improve equality for annotations, Alex suggested another scenario for the regression test: make sure a runtime error is thrown in an annotation type has a mismatch between the declared return type of a method and the default value stored for the method. A good news / bad news situation resulted.
The good new is the core reflection runtime already properly rejects such types by throwing an error. The bad news is that javac mis-generates the class file for a source files containing a annotation of such a corrupt type
I've attached the asm-generated class files which corresponds to the pseudo code
@Retention(RUNTIME)
public @interface BadAnnotationDefault {
int value();
String badValue() default -1; // Type mismatch of default
}
My test driver starts out like
@BadAnnotationSuperinterfaces(42)
@BadAnnotationSuper(42)
@BadAnnotationMethodMods(42)
@BadAnnotationParamCount(42)
@BadAnnotationThrows(42)
@BadAnnotationReturnType(42)
@BadAnnotationHashCode(42)
// @BadAnnotationDefault(42)
public class TestMalformedHandling {
// Make sure reading each of the annotations above throws an AnnotationFormatError...
}
and when @BadAnnotationDefault all eight of those annotations seem to be written out as @BadAnnotationDefault.
In the course of working on 8035781: Improve equality for annotations, Alex suggested another scenario for the regression test: make sure a runtime error is thrown in an annotation type has a mismatch between the declared return type of a method and the default value stored for the method. A good news / bad news situation resulted.
The good new is the core reflection runtime already properly rejects such types by throwing an error. The bad news is that javac mis-generates the class file for a source files containing a annotation of such a corrupt type
I've attached the asm-generated class files which corresponds to the pseudo code
@Retention(RUNTIME)
public @interface BadAnnotationDefault {
int value();
String badValue() default -1; // Type mismatch of default
}
My test driver starts out like
@BadAnnotationSuperinterfaces(42)
@BadAnnotationSuper(42)
@BadAnnotationMethodMods(42)
@BadAnnotationParamCount(42)
@BadAnnotationThrows(42)
@BadAnnotationReturnType(42)
@BadAnnotationHashCode(42)
// @BadAnnotationDefault(42)
public class TestMalformedHandling {
// Make sure reading each of the annotations above throws an AnnotationFormatError...
}
and when @BadAnnotationDefault all eight of those annotations seem to be written out as @BadAnnotationDefault.
- relates to
-
JDK-8041793 javap misses newline after printing AnnotationDefault
- Resolved