Duplicate :
|
FULL PRODUCT VERSION : java version "1.7.0_04" Java(TM) SE Runtime Environment (build 1.7.0_04-b20) Java HotSpot(TM) 64-Bit Server VM (build 23.0-b21, mixed mode) ADDITIONAL OS VERSION INFORMATION : Microsoft Windows [Version 6.1.7601] A DESCRIPTION OF THE PROBLEM : parseEnumArray will throw a ArrayStoreException if the parseEnumValue method returns anything but the enum. This renders the message provided by parseEnumValue useless as you do not get the internal exception but rather the ArrayStore. This ultimately is caused by enum classes that have had their values method renamed/removed. STEPS TO FOLLOW TO REPRODUCE THE PROBLEM : Create 3 classes. 1) enum class containing some amount of values. 2) Runtime annotation that has an array of the enum. 3) A class that is annotated with the runtime annotation that inside of it psmv attempts to use reflection to get the runtime annotation and prints its enum value. After compile modify the bytecode (most likely obfuscation) and strip away/rename the "values" method of the enum. This will result in the underlying class system to be unable to retrevie the enum constants, which in turn results in Enum.value throwing an exception, and thus causing parseEnumValue to throw an exception which is then inappropriately handled inside parseEnumArray. EXPECTED VERSUS ACTUAL BEHAVIOR : EXPECTED - parseEnumArray to return the exception of parseEnumValue instead of attempting to store it in the array. ACTUAL - java.lang.ArrayStoreException: sun.reflect.annotation.EnumConstantNotPresentEx ptionProxy at sun.reflect.annotation.AnnotationParser.parseEnumArray(Unknown Sour ) at sun.reflect.annotation.AnnotationParser.parseArray(Unknown Source) at sun.reflect.annotation.AnnotationParser.parseMemberValue(Unknown So ce) at sun.reflect.annotation.AnnotationParser.parseAnnotation(Unknown Sou e) at sun.reflect.annotation.AnnotationParser.parseAnnotations2(Unknown S rce) at sun.reflect.annotation.AnnotationParser.parseAnnotations(Unknown So ce) at java.lang.Class.initAnnotationsIfNecessary(Unknown Source) at java.lang.Class.getAnnotation(Unknown Source) REPRODUCIBILITY : This bug can be reproduced always.