src/share/classes/java/lang/Class.java
Print this page
rev 7977 : 5047859: (reflect) Class.getField can't find String[].length
Reviewed-by: duke
rev 7978 : 4987375: (reflect) Class.get{Declared}Method{s} does not return clone() for array types
Reviewed-by: duke
*** 819,828 ****
--- 819,831 ----
* interfaces, the method returns an array of length 0.
*
* <p> If this object represents a primitive type or void, the method
* returns an array of length 0.
*
+ * <p> If this Class object represents an array type, the interfaces {@code
+ * Cloneable} and {@code java.io.Serializable} are returned in that order.
+ *
* @return an array of interfaces implemented by this class.
*/
public Class<?>[] getInterfaces() {
ReflectionData<T> rd = reflectionData();
if (rd == null) {
*** 1523,1549 ****
return copyFields(privateGetPublicFields(null));
}
/**
! * Returns an array containing {@code Method} objects reflecting all
! * the public <em>member</em> methods of the class or interface represented
! * by this {@code Class} object, including those declared by the class
! * or interface and those inherited from superclasses and
! * superinterfaces. Array classes return all the (public) member methods
! * inherited from the {@code Object} class. The elements in the array
! * returned are not sorted and are not in any particular order. This
! * method returns an array of length 0 if this {@code Class} object
! * represents a class or interface that has no public member methods, or if
! * this {@code Class} object represents a primitive type or void.
! *
! * <p> The class initialization method {@code <clinit>} is not
! * included in the returned array. If the class declares multiple public
! * member methods with the same parameter types, they are all included in
! * the returned array.
*
! * <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
--- 1526,1560 ----
return copyFields(privateGetPublicFields(null));
}
/**
! * Returns an array containing {@code Method} objects reflecting all the
! * public methods of the class or interface represented by this {@code
! * Class} object, including those declared by the class or interface and
! * those inherited from superclasses and superinterfaces.
! *
! * <p> If this Class object represents a type that has multiple public
! * methods with the same name and parameter types, but different return
! * types, then the returned array has a Method object for each such method.
! *
! * <p> If this Class object represents a type with a class initialization
! * method {@code <clinit>}, then the returned array does <em>not</em> have
! * a corresponding Method object.
! *
! * <p> If this Class object represents an array type, then the returned array
! * has a Method object for each of the public methods inherited by the
! * array type from {@code Object}, except for clone().
! *
! * <p> If this Class object represents a class or interface with no public
! * methods, then the returned array has length 0.
! *
! * <p> If this Class object represents a primitive type or void, then the
! * returned array has length 0.
*
! * <p> The elements in the array returned are not sorted and are not in any
! * particular order.
*
* @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
*** 1551,1560 ****
--- 1562,1573 ----
* 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.
*
+ * @jls 8.2 Class Members
+ * @jls 8.4 Method Declarations
* @since JDK1.1
*/
@CallerSensitive
public Method[] getMethods() throws SecurityException {
checkMemberAccess(Member.PUBLIC, Reflection.getCallerClass(), true);
*** 1691,1701 ****
* returns can be implemented with {@linkplain
* java.lang.reflect.Method#isBridge bridge methods}; the bridge
* method and the method being overridden would have the same
* signature but different return types.
*
! * <p> See <em>The Java Language Specification</em>, sections 8.2 and 8.4.
*
* @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}
--- 1704,1715 ----
* returns can be implemented with {@linkplain
* java.lang.reflect.Method#isBridge bridge methods}; the bridge
* method and the method being overridden would have the same
* signature but different return types.
*
! * <p> If this Class object represents an array type, then this method does
! * not find the {@code clone()} method.
*
* @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}
*** 1708,1717 ****
--- 1722,1733 ----
* 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.
*
+ * @jls 8.2 Class Members
+ * @jls 8.4 Method Declarations
* @since JDK1.1
*/
@CallerSensitive
public Method getMethod(String name, Class<?>... parameterTypes)
throws NoSuchMethodException, SecurityException {
*** 1851,1874 ****
return copyFields(privateGetDeclaredFields(false));
}
/**
- * Returns an array of {@code Method} objects reflecting all the
- * methods declared by the class or interface represented by this
- * {@code Class} object. This includes public, protected, default
- * (package) access, and private methods, but excludes inherited methods.
- * The elements in the array returned are not sorted and are not in any
- * particular order. This method returns an array of length 0 if the class
- * or interface declares no methods, or if this {@code Class} object
- * represents a primitive type, an array class, or void. The class
- * initialization method {@code <clinit>} is not included in the
- * returned array. If the class declares multiple public member methods
- * with the same parameter types, they are all included in the returned
- * array.
*
! * <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
--- 1867,1898 ----
return copyFields(privateGetDeclaredFields(false));
}
/**
*
! * Returns an array containing {@code Method} objects reflecting all the
! * declared methods of the class or interface represented by this {@code
! * Class} object, including public, protected, default (package)
! * access, and private methods, but excluding inherited methods.
! *
! * <p> If this Class object represents a type that has multiple declared
! * methods with the same name and parameter types, but different return
! * types, then the returned array has a Method object for each such method.
! *
! * <p> If this Class object represents a type that has a class
! * initialization method {@code <clinit>}, then the returned array does
! * <em>not</em> have a corresponding Method object.
! *
! * <p> If this Class object represents a class or interface with no
! * declared methods, then the returned array has length 0.
! *
! * <p> If this Class object represents an array type, a primitive type, or
! * void, then the returned array has length 0.
! *
! * <p> The elements in the array returned are not sorted and are not in any
! * particular order.
*
* @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
*** 1889,1898 ****
--- 1913,1924 ----
* s.checkPackageAccess()} denies access to the package
* of this class
*
* </ul>
*
+ * @jls 8.2 Class Members
+ * @jls 8.4 Method Declarations
* @since JDK1.1
*/
@CallerSensitive
public Method[] getDeclaredMethods() throws SecurityException {
checkMemberAccess(Member.DECLARED, Reflection.getCallerClass(), true);
*** 2009,2018 ****
--- 2035,2047 ----
* return type that is more specific than any of the others, that method is
* returned; otherwise one of the methods is chosen arbitrarily. If the
* name is "<init>"or "<clinit>" a {@code NoSuchMethodException}
* is raised.
*
+ * <p> If this Class object represents an array type, then this method does
+ * not find the {@code clone()} method.
+ *
* @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.
*** 2036,2045 ****
--- 2065,2076 ----
* s.checkPackageAccess()} denies access to the package
* of this class
*
* </ul>
*
+ * @jls 8.2 Class Members
+ * @jls 8.4 Method Declarations
* @since JDK1.1
*/
@CallerSensitive
public Method getDeclaredMethod(String name, Class<?>... parameterTypes)
throws NoSuchMethodException, SecurityException {