-
Bug
-
Resolution: Fixed
-
P4
-
8u31
-
b124
-
x86
-
other
-
Verified
FULL PRODUCT VERSION :
java version "1.8.0_31"
Java(TM) SE Runtime Environment (build 1.8.0_31-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.31-b07, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
13.4.0 Darwin Kernel Version 13.4.0: Sun Aug 17 19:50:11 PDT 2014; root:xnu-2422.115.4~1/RELEASE_X86_64 x86_64
A DESCRIPTION OF THE PROBLEM :
Consider this simple test program:
import java.lang.annotation.*;
import java.lang.reflect.*;
public class AnnotationBug {
@Retention(RetentionPolicy.RUNTIME)
@interface MyAnnotation {
}
@MyAnnotation
public static void main(String[] args) throws Exception {
Method main = AnnotationBug.class.getMethod("main", String[].class);
MyAnnotation annotation = main.getAnnotation(MyAnnotation.class);
InvocationHandler handler = Proxy.getInvocationHandler(annotation);
assert handler.equals(annotation) == false: "1";
assert annotation.equals(handler) == false: "2";
}
}
This run with '-ea' option:
Exception in thread "main" java.lang.AssertionError: 2
at AnnotationBug.main(AnnotationBug.java:16)
vimshell: exit 1 "java -ea AnnotationBug"
The cause is the following code.
http://hg.openjdk.java.net/jdk8u/jdk8u/jdk/file/c46daef6edb5/src/share/classes/sun/reflect/annotation/AnnotationInvocationHandler.java#l191
The code in URL, == operator applied to 'this' instance, but it should apply to proxy that is argument in 'invoke' method.
REPRODUCIBILITY :
This bug can be reproduced always.
java version "1.8.0_31"
Java(TM) SE Runtime Environment (build 1.8.0_31-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.31-b07, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
13.4.0 Darwin Kernel Version 13.4.0: Sun Aug 17 19:50:11 PDT 2014; root:xnu-2422.115.4~1/RELEASE_X86_64 x86_64
A DESCRIPTION OF THE PROBLEM :
Consider this simple test program:
import java.lang.annotation.*;
import java.lang.reflect.*;
public class AnnotationBug {
@Retention(RetentionPolicy.RUNTIME)
@interface MyAnnotation {
}
@MyAnnotation
public static void main(String[] args) throws Exception {
Method main = AnnotationBug.class.getMethod("main", String[].class);
MyAnnotation annotation = main.getAnnotation(MyAnnotation.class);
InvocationHandler handler = Proxy.getInvocationHandler(annotation);
assert handler.equals(annotation) == false: "1";
assert annotation.equals(handler) == false: "2";
}
}
This run with '-ea' option:
Exception in thread "main" java.lang.AssertionError: 2
at AnnotationBug.main(AnnotationBug.java:16)
vimshell: exit 1 "java -ea AnnotationBug"
The cause is the following code.
http://hg.openjdk.java.net/jdk8u/jdk8u/jdk/file/c46daef6edb5/src/share/classes/sun/reflect/annotation/AnnotationInvocationHandler.java#l191
The code in URL, == operator applied to 'this' instance, but it should apply to proxy that is argument in 'invoke' method.
REPRODUCIBILITY :
This bug can be reproduced always.