1061 // don't have generics information |
1061 // don't have generics information |
1062 for(int i = 0; i < parameterClasses.length; i++) |
1062 for(int i = 0; i < parameterClasses.length; i++) |
1063 parameterClasses[i] = toClass(parameterTypes[i]); |
1063 parameterClasses[i] = toClass(parameterTypes[i]); |
1064 |
1064 |
1065 // Perform access check |
1065 // Perform access check |
1066 Class<?> enclosingCandidate = enclosingInfo.getEnclosingClass(); |
1066 final Class<?> enclosingCandidate = enclosingInfo.getEnclosingClass(); |
1067 enclosingCandidate.checkMemberAccess(Member.DECLARED, |
1067 enclosingCandidate.checkMemberAccess(Member.DECLARED, |
1068 Reflection.getCallerClass(), true); |
1068 Reflection.getCallerClass(), true); |
|
1069 // Client is ok to access declared methods but j.l.Class might not be. |
|
1070 Method[] candidates = AccessController.doPrivileged( |
|
1071 new PrivilegedAction<Method[]>() { |
|
1072 @Override |
|
1073 public Method[] run() { |
|
1074 return enclosingCandidate.getDeclaredMethods(); |
|
1075 } |
|
1076 }); |
1069 /* |
1077 /* |
1070 * Loop over all declared methods; match method name, |
1078 * Loop over all declared methods; match method name, |
1071 * number of and type of parameters, *and* return |
1079 * number of and type of parameters, *and* return |
1072 * type. Matching return type is also necessary |
1080 * type. Matching return type is also necessary |
1073 * because of covariant returns, etc. |
1081 * because of covariant returns, etc. |
1074 */ |
1082 */ |
1075 for(Method m: enclosingCandidate.getDeclaredMethods()) { |
1083 for(Method m: candidates) { |
1076 if (m.getName().equals(enclosingInfo.getName()) ) { |
1084 if (m.getName().equals(enclosingInfo.getName()) ) { |
1077 Class<?>[] candidateParamClasses = m.getParameterTypes(); |
1085 Class<?>[] candidateParamClasses = m.getParameterTypes(); |
1078 if (candidateParamClasses.length == parameterClasses.length) { |
1086 if (candidateParamClasses.length == parameterClasses.length) { |
1079 boolean matches = true; |
1087 boolean matches = true; |
1080 for(int i = 0; i < candidateParamClasses.length; i++) { |
1088 for(int i = 0; i < candidateParamClasses.length; i++) { |
1213 // don't have generics information |
1221 // don't have generics information |
1214 for(int i = 0; i < parameterClasses.length; i++) |
1222 for(int i = 0; i < parameterClasses.length; i++) |
1215 parameterClasses[i] = toClass(parameterTypes[i]); |
1223 parameterClasses[i] = toClass(parameterTypes[i]); |
1216 |
1224 |
1217 // Perform access check |
1225 // Perform access check |
1218 Class<?> enclosingCandidate = enclosingInfo.getEnclosingClass(); |
1226 final Class<?> enclosingCandidate = enclosingInfo.getEnclosingClass(); |
1219 enclosingCandidate.checkMemberAccess(Member.DECLARED, |
1227 enclosingCandidate.checkMemberAccess(Member.DECLARED, |
1220 Reflection.getCallerClass(), true); |
1228 Reflection.getCallerClass(), true); |
|
1229 // Client is ok to access declared methods but j.l.Class might not be. |
|
1230 Constructor<?>[] candidates = AccessController.doPrivileged( |
|
1231 new PrivilegedAction<Constructor<?>[]>() { |
|
1232 @Override |
|
1233 public Constructor<?>[] run() { |
|
1234 return enclosingCandidate.getDeclaredConstructors(); |
|
1235 } |
|
1236 }); |
1221 /* |
1237 /* |
1222 * Loop over all declared constructors; match number |
1238 * Loop over all declared constructors; match number |
1223 * of and type of parameters. |
1239 * of and type of parameters. |
1224 */ |
1240 */ |
1225 for(Constructor<?> c: enclosingCandidate.getDeclaredConstructors()) { |
1241 for(Constructor<?> c: candidates) { |
1226 Class<?>[] candidateParamClasses = c.getParameterTypes(); |
1242 Class<?>[] candidateParamClasses = c.getParameterTypes(); |
1227 if (candidateParamClasses.length == parameterClasses.length) { |
1243 if (candidateParamClasses.length == parameterClasses.length) { |
1228 boolean matches = true; |
1244 boolean matches = true; |
1229 for(int i = 0; i < candidateParamClasses.length; i++) { |
1245 for(int i = 0; i < candidateParamClasses.length; i++) { |
1230 if (!candidateParamClasses[i].equals(parameterClasses[i])) { |
1246 if (!candidateParamClasses[i].equals(parameterClasses[i])) { |