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

Print this page
rev 7928 : 5047859: (reflect) Class.getField can't find String[].length
Reviewed-by: duke

*** 1493,1505 **** * this method returns the public fields of this class and of all its * superclasses. If this {@code Class} object represents an * interface, this method returns the fields of this interface and of all * its superinterfaces. * ! * <p> The implicit length field for array class is not reflected by this ! * method. User code should use the methods of class {@code Array} to ! * manipulate arrays. * * <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 --- 1493,1505 ---- * this method returns the public fields of this class and of all its * superclasses. If this {@code Class} object represents an * interface, this method returns the fields of this interface and of all * its superinterfaces. * ! * <p> If this Class object represents an array type, then the returned array ! * does not contain a Field object for the 'length' field of the array ! * type. * * <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
*** 1599,1609 **** * member field of the class or interface represented by this * {@code Class} object. The {@code name} parameter is a * {@code String} specifying the simple name of the desired field. * * <p> The field to be reflected is determined by the algorithm that ! * follows. Let C be the class represented by this object: * <OL> * <LI> If C declares a public field with the name specified, that is the * field to be reflected.</LI> * <LI> If no field was found in step 1 above, this algorithm is applied * recursively to each direct superinterface of C. The direct --- 1599,1609 ---- * member field of the class or interface represented by this * {@code Class} object. The {@code name} parameter is a * {@code String} specifying the simple name of the desired field. * * <p> The field to be reflected is determined by the algorithm that ! * follows. Let C be the class or interface represented by this object: * <OL> * <LI> If C declares a public field with the name specified, that is the * field to be reflected.</LI> * <LI> If no field was found in step 1 above, this algorithm is applied * recursively to each direct superinterface of C. The direct
*** 1612,1621 **** --- 1612,1624 ---- * superclass S, then this algorithm is invoked recursively upon S. * If C has no superclass, then a {@code NoSuchFieldException} * is thrown.</LI> * </OL> * + * <p> If this Class object represents an array type, then this method does + * not find the 'length' field of the array type. + * * <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}