-
Bug
-
Resolution: Done
-
Major
-
None
-
java version "1.8.0"
Java(TM) SE Runtime Environment (build pxi3280sr1fp10-20150711_01(SR1 FP10))
IBM J9 VM (build 2.8, JRE 1.8.0 Linux x86-32 20150630_255633 (JIT enabled, AOT enabled)
J9VM - R28_jvm.28_20150630_1742_B255633
JIT - tr.r14.java_20150625_95081.01
GC - R28_jvm.28_20150630_1742_B255633
J9CL - 20150630_255633)
JCL - 20150711_01 based on Oracle jdk8u51-b15java version "1.8.0" Java(TM) SE Runtime Environment (build pxi3280sr1fp10-20150711_01(SR1 FP10)) IBM J9 VM (build 2.8, JRE 1.8.0 Linux x86-32 20150630_255633 (JIT enabled, AOT enabled) J9VM - R28_jvm.28_20150630_1742_B255633 JIT - tr.r14.java_20150625_95081.01 GC - R28_jvm.28_20150630_1742_B255633 J9CL - 20150630_255633) JCL - 20150711_01 based on Oracle jdk8u51-b15
-
Release Notes
-
-
-
-
-
-
-
Documented as Known Issue
This looks like a bug in IBM JDK. When introspecting a generic parameter of a method using getAnnotatedParameterTypes, IBM JDK returns an instance of sun.reflect.annotation.AnnotatedTypeFactory$AnnotatedTypeBaseImpl instead of the correct sun.reflect.annotation.AnnotatedTypeFactory$AnnotatedParameterizedTypeImpl
When introspecting generic fields or methods' return values this way, it works correctly!
The impact is that Hibernate Validator won't see nor be able to enforce constraints which are declared using type-use annotations on method parameters.
This also causes 8 failures in Hibernate Validator test suite when running with IBM JDK 8 - 4 in OptionalTypeAnnotationConstraintOnMethodTest and 4 in OptionalTypeAnnotationConstraintOnConstructorTest
Reproducer - simply compile this and run it using IBM JDK - it will fail with a ClassCastException, while it will finish successfully on other JDKs:
public class TypeUse_Parameter_Reproducer { public static void main(String[] args) throws NoSuchMethodException { final Method method = TypeUse_Parameter_Reproducer.class.getMethod("method", List.class); final AnnotatedType type = method.getAnnotatedParameterTypes()[0]; final AnnotatedParameterizedType annotatedParameterizedType = (AnnotatedParameterizedType)type; // booom! System.out .println(annotatedParameterizedType.getAnnotatedActualTypeArguments()[0].getAnnotations()[0]); // the expected output is: // @TypeUse_Parameter_Reproducer$TypeUseAnnotation(message=hi) } public void method(List<@TypeUseAnnotation(message = "hi") String> param) { } @Retention(RetentionPolicy.RUNTIME) @Target({ElementType.TYPE_USE}) public @interface TypeUseAnnotation { String message() default "blabla"; } }
Btw. To be able to run the Hibernate Validator test suite using IBM JDK, you also need to get rid of classes which depend on JavaFX and turn off the maven-enforcer-plugin using -Denforcer.skip=true..
- cloned from
-
HV-1024 Loading...