Skip to content

Commit 40232f4

Browse files
committed
ASM annotation visitor defensively accesses enum constants
Issue: SPR-15442 (cherry picked from commit 4838f06)
1 parent 80fa3ac commit 40232f4

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

spring-core/src/main/java/org/springframework/core/type/classreading/AbstractRecursiveAnnotationVisitor.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2016 the original author or authors.
2+
* Copyright 2002-2017 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -17,6 +17,7 @@
1717
package org.springframework.core.type.classreading;
1818

1919
import java.lang.reflect.Field;
20+
import java.security.AccessControlException;
2021

2122
import org.apache.commons.logging.Log;
2223
import org.apache.commons.logging.LogFactory;
@@ -80,14 +81,21 @@ protected Object getEnumValue(String asmTypeDescriptor, String attributeValue) {
8081
Class<?> enumType = this.classLoader.loadClass(Type.getType(asmTypeDescriptor).getClassName());
8182
Field enumConstant = ReflectionUtils.findField(enumType, attributeValue);
8283
if (enumConstant != null) {
84+
ReflectionUtils.makeAccessible(enumConstant);
8385
valueToUse = enumConstant.get(null);
8486
}
8587
}
8688
catch (ClassNotFoundException ex) {
8789
logger.debug("Failed to classload enum type while reading annotation metadata", ex);
8890
}
91+
catch (NoClassDefFoundError ex) {
92+
logger.debug("Failed to classload enum type while reading annotation metadata", ex);
93+
}
8994
catch (IllegalAccessException ex) {
90-
logger.warn("Could not access enum value while reading annotation metadata", ex);
95+
logger.debug("Could not access enum value while reading annotation metadata", ex);
96+
}
97+
catch (AccessControlException ex) {
98+
logger.debug("Could not access enum value while reading annotation metadata", ex);
9199
}
92100
return valueToUse;
93101
}

0 commit comments

Comments
 (0)