equal
deleted
inserted
replaced
226 * method calls the security manager's {@code checkPermission} method |
226 * method calls the security manager's {@code checkPermission} method |
227 * with a {@code RuntimePermission("getClassLoader")} permission to |
227 * with a {@code RuntimePermission("getClassLoader")} permission to |
228 * ensure it's ok to access the bootstrap class loader. |
228 * ensure it's ok to access the bootstrap class loader. |
229 * |
229 * |
230 * @param name fully qualified name of the desired class |
230 * @param name fully qualified name of the desired class |
231 * @param initialize whether the class must be initialized |
231 * @param initialize if {@code true} the class will be initialized. |
|
232 * See Section 12.4 of <em>The Java Language Specification</em>. |
232 * @param loader class loader from which the class must be loaded |
233 * @param loader class loader from which the class must be loaded |
233 * @return class object representing the desired class |
234 * @return class object representing the desired class |
234 * |
235 * |
235 * @exception LinkageError if the linkage fails |
236 * @exception LinkageError if the linkage fails |
236 * @exception ExceptionInInitializerError if the initialization provoked |
237 * @exception ExceptionInInitializerError if the initialization provoked |
603 if (cl == null) |
604 if (cl == null) |
604 return null; |
605 return null; |
605 SecurityManager sm = System.getSecurityManager(); |
606 SecurityManager sm = System.getSecurityManager(); |
606 if (sm != null) { |
607 if (sm != null) { |
607 ClassLoader ccl = ClassLoader.getCallerClassLoader(); |
608 ClassLoader ccl = ClassLoader.getCallerClassLoader(); |
608 if (ccl != null && ccl != cl && !cl.isAncestor(ccl)) { |
609 if (ClassLoader.needsClassLoaderPermissionCheck(ccl, cl)) { |
609 sm.checkPermission(SecurityConstants.GET_CLASSLOADER_PERMISSION); |
610 sm.checkPermission(SecurityConstants.GET_CLASSLOADER_PERMISSION); |
610 } |
611 } |
611 } |
612 } |
612 return cl; |
613 return cl; |
613 } |
614 } |
2168 private void checkMemberAccess(int which, ClassLoader ccl) { |
2169 private void checkMemberAccess(int which, ClassLoader ccl) { |
2169 SecurityManager s = System.getSecurityManager(); |
2170 SecurityManager s = System.getSecurityManager(); |
2170 if (s != null) { |
2171 if (s != null) { |
2171 s.checkMemberAccess(this, which); |
2172 s.checkMemberAccess(this, which); |
2172 ClassLoader cl = getClassLoader0(); |
2173 ClassLoader cl = getClassLoader0(); |
2173 if ((ccl != null) && (ccl != cl) && |
2174 if (sun.reflect.misc.ReflectUtil.needsPackageAccessCheck(ccl, cl)) { |
2174 ((cl == null) || !cl.isAncestor(ccl))) { |
|
2175 String name = this.getName(); |
2175 String name = this.getName(); |
2176 int i = name.lastIndexOf('.'); |
2176 int i = name.lastIndexOf('.'); |
2177 if (i != -1) { |
2177 if (i != -1) { |
2178 s.checkPackageAccess(name.substring(0, i)); |
2178 s.checkPackageAccess(name.substring(0, i)); |
2179 } |
2179 } |