src/share/classes/java/lang/Class.java

Print this page

        

*** 287,324 **** * any exception thrown by the constructor in a (checked) {@link * java.lang.reflect.InvocationTargetException}. * * @return a newly allocated instance of the class represented by this * object. ! * @exception IllegalAccessException if the class or its nullary * constructor is not accessible. ! * @exception InstantiationException * if this {@code Class} represents an abstract class, * an interface, an array class, a primitive type, or void; * or if the class has no nullary constructor; * or if the instantiation fails for some other reason. ! * @exception ExceptionInInitializerError if the initialization * provoked by this method fails. ! * @exception SecurityException ! * If a security manager, <i>s</i>, is present and any of the ! * following conditions is met: ! * ! * <ul> ! * ! * <li> invocation of ! * {@link SecurityManager#checkMemberAccess ! * s.checkMemberAccess(this, Member.PUBLIC)} denies ! * creation of new instances of this class ! * ! * <li> the caller's class loader is not the same as or an * ancestor of the class loader for the current class and * invocation of {@link SecurityManager#checkPackageAccess * s.checkPackageAccess()} denies access to the package ! * of this class ! * ! * </ul> ! * */ public T newInstance() throws InstantiationException, IllegalAccessException { if (System.getSecurityManager() != null) { --- 287,312 ---- * any exception thrown by the constructor in a (checked) {@link * java.lang.reflect.InvocationTargetException}. * * @return a newly allocated instance of the class represented by this * object. ! * @throws IllegalAccessException if the class or its nullary * constructor is not accessible. ! * @throws InstantiationException * if this {@code Class} represents an abstract class, * an interface, an array class, a primitive type, or void; * or if the class has no nullary constructor; * or if the instantiation fails for some other reason. ! * @throws ExceptionInInitializerError if the initialization * provoked by this method fails. ! * @throws SecurityException ! * If a security manager, <i>s</i>, is present and ! * the caller's class loader is not the same as or an * ancestor of the class loader for the current class and * invocation of {@link SecurityManager#checkPackageAccess * s.checkPackageAccess()} denies access to the package ! * of this class. */ public T newInstance() throws InstantiationException, IllegalAccessException { if (System.getSecurityManager() != null) {
*** 1275,1309 **** * this {@code Class} object represents a primitive type, an array * class, or void. * * @return the array of {@code Class} objects representing the public * members of this class ! * @exception SecurityException ! * If a security manager, <i>s</i>, is present and any of the ! * following conditions is met: ! * ! * <ul> ! * ! * <li> invocation of ! * {@link SecurityManager#checkMemberAccess ! * s.checkMemberAccess(this, Member.PUBLIC)} method ! * denies access to the classes within this class ! * ! * <li> the caller's class loader is not the same as or an * ancestor of the class loader for the current class and * invocation of {@link SecurityManager#checkPackageAccess * s.checkPackageAccess()} denies access to the package ! * of this class ! * ! * </ul> * * @since JDK1.1 */ public Class<?>[] getClasses() { - // be very careful not to change the stack depth of this - // checkMemberAccess call for security reasons - // see java.lang.SecurityManager.checkMemberAccess checkMemberAccess(Member.PUBLIC, ClassLoader.getCallerClassLoader(), false); // Privileged so this implementation can look at DECLARED classes, // something the caller might not have privilege to do. The code here // is allowed to look at DECLARED classes because (1) it does not hand --- 1263,1283 ---- * this {@code Class} object represents a primitive type, an array * class, or void. * * @return the array of {@code Class} objects representing the public * members of this class ! * @throws SecurityException ! * If a security manager, <i>s</i>, is present and ! * the caller's class loader is not the same as or an * ancestor of the class loader for the current class and * invocation of {@link SecurityManager#checkPackageAccess * s.checkPackageAccess()} denies access to the package ! * of this class. * * @since JDK1.1 */ public Class<?>[] getClasses() { checkMemberAccess(Member.PUBLIC, ClassLoader.getCallerClassLoader(), false); // Privileged so this implementation can look at DECLARED classes, // something the caller might not have privilege to do. The code here // is allowed to look at DECLARED classes because (1) it does not hand
*** 1350,1384 **** * * <p> See <em>The Java Language Specification</em>, sections 8.2 and 8.3. * * @return the array of {@code Field} objects representing the * public fields - * @exception SecurityException - * If a security manager, <i>s</i>, is present and any of the - * following conditions is met: * ! * <ul> ! * ! * <li> invocation of ! * {@link SecurityManager#checkMemberAccess ! * s.checkMemberAccess(this, Member.PUBLIC)} denies ! * access to the fields within this class ! * ! * <li> the caller's class loader is not the same as or an * ancestor of the class loader for the current class and * invocation of {@link SecurityManager#checkPackageAccess * s.checkPackageAccess()} denies access to the package ! * of this class ! * ! * </ul> * * @since JDK1.1 */ public Field[] getFields() throws SecurityException { - // be very careful not to change the stack depth of this - // checkMemberAccess call for security reasons - // see java.lang.SecurityManager.checkMemberAccess checkMemberAccess(Member.PUBLIC, ClassLoader.getCallerClassLoader(), true); return copyFields(privateGetPublicFields(null)); } --- 1324,1345 ---- * * <p> See <em>The Java Language Specification</em>, sections 8.2 and 8.3. * * @return the array of {@code Field} objects representing the * public fields * ! * @throws SecurityException ! * If a security manager, <i>s</i>, is present and ! * the caller's class loader is not the same as or an * ancestor of the class loader for the current class and * invocation of {@link SecurityManager#checkPackageAccess * s.checkPackageAccess()} denies access to the package ! * of this class. * * @since JDK1.1 */ public Field[] getFields() throws SecurityException { checkMemberAccess(Member.PUBLIC, ClassLoader.getCallerClassLoader(), true); return copyFields(privateGetPublicFields(null)); }
*** 1401,1435 **** * * <p> See <em>The Java Language Specification</em>, sections 8.2 and 8.4. * * @return the array of {@code Method} objects representing the * public methods of this class ! * @exception SecurityException ! * If a security manager, <i>s</i>, is present and any of the ! * following conditions is met: ! * ! * <ul> ! * ! * <li> invocation of ! * {@link SecurityManager#checkMemberAccess ! * s.checkMemberAccess(this, Member.PUBLIC)} denies ! * access to the methods within this class ! * ! * <li> the caller's class loader is not the same as or an * ancestor of the class loader for the current class and * invocation of {@link SecurityManager#checkPackageAccess * s.checkPackageAccess()} denies access to the package ! * of this class ! * ! * </ul> * * @since JDK1.1 */ public Method[] getMethods() throws SecurityException { - // be very careful not to change the stack depth of this - // checkMemberAccess call for security reasons - // see java.lang.SecurityManager.checkMemberAccess checkMemberAccess(Member.PUBLIC, ClassLoader.getCallerClassLoader(), true); return copyMethods(privateGetPublicMethods()); } --- 1362,1382 ---- * * <p> See <em>The Java Language Specification</em>, sections 8.2 and 8.4. * * @return the array of {@code Method} objects representing the * public methods of this class ! * @throws SecurityException ! * If a security manager, <i>s</i>, is present and ! * the caller's class loader is not the same as or an * ancestor of the class loader for the current class and * invocation of {@link SecurityManager#checkPackageAccess * s.checkPackageAccess()} denies access to the package ! * of this class. * * @since JDK1.1 */ public Method[] getMethods() throws SecurityException { checkMemberAccess(Member.PUBLIC, ClassLoader.getCallerClassLoader(), true); return copyMethods(privateGetPublicMethods()); }
*** 1450,1484 **** * different classes, which would violate the type guarantees of * {@code Constructor<T>[]}. * * @return the array of {@code Constructor} objects representing the * public constructors of this class ! * @exception SecurityException ! * If a security manager, <i>s</i>, is present and any of the ! * following conditions is met: ! * ! * <ul> ! * ! * <li> invocation of ! * {@link SecurityManager#checkMemberAccess ! * s.checkMemberAccess(this, Member.PUBLIC)} denies ! * access to the constructors within this class ! * ! * <li> the caller's class loader is not the same as or an * ancestor of the class loader for the current class and * invocation of {@link SecurityManager#checkPackageAccess * s.checkPackageAccess()} denies access to the package ! * of this class ! * ! * </ul> * * @since JDK1.1 */ public Constructor<?>[] getConstructors() throws SecurityException { - // be very careful not to change the stack depth of this - // checkMemberAccess call for security reasons - // see java.lang.SecurityManager.checkMemberAccess checkMemberAccess(Member.PUBLIC, ClassLoader.getCallerClassLoader(), true); return copyConstructors(privateGetDeclaredConstructors(true)); } --- 1397,1417 ---- * different classes, which would violate the type guarantees of * {@code Constructor<T>[]}. * * @return the array of {@code Constructor} objects representing the * public constructors of this class ! * @throws SecurityException ! * If a security manager, <i>s</i>, is present and ! * the caller's class loader is not the same as or an * ancestor of the class loader for the current class and * invocation of {@link SecurityManager#checkPackageAccess * s.checkPackageAccess()} denies access to the package ! * of this class. * * @since JDK1.1 */ public Constructor<?>[] getConstructors() throws SecurityException { checkMemberAccess(Member.PUBLIC, ClassLoader.getCallerClassLoader(), true); return copyConstructors(privateGetDeclaredConstructors(true)); }
*** 1505,1543 **** * <p> See <em>The Java Language Specification</em>, sections 8.2 and 8.3. * * @param name the field name * @return the {@code Field} object of this class specified by * {@code name} ! * @exception NoSuchFieldException if a field with the specified name is * not found. ! * @exception NullPointerException if {@code name} is {@code null} ! * @exception SecurityException ! * If a security manager, <i>s</i>, is present and any of the ! * following conditions is met: ! * ! * <ul> ! * ! * <li> invocation of ! * {@link SecurityManager#checkMemberAccess ! * s.checkMemberAccess(this, Member.PUBLIC)} denies ! * access to the field ! * ! * <li> the caller's class loader is not the same as or an * ancestor of the class loader for the current class and * invocation of {@link SecurityManager#checkPackageAccess * s.checkPackageAccess()} denies access to the package ! * of this class ! * ! * </ul> * * @since JDK1.1 */ public Field getField(String name) throws NoSuchFieldException, SecurityException { - // be very careful not to change the stack depth of this - // checkMemberAccess call for security reasons - // see java.lang.SecurityManager.checkMemberAccess checkMemberAccess(Member.PUBLIC, ClassLoader.getCallerClassLoader(), true); Field field = getField0(name); if (field == null) { throw new NoSuchFieldException(name); } --- 1438,1462 ---- * <p> See <em>The Java Language Specification</em>, sections 8.2 and 8.3. * * @param name the field name * @return the {@code Field} object of this class specified by * {@code name} ! * @throws NoSuchFieldException if a field with the specified name is * not found. ! * @throws NullPointerException if {@code name} is {@code null} ! * @throws SecurityException ! * If a security manager, <i>s</i>, is present and ! * the caller's class loader is not the same as or an * ancestor of the class loader for the current class and * invocation of {@link SecurityManager#checkPackageAccess * s.checkPackageAccess()} denies access to the package ! * of this class. * * @since JDK1.1 */ public Field getField(String name) throws NoSuchFieldException, SecurityException { checkMemberAccess(Member.PUBLIC, ClassLoader.getCallerClassLoader(), true); Field field = getField0(name); if (field == null) { throw new NoSuchFieldException(name); }
*** 1590,1628 **** * * @param name the name of the method * @param parameterTypes the list of parameters * @return the {@code Method} object that matches the specified * {@code name} and {@code parameterTypes} ! * @exception NoSuchMethodException if a matching method is not found * or if the name is "&lt;init&gt;"or "&lt;clinit&gt;". ! * @exception NullPointerException if {@code name} is {@code null} ! * @exception SecurityException ! * If a security manager, <i>s</i>, is present and any of the ! * following conditions is met: ! * ! * <ul> ! * ! * <li> invocation of ! * {@link SecurityManager#checkMemberAccess ! * s.checkMemberAccess(this, Member.PUBLIC)} denies ! * access to the method ! * ! * <li> the caller's class loader is not the same as or an * ancestor of the class loader for the current class and * invocation of {@link SecurityManager#checkPackageAccess * s.checkPackageAccess()} denies access to the package ! * of this class ! * ! * </ul> * * @since JDK1.1 */ public Method getMethod(String name, Class<?>... parameterTypes) throws NoSuchMethodException, SecurityException { - // be very careful not to change the stack depth of this - // checkMemberAccess call for security reasons - // see java.lang.SecurityManager.checkMemberAccess checkMemberAccess(Member.PUBLIC, ClassLoader.getCallerClassLoader(), true); Method method = getMethod0(name, parameterTypes); if (method == null) { throw new NoSuchMethodException(getName() + "." + name + argumentTypesToString(parameterTypes)); } --- 1509,1533 ---- * * @param name the name of the method * @param parameterTypes the list of parameters * @return the {@code Method} object that matches the specified * {@code name} and {@code parameterTypes} ! * @throws NoSuchMethodException if a matching method is not found * or if the name is "&lt;init&gt;"or "&lt;clinit&gt;". ! * @throws NullPointerException if {@code name} is {@code null} ! * @throws SecurityException ! * If a security manager, <i>s</i>, is present and ! * the caller's class loader is not the same as or an * ancestor of the class loader for the current class and * invocation of {@link SecurityManager#checkPackageAccess * s.checkPackageAccess()} denies access to the package ! * of this class. * * @since JDK1.1 */ public Method getMethod(String name, Class<?>... parameterTypes) throws NoSuchMethodException, SecurityException { checkMemberAccess(Member.PUBLIC, ClassLoader.getCallerClassLoader(), true); Method method = getMethod0(name, parameterTypes); if (method == null) { throw new NoSuchMethodException(getName() + "." + name + argumentTypesToString(parameterTypes)); }
*** 1646,1682 **** * types match those specified by {@code parameterTypes}. * * @param parameterTypes the parameter array * @return the {@code Constructor} object of the public constructor that * matches the specified {@code parameterTypes} ! * @exception NoSuchMethodException if a matching method is not found. ! * @exception SecurityException ! * If a security manager, <i>s</i>, is present and any of the ! * following conditions is met: ! * ! * <ul> ! * ! * <li> invocation of ! * {@link SecurityManager#checkMemberAccess ! * s.checkMemberAccess(this, Member.PUBLIC)} denies ! * access to the constructor ! * ! * <li> the caller's class loader is not the same as or an * ancestor of the class loader for the current class and * invocation of {@link SecurityManager#checkPackageAccess * s.checkPackageAccess()} denies access to the package ! * of this class ! * ! * </ul> * * @since JDK1.1 */ public Constructor<T> getConstructor(Class<?>... parameterTypes) throws NoSuchMethodException, SecurityException { - // be very careful not to change the stack depth of this - // checkMemberAccess call for security reasons - // see java.lang.SecurityManager.checkMemberAccess checkMemberAccess(Member.PUBLIC, ClassLoader.getCallerClassLoader(), true); return getConstructor0(parameterTypes, Member.PUBLIC); } --- 1551,1573 ---- * types match those specified by {@code parameterTypes}. * * @param parameterTypes the parameter array * @return the {@code Constructor} object of the public constructor that * matches the specified {@code parameterTypes} ! * @throws NoSuchMethodException if a matching method is not found. ! * @throws SecurityException ! * If a security manager, <i>s</i>, is present and ! * the caller's class loader is not the same as or an * ancestor of the class loader for the current class and * invocation of {@link SecurityManager#checkPackageAccess * s.checkPackageAccess()} denies access to the package ! * of this class. * * @since JDK1.1 */ public Constructor<T> getConstructor(Class<?>... parameterTypes) throws NoSuchMethodException, SecurityException { checkMemberAccess(Member.PUBLIC, ClassLoader.getCallerClassLoader(), true); return getConstructor0(parameterTypes, Member.PUBLIC); }
*** 1690,1709 **** * interfaces as members, or if this {@code Class} object represents a * primitive type, an array class, or void. * * @return the array of {@code Class} objects representing all the * declared members of this class ! * @exception SecurityException * If a security manager, <i>s</i>, is present and any of the * following conditions is met: * * <ul> * ! * <li> invocation of ! * {@link SecurityManager#checkMemberAccess ! * s.checkMemberAccess(this, Member.DECLARED)} denies ! * access to the declared classes within this class * * <li> the caller's class loader is not the same as or an * ancestor of the class loader for the current class and * invocation of {@link SecurityManager#checkPackageAccess * s.checkPackageAccess()} denies access to the package --- 1581,1602 ---- * interfaces as members, or if this {@code Class} object represents a * primitive type, an array class, or void. * * @return the array of {@code Class} objects representing all the * declared members of this class ! * @throws SecurityException * If a security manager, <i>s</i>, is present and any of the * following conditions is met: * * <ul> * ! * <li> the caller's class loader is not the same as the ! * class loader of this class and invocation of ! * {@link SecurityManager#checkPermission ! * s.checkPermission} method with ! * {@code RuntimePermission("accessDeclaredMembers")} ! * denies access to the declared classes within this class * * <li> the caller's class loader is not the same as or an * ancestor of the class loader for the current class and * invocation of {@link SecurityManager#checkPackageAccess * s.checkPackageAccess()} denies access to the package
*** 1712,1724 **** * </ul> * * @since JDK1.1 */ public Class<?>[] getDeclaredClasses() throws SecurityException { - // be very careful not to change the stack depth of this - // checkMemberAccess call for security reasons - // see java.lang.SecurityManager.checkMemberAccess checkMemberAccess(Member.DECLARED, ClassLoader.getCallerClassLoader(), false); return getDeclaredClasses0(); } --- 1605,1614 ----
*** 1734,1753 **** * * <p> See <em>The Java Language Specification</em>, sections 8.2 and 8.3. * * @return the array of {@code Field} objects representing all the * declared fields of this class ! * @exception SecurityException * If a security manager, <i>s</i>, is present and any of the * following conditions is met: * * <ul> * ! * <li> invocation of ! * {@link SecurityManager#checkMemberAccess ! * s.checkMemberAccess(this, Member.DECLARED)} denies ! * access to the declared fields within this class * * <li> the caller's class loader is not the same as or an * ancestor of the class loader for the current class and * invocation of {@link SecurityManager#checkPackageAccess * s.checkPackageAccess()} denies access to the package --- 1624,1645 ---- * * <p> See <em>The Java Language Specification</em>, sections 8.2 and 8.3. * * @return the array of {@code Field} objects representing all the * declared fields of this class ! * @throws SecurityException * If a security manager, <i>s</i>, is present and any of the * following conditions is met: * * <ul> * ! * <li> the caller's class loader is not the same as the ! * class loader of this class and invocation of ! * {@link SecurityManager#checkPermission ! * s.checkPermission} method with ! * {@code RuntimePermission("accessDeclaredMembers")} ! * denies access to the declared fields within this class * * <li> the caller's class loader is not the same as or an * ancestor of the class loader for the current class and * invocation of {@link SecurityManager#checkPackageAccess * s.checkPackageAccess()} denies access to the package
*** 1756,1768 **** * </ul> * * @since JDK1.1 */ public Field[] getDeclaredFields() throws SecurityException { - // be very careful not to change the stack depth of this - // checkMemberAccess call for security reasons - // see java.lang.SecurityManager.checkMemberAccess checkMemberAccess(Member.DECLARED, ClassLoader.getCallerClassLoader(), true); return copyFields(privateGetDeclaredFields(false)); } --- 1648,1657 ----
*** 1782,1801 **** * * <p> See <em>The Java Language Specification</em>, section 8.2. * * @return the array of {@code Method} objects representing all the * declared methods of this class ! * @exception SecurityException * If a security manager, <i>s</i>, is present and any of the * following conditions is met: * * <ul> * ! * <li> invocation of ! * {@link SecurityManager#checkMemberAccess ! * s.checkMemberAccess(this, Member.DECLARED)} denies ! * access to the declared methods within this class * * <li> the caller's class loader is not the same as or an * ancestor of the class loader for the current class and * invocation of {@link SecurityManager#checkPackageAccess * s.checkPackageAccess()} denies access to the package --- 1671,1692 ---- * * <p> See <em>The Java Language Specification</em>, section 8.2. * * @return the array of {@code Method} objects representing all the * declared methods of this class ! * @throws SecurityException * If a security manager, <i>s</i>, is present and any of the * following conditions is met: * * <ul> * ! * <li> the caller's class loader is not the same as the ! * class loader of this class and invocation of ! * {@link SecurityManager#checkPermission ! * s.checkPermission} method with ! * {@code RuntimePermission("accessDeclaredMembers")} ! * denies access to the declared methods within this class * * <li> the caller's class loader is not the same as or an * ancestor of the class loader for the current class and * invocation of {@link SecurityManager#checkPackageAccess * s.checkPackageAccess()} denies access to the package
*** 1804,1816 **** * </ul> * * @since JDK1.1 */ public Method[] getDeclaredMethods() throws SecurityException { - // be very careful not to change the stack depth of this - // checkMemberAccess call for security reasons - // see java.lang.SecurityManager.checkMemberAccess checkMemberAccess(Member.DECLARED, ClassLoader.getCallerClassLoader(), true); return copyMethods(privateGetDeclaredMethods(false)); } --- 1695,1704 ----
*** 1827,1846 **** * * <p> See <em>The Java Language Specification</em>, section 8.2. * * @return the array of {@code Constructor} objects representing all the * declared constructors of this class ! * @exception SecurityException * If a security manager, <i>s</i>, is present and any of the * following conditions is met: * * <ul> * ! * <li> invocation of ! * {@link SecurityManager#checkMemberAccess ! * s.checkMemberAccess(this, Member.DECLARED)} denies ! * access to the declared constructors within this class * * <li> the caller's class loader is not the same as or an * ancestor of the class loader for the current class and * invocation of {@link SecurityManager#checkPackageAccess * s.checkPackageAccess()} denies access to the package --- 1715,1736 ---- * * <p> See <em>The Java Language Specification</em>, section 8.2. * * @return the array of {@code Constructor} objects representing all the * declared constructors of this class ! * @throws SecurityException * If a security manager, <i>s</i>, is present and any of the * following conditions is met: * * <ul> * ! * <li> the caller's class loader is not the same as the ! * class loader of this class and invocation of ! * {@link SecurityManager#checkPermission ! * s.checkPermission} method with ! * {@code RuntimePermission("accessDeclaredMembers")} ! * denies access to the declared constructors within this class * * <li> the caller's class loader is not the same as or an * ancestor of the class loader for the current class and * invocation of {@link SecurityManager#checkPackageAccess * s.checkPackageAccess()} denies access to the package
*** 1849,1861 **** * </ul> * * @since JDK1.1 */ public Constructor<?>[] getDeclaredConstructors() throws SecurityException { - // be very careful not to change the stack depth of this - // checkMemberAccess call for security reasons - // see java.lang.SecurityManager.checkMemberAccess checkMemberAccess(Member.DECLARED, ClassLoader.getCallerClassLoader(), true); return copyConstructors(privateGetDeclaredConstructors(false)); } --- 1739,1748 ----
*** 1867,1889 **** * will not reflect the {@code length} field of an array class. * * @param name the name of the field * @return the {@code Field} object for the specified field in this * class ! * @exception NoSuchFieldException if a field with the specified name is * not found. ! * @exception NullPointerException if {@code name} is {@code null} ! * @exception SecurityException * If a security manager, <i>s</i>, is present and any of the * following conditions is met: * * <ul> * ! * <li> invocation of ! * {@link SecurityManager#checkMemberAccess ! * s.checkMemberAccess(this, Member.DECLARED)} denies ! * access to the declared field * * <li> the caller's class loader is not the same as or an * ancestor of the class loader for the current class and * invocation of {@link SecurityManager#checkPackageAccess * s.checkPackageAccess()} denies access to the package --- 1754,1778 ---- * will not reflect the {@code length} field of an array class. * * @param name the name of the field * @return the {@code Field} object for the specified field in this * class ! * @throws NoSuchFieldException if a field with the specified name is * not found. ! * @throws NullPointerException if {@code name} is {@code null} ! * @throws SecurityException * If a security manager, <i>s</i>, is present and any of the * following conditions is met: * * <ul> * ! * <li> the caller's class loader is not the same as the ! * class loader of this class and invocation of ! * {@link SecurityManager#checkPermission ! * s.checkPermission} method with ! * {@code RuntimePermission("accessDeclaredMembers")} ! * denies access to the declared field * * <li> the caller's class loader is not the same as or an * ancestor of the class loader for the current class and * invocation of {@link SecurityManager#checkPackageAccess * s.checkPackageAccess()} denies access to the package
*** 1893,1905 **** * * @since JDK1.1 */ public Field getDeclaredField(String name) throws NoSuchFieldException, SecurityException { - // be very careful not to change the stack depth of this - // checkMemberAccess call for security reasons - // see java.lang.SecurityManager.checkMemberAccess checkMemberAccess(Member.DECLARED, ClassLoader.getCallerClassLoader(), true); Field field = searchFields(privateGetDeclaredFields(false), name); if (field == null) { throw new NoSuchFieldException(name); } --- 1782,1791 ----
*** 1923,1944 **** * * @param name the name of the method * @param parameterTypes the parameter array * @return the {@code Method} object for the method of this class * matching the specified name and parameters ! * @exception NoSuchMethodException if a matching method is not found. ! * @exception NullPointerException if {@code name} is {@code null} ! * @exception SecurityException * If a security manager, <i>s</i>, is present and any of the * following conditions is met: * * <ul> * ! * <li> invocation of ! * {@link SecurityManager#checkMemberAccess ! * s.checkMemberAccess(this, Member.DECLARED)} denies ! * access to the declared method * * <li> the caller's class loader is not the same as or an * ancestor of the class loader for the current class and * invocation of {@link SecurityManager#checkPackageAccess * s.checkPackageAccess()} denies access to the package --- 1809,1832 ---- * * @param name the name of the method * @param parameterTypes the parameter array * @return the {@code Method} object for the method of this class * matching the specified name and parameters ! * @throws NoSuchMethodException if a matching method is not found. ! * @throws NullPointerException if {@code name} is {@code null} ! * @throws SecurityException * If a security manager, <i>s</i>, is present and any of the * following conditions is met: * * <ul> * ! * <li> the caller's class loader is not the same as the ! * class loader of this class and invocation of ! * {@link SecurityManager#checkPermission ! * s.checkPermission} method with ! * {@code RuntimePermission("accessDeclaredMembers")} ! * denies access to the declared method * * <li> the caller's class loader is not the same as or an * ancestor of the class loader for the current class and * invocation of {@link SecurityManager#checkPackageAccess * s.checkPackageAccess()} denies access to the package
*** 1948,1960 **** * * @since JDK1.1 */ public Method getDeclaredMethod(String name, Class<?>... parameterTypes) throws NoSuchMethodException, SecurityException { - // be very careful not to change the stack depth of this - // checkMemberAccess call for security reasons - // see java.lang.SecurityManager.checkMemberAccess checkMemberAccess(Member.DECLARED, ClassLoader.getCallerClassLoader(), true); Method method = searchMethods(privateGetDeclaredMethods(false), name, parameterTypes); if (method == null) { throw new NoSuchMethodException(getName() + "." + name + argumentTypesToString(parameterTypes)); } --- 1836,1845 ----
*** 1974,1994 **** * include the explicit enclosing instance as the first parameter. * * @param parameterTypes the parameter array * @return The {@code Constructor} object for the constructor with the * specified parameter list ! * @exception NoSuchMethodException if a matching method is not found. ! * @exception SecurityException * If a security manager, <i>s</i>, is present and any of the * following conditions is met: * * <ul> * ! * <li> invocation of ! * {@link SecurityManager#checkMemberAccess ! * s.checkMemberAccess(this, Member.DECLARED)} denies ! * access to the declared constructor * * <li> the caller's class loader is not the same as or an * ancestor of the class loader for the current class and * invocation of {@link SecurityManager#checkPackageAccess * s.checkPackageAccess()} denies access to the package --- 1859,1881 ---- * include the explicit enclosing instance as the first parameter. * * @param parameterTypes the parameter array * @return The {@code Constructor} object for the constructor with the * specified parameter list ! * @throws NoSuchMethodException if a matching method is not found. ! * @throws SecurityException * If a security manager, <i>s</i>, is present and any of the * following conditions is met: * * <ul> * ! * <li> the caller's class loader is not the same as the ! * class loader of this class and invocation of ! * {@link SecurityManager#checkPermission ! * s.checkPermission} method with ! * {@code RuntimePermission("accessDeclaredMembers")} ! * denies access to the declared constructor * * <li> the caller's class loader is not the same as or an * ancestor of the class loader for the current class and * invocation of {@link SecurityManager#checkPackageAccess * s.checkPackageAccess()} denies access to the package
*** 1998,2010 **** * * @since JDK1.1 */ public Constructor<T> getDeclaredConstructor(Class<?>... parameterTypes) throws NoSuchMethodException, SecurityException { - // be very careful not to change the stack depth of this - // checkMemberAccess call for security reasons - // see java.lang.SecurityManager.checkMemberAccess checkMemberAccess(Member.DECLARED, ClassLoader.getCallerClassLoader(), true); return getConstructor0(parameterTypes, Member.DECLARED); } /** --- 1885,1894 ----
*** 2164,2184 **** /* * Check if client is allowed to access members. If access is denied, * throw a SecurityException. * - * Be very careful not to change the stack depth of this checkMemberAccess - * call for security reasons. - * See java.lang.SecurityManager.checkMemberAccess. - * * <p> Default policy: allow all clients access with normal Java access * control. */ private void checkMemberAccess(int which, ClassLoader ccl, boolean checkProxyInterfaces) { SecurityManager s = System.getSecurityManager(); if (s != null) { ! s.checkMemberAccess(this, which); ClassLoader cl = getClassLoader0(); if (ReflectUtil.needsPackageAccessCheck(ccl, cl)) { String name = this.getName(); int i = name.lastIndexOf('.'); if (i != -1) { --- 2048,2073 ---- /* * Check if client is allowed to access members. If access is denied, * throw a SecurityException. * * <p> Default policy: allow all clients access with normal Java access * control. */ private void checkMemberAccess(int which, ClassLoader ccl, boolean checkProxyInterfaces) { SecurityManager s = System.getSecurityManager(); if (s != null) { ! /* Default policy allows access to all {@link Member#PUBLIC} members, ! * as well as access to classes that have the same class loader as the caller. ! * In all other cases, it requires RuntimePermission("accessDeclaredMembers") ! * permission. ! */ ! if (which != Member.PUBLIC) { ! if (ccl != this.getClassLoader()) { ! s.checkPermission(SecurityConstants.CHECK_MEMBER_ACCESS_PERMISSION); ! } ! } ClassLoader cl = getClassLoader0(); if (ReflectUtil.needsPackageAccessCheck(ccl, cl)) { String name = this.getName(); int i = name.lastIndexOf('.'); if (i != -1) {