51 import java.util.Set; |
51 import java.util.Set; |
52 import java.util.Map; |
52 import java.util.Map; |
53 import java.util.HashMap; |
53 import java.util.HashMap; |
54 import java.util.Objects; |
54 import java.util.Objects; |
55 import sun.misc.Unsafe; |
55 import sun.misc.Unsafe; |
|
56 import sun.reflect.CallerSensitive; |
56 import sun.reflect.ConstantPool; |
57 import sun.reflect.ConstantPool; |
57 import sun.reflect.Reflection; |
58 import sun.reflect.Reflection; |
58 import sun.reflect.ReflectionFactory; |
59 import sun.reflect.ReflectionFactory; |
59 import sun.reflect.generics.factory.CoreReflectionFactory; |
60 import sun.reflect.generics.factory.CoreReflectionFactory; |
60 import sun.reflect.generics.factory.GenericsFactory; |
61 import sun.reflect.generics.factory.GenericsFactory; |
248 * @exception LinkageError if the linkage fails |
249 * @exception LinkageError if the linkage fails |
249 * @exception ExceptionInInitializerError if the initialization provoked |
250 * @exception ExceptionInInitializerError if the initialization provoked |
250 * by this method fails |
251 * by this method fails |
251 * @exception ClassNotFoundException if the class cannot be located |
252 * @exception ClassNotFoundException if the class cannot be located |
252 */ |
253 */ |
|
254 @CallerSensitive |
253 public static Class<?> forName(String className) |
255 public static Class<?> forName(String className) |
254 throws ClassNotFoundException { |
256 throws ClassNotFoundException { |
255 return forName0(className, true, ClassLoader.getCallerClassLoader()); |
257 return forName0(className, true, |
|
258 ClassLoader.getClassLoader(Reflection.getCallerClass())); |
256 } |
259 } |
257 |
260 |
258 |
261 |
259 /** |
262 /** |
260 * Returns the {@code Class} object associated with the class or |
263 * Returns the {@code Class} object associated with the class or |
315 * |
318 * |
316 * @see java.lang.Class#forName(String) |
319 * @see java.lang.Class#forName(String) |
317 * @see java.lang.ClassLoader |
320 * @see java.lang.ClassLoader |
318 * @since 1.2 |
321 * @since 1.2 |
319 */ |
322 */ |
|
323 @CallerSensitive |
320 public static Class<?> forName(String name, boolean initialize, |
324 public static Class<?> forName(String name, boolean initialize, |
321 ClassLoader loader) |
325 ClassLoader loader) |
322 throws ClassNotFoundException |
326 throws ClassNotFoundException |
323 { |
327 { |
324 if (sun.misc.VM.isSystemDomainLoader(loader)) { |
328 if (sun.misc.VM.isSystemDomainLoader(loader)) { |
325 SecurityManager sm = System.getSecurityManager(); |
329 SecurityManager sm = System.getSecurityManager(); |
326 if (sm != null) { |
330 if (sm != null) { |
327 ClassLoader ccl = ClassLoader.getCallerClassLoader(); |
331 ClassLoader ccl = ClassLoader.getClassLoader(Reflection.getCallerClass()); |
328 if (!sun.misc.VM.isSystemDomainLoader(ccl)) { |
332 if (!sun.misc.VM.isSystemDomainLoader(ccl)) { |
329 sm.checkPermission( |
333 sm.checkPermission( |
330 SecurityConstants.GET_CLASSLOADER_PERMISSION); |
334 SecurityConstants.GET_CLASSLOADER_PERMISSION); |
331 } |
335 } |
332 } |
336 } |
384 * of this class |
388 * of this class |
385 * |
389 * |
386 * </ul> |
390 * </ul> |
387 * |
391 * |
388 */ |
392 */ |
|
393 @CallerSensitive |
389 public T newInstance() |
394 public T newInstance() |
390 throws InstantiationException, IllegalAccessException |
395 throws InstantiationException, IllegalAccessException |
391 { |
396 { |
392 if (System.getSecurityManager() != null) { |
397 if (System.getSecurityManager() != null) { |
393 checkMemberAccess(Member.PUBLIC, ClassLoader.getCallerClassLoader(), false); |
398 checkMemberAccess(Member.PUBLIC, Reflection.getCallerClass(), false); |
394 } |
399 } |
395 return newInstance0(); |
400 |
396 } |
|
397 |
|
398 private T newInstance0() |
|
399 throws InstantiationException, IllegalAccessException |
|
400 { |
|
401 // NOTE: the following code may not be strictly correct under |
401 // NOTE: the following code may not be strictly correct under |
402 // the current Java memory model. |
402 // the current Java memory model. |
403 |
403 |
404 // Constructor lookup |
404 // Constructor lookup |
405 if (cachedConstructor == null) { |
405 if (cachedConstructor == null) { |
430 } |
430 } |
431 Constructor<T> tmpConstructor = cachedConstructor; |
431 Constructor<T> tmpConstructor = cachedConstructor; |
432 // Security check (same as in java.lang.reflect.Constructor) |
432 // Security check (same as in java.lang.reflect.Constructor) |
433 int modifiers = tmpConstructor.getModifiers(); |
433 int modifiers = tmpConstructor.getModifiers(); |
434 if (!Reflection.quickCheckMemberAccess(this, modifiers)) { |
434 if (!Reflection.quickCheckMemberAccess(this, modifiers)) { |
435 Class<?> caller = Reflection.getCallerClass(3); |
435 Class<?> caller = Reflection.getCallerClass(); |
436 if (newInstanceCallerCache != caller) { |
436 if (newInstanceCallerCache != caller) { |
437 Reflection.ensureMemberAccess(caller, this, null, modifiers); |
437 Reflection.ensureMemberAccess(caller, this, null, modifiers); |
438 newInstanceCallerCache = caller; |
438 newInstanceCallerCache = caller; |
439 } |
439 } |
440 } |
440 } |
672 * access to the class loader for the class. |
672 * access to the class loader for the class. |
673 * @see java.lang.ClassLoader |
673 * @see java.lang.ClassLoader |
674 * @see SecurityManager#checkPermission |
674 * @see SecurityManager#checkPermission |
675 * @see java.lang.RuntimePermission |
675 * @see java.lang.RuntimePermission |
676 */ |
676 */ |
|
677 @CallerSensitive |
677 public ClassLoader getClassLoader() { |
678 public ClassLoader getClassLoader() { |
678 ClassLoader cl = getClassLoader0(); |
679 ClassLoader cl = getClassLoader0(); |
679 if (cl == null) |
680 if (cl == null) |
680 return null; |
681 return null; |
681 SecurityManager sm = System.getSecurityManager(); |
682 SecurityManager sm = System.getSecurityManager(); |
682 if (sm != null) { |
683 if (sm != null) { |
683 ClassLoader ccl = ClassLoader.getCallerClassLoader(); |
684 ClassLoader.checkClassLoaderPermission(cl, Reflection.getCallerClass()); |
684 if (ClassLoader.needsClassLoaderPermissionCheck(ccl, cl)) { |
|
685 sm.checkPermission(SecurityConstants.GET_CLASSLOADER_PERMISSION); |
|
686 } |
|
687 } |
685 } |
688 return cl; |
686 return cl; |
689 } |
687 } |
690 |
688 |
691 // Package-private to allow ClassLoader access |
689 // Package-private to allow ClassLoader access |
1390 * |
1388 * |
1391 * </ul> |
1389 * </ul> |
1392 * |
1390 * |
1393 * @since JDK1.1 |
1391 * @since JDK1.1 |
1394 */ |
1392 */ |
|
1393 @CallerSensitive |
1395 public Class<?>[] getClasses() { |
1394 public Class<?>[] getClasses() { |
1396 // be very careful not to change the stack depth of this |
1395 checkMemberAccess(Member.PUBLIC, Reflection.getCallerClass(), false); |
1397 // checkMemberAccess call for security reasons |
|
1398 // see java.lang.SecurityManager.checkMemberAccess |
|
1399 checkMemberAccess(Member.PUBLIC, ClassLoader.getCallerClassLoader(), false); |
|
1400 |
1396 |
1401 // Privileged so this implementation can look at DECLARED classes, |
1397 // Privileged so this implementation can look at DECLARED classes, |
1402 // something the caller might not have privilege to do. The code here |
1398 // something the caller might not have privilege to do. The code here |
1403 // is allowed to look at DECLARED classes because (1) it does not hand |
1399 // is allowed to look at DECLARED classes because (1) it does not hand |
1404 // out anything other than public members and (2) public member access |
1400 // out anything other than public members and (2) public member access |
1465 * |
1461 * |
1466 * </ul> |
1462 * </ul> |
1467 * |
1463 * |
1468 * @since JDK1.1 |
1464 * @since JDK1.1 |
1469 */ |
1465 */ |
|
1466 @CallerSensitive |
1470 public Field[] getFields() throws SecurityException { |
1467 public Field[] getFields() throws SecurityException { |
1471 // be very careful not to change the stack depth of this |
1468 checkMemberAccess(Member.PUBLIC, Reflection.getCallerClass(), true); |
1472 // checkMemberAccess call for security reasons |
|
1473 // see java.lang.SecurityManager.checkMemberAccess |
|
1474 checkMemberAccess(Member.PUBLIC, ClassLoader.getCallerClassLoader(), true); |
|
1475 return copyFields(privateGetPublicFields(null)); |
1469 return copyFields(privateGetPublicFields(null)); |
1476 } |
1470 } |
1477 |
1471 |
1478 |
1472 |
1479 /** |
1473 /** |
1516 * |
1510 * |
1517 * </ul> |
1511 * </ul> |
1518 * |
1512 * |
1519 * @since JDK1.1 |
1513 * @since JDK1.1 |
1520 */ |
1514 */ |
|
1515 @CallerSensitive |
1521 public Method[] getMethods() throws SecurityException { |
1516 public Method[] getMethods() throws SecurityException { |
1522 // be very careful not to change the stack depth of this |
1517 checkMemberAccess(Member.PUBLIC, Reflection.getCallerClass(), true); |
1523 // checkMemberAccess call for security reasons |
|
1524 // see java.lang.SecurityManager.checkMemberAccess |
|
1525 checkMemberAccess(Member.PUBLIC, ClassLoader.getCallerClassLoader(), true); |
|
1526 return copyMethods(privateGetPublicMethods()); |
1518 return copyMethods(privateGetPublicMethods()); |
1527 } |
1519 } |
1528 |
1520 |
1529 |
1521 |
1530 /** |
1522 /** |
1565 * |
1557 * |
1566 * </ul> |
1558 * </ul> |
1567 * |
1559 * |
1568 * @since JDK1.1 |
1560 * @since JDK1.1 |
1569 */ |
1561 */ |
|
1562 @CallerSensitive |
1570 public Constructor<?>[] getConstructors() throws SecurityException { |
1563 public Constructor<?>[] getConstructors() throws SecurityException { |
1571 // be very careful not to change the stack depth of this |
1564 checkMemberAccess(Member.PUBLIC, Reflection.getCallerClass(), true); |
1572 // checkMemberAccess call for security reasons |
|
1573 // see java.lang.SecurityManager.checkMemberAccess |
|
1574 checkMemberAccess(Member.PUBLIC, ClassLoader.getCallerClassLoader(), true); |
|
1575 return copyConstructors(privateGetDeclaredConstructors(true)); |
1565 return copyConstructors(privateGetDeclaredConstructors(true)); |
1576 } |
1566 } |
1577 |
1567 |
1578 |
1568 |
1579 /** |
1569 /** |
1623 * |
1613 * |
1624 * </ul> |
1614 * </ul> |
1625 * |
1615 * |
1626 * @since JDK1.1 |
1616 * @since JDK1.1 |
1627 */ |
1617 */ |
|
1618 @CallerSensitive |
1628 public Field getField(String name) |
1619 public Field getField(String name) |
1629 throws NoSuchFieldException, SecurityException { |
1620 throws NoSuchFieldException, SecurityException { |
1630 // be very careful not to change the stack depth of this |
1621 checkMemberAccess(Member.PUBLIC, Reflection.getCallerClass(), true); |
1631 // checkMemberAccess call for security reasons |
|
1632 // see java.lang.SecurityManager.checkMemberAccess |
|
1633 checkMemberAccess(Member.PUBLIC, ClassLoader.getCallerClassLoader(), true); |
|
1634 Field field = getField0(name); |
1622 Field field = getField0(name); |
1635 if (field == null) { |
1623 if (field == null) { |
1636 throw new NoSuchFieldException(name); |
1624 throw new NoSuchFieldException(name); |
1637 } |
1625 } |
1638 return field; |
1626 return field; |
1708 * |
1696 * |
1709 * </ul> |
1697 * </ul> |
1710 * |
1698 * |
1711 * @since JDK1.1 |
1699 * @since JDK1.1 |
1712 */ |
1700 */ |
|
1701 @CallerSensitive |
1713 public Method getMethod(String name, Class<?>... parameterTypes) |
1702 public Method getMethod(String name, Class<?>... parameterTypes) |
1714 throws NoSuchMethodException, SecurityException { |
1703 throws NoSuchMethodException, SecurityException { |
1715 // be very careful not to change the stack depth of this |
1704 checkMemberAccess(Member.PUBLIC, Reflection.getCallerClass(), true); |
1716 // checkMemberAccess call for security reasons |
|
1717 // see java.lang.SecurityManager.checkMemberAccess |
|
1718 checkMemberAccess(Member.PUBLIC, ClassLoader.getCallerClassLoader(), true); |
|
1719 Method method = getMethod0(name, parameterTypes); |
1705 Method method = getMethod0(name, parameterTypes); |
1720 if (method == null) { |
1706 if (method == null) { |
1721 throw new NoSuchMethodException(getName() + "." + name + argumentTypesToString(parameterTypes)); |
1707 throw new NoSuchMethodException(getName() + "." + name + argumentTypesToString(parameterTypes)); |
1722 } |
1708 } |
1723 return method; |
1709 return method; |
1762 * |
1748 * |
1763 * </ul> |
1749 * </ul> |
1764 * |
1750 * |
1765 * @since JDK1.1 |
1751 * @since JDK1.1 |
1766 */ |
1752 */ |
|
1753 @CallerSensitive |
1767 public Constructor<T> getConstructor(Class<?>... parameterTypes) |
1754 public Constructor<T> getConstructor(Class<?>... parameterTypes) |
1768 throws NoSuchMethodException, SecurityException { |
1755 throws NoSuchMethodException, SecurityException { |
1769 // be very careful not to change the stack depth of this |
1756 checkMemberAccess(Member.PUBLIC, Reflection.getCallerClass(), true); |
1770 // checkMemberAccess call for security reasons |
|
1771 // see java.lang.SecurityManager.checkMemberAccess |
|
1772 checkMemberAccess(Member.PUBLIC, ClassLoader.getCallerClassLoader(), true); |
|
1773 return getConstructor0(parameterTypes, Member.PUBLIC); |
1757 return getConstructor0(parameterTypes, Member.PUBLIC); |
1774 } |
1758 } |
1775 |
1759 |
1776 |
1760 |
1777 /** |
1761 /** |
1805 * |
1789 * |
1806 * </ul> |
1790 * </ul> |
1807 * |
1791 * |
1808 * @since JDK1.1 |
1792 * @since JDK1.1 |
1809 */ |
1793 */ |
|
1794 @CallerSensitive |
1810 public Class<?>[] getDeclaredClasses() throws SecurityException { |
1795 public Class<?>[] getDeclaredClasses() throws SecurityException { |
1811 // be very careful not to change the stack depth of this |
1796 checkMemberAccess(Member.DECLARED, Reflection.getCallerClass(), false); |
1812 // checkMemberAccess call for security reasons |
|
1813 // see java.lang.SecurityManager.checkMemberAccess |
|
1814 checkMemberAccess(Member.DECLARED, ClassLoader.getCallerClassLoader(), false); |
|
1815 return getDeclaredClasses0(); |
1797 return getDeclaredClasses0(); |
1816 } |
1798 } |
1817 |
1799 |
1818 |
1800 |
1819 /** |
1801 /** |
1849 * |
1831 * |
1850 * </ul> |
1832 * </ul> |
1851 * |
1833 * |
1852 * @since JDK1.1 |
1834 * @since JDK1.1 |
1853 */ |
1835 */ |
|
1836 @CallerSensitive |
1854 public Field[] getDeclaredFields() throws SecurityException { |
1837 public Field[] getDeclaredFields() throws SecurityException { |
1855 // be very careful not to change the stack depth of this |
1838 checkMemberAccess(Member.DECLARED, Reflection.getCallerClass(), true); |
1856 // checkMemberAccess call for security reasons |
|
1857 // see java.lang.SecurityManager.checkMemberAccess |
|
1858 checkMemberAccess(Member.DECLARED, ClassLoader.getCallerClassLoader(), true); |
|
1859 return copyFields(privateGetDeclaredFields(false)); |
1839 return copyFields(privateGetDeclaredFields(false)); |
1860 } |
1840 } |
1861 |
1841 |
1862 |
1842 |
1863 /** |
1843 /** |
1897 * |
1877 * |
1898 * </ul> |
1878 * </ul> |
1899 * |
1879 * |
1900 * @since JDK1.1 |
1880 * @since JDK1.1 |
1901 */ |
1881 */ |
|
1882 @CallerSensitive |
1902 public Method[] getDeclaredMethods() throws SecurityException { |
1883 public Method[] getDeclaredMethods() throws SecurityException { |
1903 // be very careful not to change the stack depth of this |
1884 checkMemberAccess(Member.DECLARED, Reflection.getCallerClass(), true); |
1904 // checkMemberAccess call for security reasons |
|
1905 // see java.lang.SecurityManager.checkMemberAccess |
|
1906 checkMemberAccess(Member.DECLARED, ClassLoader.getCallerClassLoader(), true); |
|
1907 return copyMethods(privateGetDeclaredMethods(false)); |
1885 return copyMethods(privateGetDeclaredMethods(false)); |
1908 } |
1886 } |
1909 |
1887 |
1910 |
1888 |
1911 /** |
1889 /** |
1942 * |
1920 * |
1943 * </ul> |
1921 * </ul> |
1944 * |
1922 * |
1945 * @since JDK1.1 |
1923 * @since JDK1.1 |
1946 */ |
1924 */ |
|
1925 @CallerSensitive |
1947 public Constructor<?>[] getDeclaredConstructors() throws SecurityException { |
1926 public Constructor<?>[] getDeclaredConstructors() throws SecurityException { |
1948 // be very careful not to change the stack depth of this |
1927 checkMemberAccess(Member.DECLARED, Reflection.getCallerClass(), true); |
1949 // checkMemberAccess call for security reasons |
|
1950 // see java.lang.SecurityManager.checkMemberAccess |
|
1951 checkMemberAccess(Member.DECLARED, ClassLoader.getCallerClassLoader(), true); |
|
1952 return copyConstructors(privateGetDeclaredConstructors(false)); |
1928 return copyConstructors(privateGetDeclaredConstructors(false)); |
1953 } |
1929 } |
1954 |
1930 |
1955 |
1931 |
1956 /** |
1932 /** |
1985 * |
1961 * |
1986 * </ul> |
1962 * </ul> |
1987 * |
1963 * |
1988 * @since JDK1.1 |
1964 * @since JDK1.1 |
1989 */ |
1965 */ |
|
1966 @CallerSensitive |
1990 public Field getDeclaredField(String name) |
1967 public Field getDeclaredField(String name) |
1991 throws NoSuchFieldException, SecurityException { |
1968 throws NoSuchFieldException, SecurityException { |
1992 // be very careful not to change the stack depth of this |
1969 checkMemberAccess(Member.DECLARED, Reflection.getCallerClass(), true); |
1993 // checkMemberAccess call for security reasons |
|
1994 // see java.lang.SecurityManager.checkMemberAccess |
|
1995 checkMemberAccess(Member.DECLARED, ClassLoader.getCallerClassLoader(), true); |
|
1996 Field field = searchFields(privateGetDeclaredFields(false), name); |
1970 Field field = searchFields(privateGetDeclaredFields(false), name); |
1997 if (field == null) { |
1971 if (field == null) { |
1998 throw new NoSuchFieldException(name); |
1972 throw new NoSuchFieldException(name); |
1999 } |
1973 } |
2000 return field; |
1974 return field; |
2040 * |
2014 * |
2041 * </ul> |
2015 * </ul> |
2042 * |
2016 * |
2043 * @since JDK1.1 |
2017 * @since JDK1.1 |
2044 */ |
2018 */ |
|
2019 @CallerSensitive |
2045 public Method getDeclaredMethod(String name, Class<?>... parameterTypes) |
2020 public Method getDeclaredMethod(String name, Class<?>... parameterTypes) |
2046 throws NoSuchMethodException, SecurityException { |
2021 throws NoSuchMethodException, SecurityException { |
2047 // be very careful not to change the stack depth of this |
2022 checkMemberAccess(Member.DECLARED, Reflection.getCallerClass(), true); |
2048 // checkMemberAccess call for security reasons |
|
2049 // see java.lang.SecurityManager.checkMemberAccess |
|
2050 checkMemberAccess(Member.DECLARED, ClassLoader.getCallerClassLoader(), true); |
|
2051 Method method = searchMethods(privateGetDeclaredMethods(false), name, parameterTypes); |
2023 Method method = searchMethods(privateGetDeclaredMethods(false), name, parameterTypes); |
2052 if (method == null) { |
2024 if (method == null) { |
2053 throw new NoSuchMethodException(getName() + "." + name + argumentTypesToString(parameterTypes)); |
2025 throw new NoSuchMethodException(getName() + "." + name + argumentTypesToString(parameterTypes)); |
2054 } |
2026 } |
2055 return method; |
2027 return method; |
2090 * |
2062 * |
2091 * </ul> |
2063 * </ul> |
2092 * |
2064 * |
2093 * @since JDK1.1 |
2065 * @since JDK1.1 |
2094 */ |
2066 */ |
|
2067 @CallerSensitive |
2095 public Constructor<T> getDeclaredConstructor(Class<?>... parameterTypes) |
2068 public Constructor<T> getDeclaredConstructor(Class<?>... parameterTypes) |
2096 throws NoSuchMethodException, SecurityException { |
2069 throws NoSuchMethodException, SecurityException { |
2097 // be very careful not to change the stack depth of this |
2070 checkMemberAccess(Member.DECLARED, Reflection.getCallerClass(), true); |
2098 // checkMemberAccess call for security reasons |
|
2099 // see java.lang.SecurityManager.checkMemberAccess |
|
2100 checkMemberAccess(Member.DECLARED, ClassLoader.getCallerClassLoader(), true); |
|
2101 return getConstructor0(parameterTypes, Member.DECLARED); |
2071 return getConstructor0(parameterTypes, Member.DECLARED); |
2102 } |
2072 } |
2103 |
2073 |
2104 /** |
2074 /** |
2105 * Finds a resource with a given name. The rules for searching resources |
2075 * Finds a resource with a given name. The rules for searching resources |
2253 * Return the Virtual Machine's Class object for the named |
2223 * Return the Virtual Machine's Class object for the named |
2254 * primitive type. |
2224 * primitive type. |
2255 */ |
2225 */ |
2256 static native Class<?> getPrimitiveClass(String name); |
2226 static native Class<?> getPrimitiveClass(String name); |
2257 |
2227 |
|
2228 private static boolean isCheckMemberAccessOverridden(SecurityManager smgr) { |
|
2229 if (smgr.getClass() == SecurityManager.class) return false; |
|
2230 |
|
2231 Class<?>[] paramTypes = new Class<?>[] {Class.class, int.class}; |
|
2232 return smgr.getClass().getMethod0("checkMemberAccess", paramTypes). |
|
2233 getDeclaringClass() != SecurityManager.class; |
|
2234 } |
2258 |
2235 |
2259 /* |
2236 /* |
2260 * Check if client is allowed to access members. If access is denied, |
2237 * Check if client is allowed to access members. If access is denied, |
2261 * throw a SecurityException. |
2238 * throw a SecurityException. |
2262 * |
2239 * |
2263 * Be very careful not to change the stack depth of this checkMemberAccess |
|
2264 * call for security reasons. |
|
2265 * See java.lang.SecurityManager.checkMemberAccess. |
|
2266 * |
|
2267 * <p> Default policy: allow all clients access with normal Java access |
2240 * <p> Default policy: allow all clients access with normal Java access |
2268 * control. |
2241 * control. |
2269 */ |
2242 */ |
2270 private void checkMemberAccess(int which, ClassLoader ccl, boolean checkProxyInterfaces) { |
2243 private void checkMemberAccess(int which, Class<?> caller, boolean checkProxyInterfaces) { |
2271 SecurityManager s = System.getSecurityManager(); |
2244 final SecurityManager s = System.getSecurityManager(); |
2272 if (s != null) { |
2245 if (s != null) { |
2273 s.checkMemberAccess(this, which); |
2246 final ClassLoader ccl = ClassLoader.getClassLoader(caller); |
2274 ClassLoader cl = getClassLoader0(); |
2247 final ClassLoader cl = getClassLoader0(); |
|
2248 if (!isCheckMemberAccessOverridden(s)) { |
|
2249 // Inlined SecurityManager.checkMemberAccess |
|
2250 if (which != Member.PUBLIC) { |
|
2251 if (ccl != cl) { |
|
2252 s.checkPermission(SecurityConstants.CHECK_MEMBER_ACCESS_PERMISSION); |
|
2253 } |
|
2254 } |
|
2255 } else { |
|
2256 // Don't refactor; otherwise break the stack depth for |
|
2257 // checkMemberAccess of subclasses of SecurityManager as specified. |
|
2258 s.checkMemberAccess(this, which); |
|
2259 } |
|
2260 |
|
2261 |
2275 if (ReflectUtil.needsPackageAccessCheck(ccl, cl)) { |
2262 if (ReflectUtil.needsPackageAccessCheck(ccl, cl)) { |
2276 String name = this.getName(); |
2263 String name = this.getName(); |
2277 int i = name.lastIndexOf('.'); |
2264 int i = name.lastIndexOf('.'); |
2278 if (i != -1) { |
2265 if (i != -1) { |
2279 // skip the package access check on a proxy class in default proxy package |
2266 // skip the package access check on a proxy class in default proxy package |