Skip to content

Commit

Permalink
not fail on getDeclaredXXX when user has used a SecurityManager (orph…
Browse files Browse the repository at this point in the history
…an-oss#79)

not fail on getDeclaredXXX when user has used a SecurityManager

(cherry picked from commit 32d076d)
  • Loading branch information
yasserzamani committed Dec 16, 2019
1 parent 09db4f4 commit a973c19
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions src/main/java/ognl/OgnlRuntime.java
Original file line number Diff line number Diff line change
Expand Up @@ -2177,7 +2177,12 @@ public static Map getMethods(Class targetClass, boolean staticMethods)
}

private static void collectMethods(Class c, Map result, boolean staticMethods) {
final Method[] ma = c.getDeclaredMethods();
Method[] ma;
try {
ma = c.getDeclaredMethods();
} catch (SecurityException ignored) {
ma = c.getMethods();
}
for (int i = 0, icount = ma.length; i < icount; i++)
{
if (c.isInterface())
Expand Down Expand Up @@ -2307,7 +2312,11 @@ public static Map getFields(Class targetClass)
Field fa[];

result = new HashMap(23);
fa = targetClass.getDeclaredFields();
try {
fa = targetClass.getDeclaredFields();
} catch (SecurityException ignored) {
fa = targetClass.getFields();
}
for (int i = 0; i < fa.length; i++) {
result.put(fa[i].getName(), fa[i]);
}
Expand Down Expand Up @@ -2595,7 +2604,12 @@ public static List getDeclaredMethods(Class targetClass, String propertyName, bo

private static void collectAccessors(Class c, String baseName, List result, boolean findSets)
{
final Method[] methods = c.getDeclaredMethods();
Method[] methods;
try {
methods = c.getDeclaredMethods();
} catch (SecurityException ignored) {
methods = c.getMethods();
}
for (int i = 0; i < methods.length; i++) {
if (c.isInterface()) {
if (isDefaultMethod(methods[i]) || isNonDefaultPublicInterfaceMethod(methods[i])) {
Expand Down

0 comments on commit a973c19

Please sign in to comment.