Details
-
Bug
-
Resolution: Fixed
-
P4
-
8, 9
-
b17
-
generic
-
generic
Description
FULL PRODUCT VERSION :
java version "1.8.0_112"
Java(TM) SE Runtime Environment (build 1.8.0_112-b15)
Java HotSpot(TM) 64-Bit Server VM (build 25.112-b15, mixed mode)
java version "9-ea"
Java(TM) SE Runtime Environment (build 9-ea+144)
Java HotSpot(TM) 64-Bit Server VM (build 9-ea+144, mixed mode)
A DESCRIPTION OF THE PROBLEM :
I'm a developer of the JaCoCo code coverage library.
While preparing test cases for instrumentation of annotations, I encountered this issue and isolated a simple reproducer.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Compile and start the source code below.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
No exception
ACTUAL -
java.lang.annotation.AnnotationFormatError: Malformed method on an annotation type
at sun.reflect.annotation.AnnotationInvocationHandler.validateAnnotationMethods(AnnotationInvocationHandler.java:384)
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.reflect.Method;
class AnnotationBug {
@Retention(RetentionPolicy.RUNTIME)
@interface Annotation {
// provoke creation of method
Runnable r = () -> {};
}
@Annotation
public static void m1() {
}
@Annotation
public static void m2() {
}
@Annotation
public static void main(String[] args) throws Exception {
Annotation a1 = AnnotationBug.class.getMethod("m1").getAnnotation(Annotation.class);
Annotation a2 = AnnotationBug.class.getMethod("m2").getAnnotation(Annotation.class);
// provoke verification in AnnotationInvocationHandler
a1.equals(a2);
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Don't test wired corner cases ;-)
java version "1.8.0_112"
Java(TM) SE Runtime Environment (build 1.8.0_112-b15)
Java HotSpot(TM) 64-Bit Server VM (build 25.112-b15, mixed mode)
java version "9-ea"
Java(TM) SE Runtime Environment (build 9-ea+144)
Java HotSpot(TM) 64-Bit Server VM (build 9-ea+144, mixed mode)
A DESCRIPTION OF THE PROBLEM :
I'm a developer of the JaCoCo code coverage library.
While preparing test cases for instrumentation of annotations, I encountered this issue and isolated a simple reproducer.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Compile and start the source code below.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
No exception
ACTUAL -
java.lang.annotation.AnnotationFormatError: Malformed method on an annotation type
at sun.reflect.annotation.AnnotationInvocationHandler.validateAnnotationMethods(AnnotationInvocationHandler.java:384)
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.reflect.Method;
class AnnotationBug {
@Retention(RetentionPolicy.RUNTIME)
@interface Annotation {
// provoke creation of method
Runnable r = () -> {};
}
@Annotation
public static void m1() {
}
@Annotation
public static void m2() {
}
@Annotation
public static void main(String[] args) throws Exception {
Annotation a1 = AnnotationBug.class.getMethod("m1").getAnnotation(Annotation.class);
Annotation a2 = AnnotationBug.class.getMethod("m2").getAnnotation(Annotation.class);
// provoke verification in AnnotationInvocationHandler
a1.equals(a2);
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Don't test wired corner cases ;-)
Attachments
Issue Links
- relates to
-
JDK-8268788 Annotations with lambda expressions can still cause AnnotationFormatError
- Open