< prev index next >

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

Print this page

        

*** 137,147 **** * " is " + obj.getClass().getName()); * } * </pre></blockquote> * * <p> It is also possible to get the {@code Class} object for a named ! * type (or for void) using a class literal. See Section 15.8.2 of * <cite>The Java&trade; Language Specification</cite>. * For example: * * <blockquote> * {@code System.out.println("The name of class Foo is: "+Foo.class.getName());} --- 137,147 ---- * " is " + obj.getClass().getName()); * } * </pre></blockquote> * * <p> It is also possible to get the {@code Class} object for a named ! * type (or for void) using a class literal. See Section {@jls 15.8.2} of * <cite>The Java&trade; Language Specification</cite>. * For example: * * <blockquote> * {@code System.out.println("The name of class Foo is: "+Foo.class.getName());}
*** 374,391 **** * {@code Class.forName("Foo", true, this.getClass().getClassLoader())} * </blockquote> * * Note that this method throws errors related to loading, linking * or initializing as specified in Sections {@jls 12.2}, {@jls ! * 12.3}, and {@jls 12.4} of <em>The Java Language ! * Specification</em>. * Note that this method does not check whether the requested class * is accessible to its caller. * * @param name fully qualified name of the desired class * @param initialize if {@code true} the class will be initialized (which implies linking). ! * See Section {@jls 12.4} of <em>The Java Language Specification</em>. * @param loader class loader from which the class must be loaded * @return class object representing the desired class * * @throws LinkageError if the linkage fails * @throws ExceptionInInitializerError if the initialization provoked --- 374,391 ---- * {@code Class.forName("Foo", true, this.getClass().getClassLoader())} * </blockquote> * * Note that this method throws errors related to loading, linking * or initializing as specified in Sections {@jls 12.2}, {@jls ! * 12.3}, and {@jls 12.4} of <cite>The Java&trade; Language ! * Specification</cite>. * Note that this method does not check whether the requested class * is accessible to its caller. * * @param name fully qualified name of the desired class * @param initialize if {@code true} the class will be initialized (which implies linking). ! * See Section {@jls 12.4} of <cite>The Java&trade; Language Specification</cite>. * @param loader class loader from which the class must be loaded * @return class object representing the desired class * * @throws LinkageError if the linkage fails * @throws ExceptionInInitializerError if the initialization provoked
*** 658,669 **** * {@code false}. * * <p> Specifically, this method tests whether the type represented by the * specified {@code Class} parameter can be converted to the type * represented by this {@code Class} object via an identity conversion ! * or via a widening reference conversion. See <em>The Java Language ! * Specification</em>, sections {@jls 5.1.1} and {@jls 5.1.4}, * for details. * * @param cls the {@code Class} object to be checked * @return the {@code boolean} value indicating whether objects of the * type {@code cls} can be assigned to objects of this class --- 658,669 ---- * {@code false}. * * <p> Specifically, this method tests whether the type represented by the * specified {@code Class} parameter can be converted to the type * represented by this {@code Class} object via an identity conversion ! * or via a widening reference conversion. See <cite>The Java&trade; Language ! * Specification</cite>, sections {@jls 5.1.1} and {@jls 5.1.4}, * for details. * * @param cls the {@code Class} object to be checked * @return the {@code boolean} value indicating whether objects of the * type {@code cls} can be assigned to objects of this class
*** 743,753 **** /** * Returns {@code true} if this class is a synthetic class; * returns {@code false} otherwise. * @return {@code true} if and only if this class is a synthetic class as ! * defined by the Java Language Specification. * @jls 13.1 The Form of a Binary * @since 1.5 */ public boolean isSynthetic() { return (getModifiers() & SYNTHETIC) != 0; --- 743,753 ---- /** * Returns {@code true} if this class is a synthetic class; * returns {@code false} otherwise. * @return {@code true} if and only if this class is a synthetic class as ! * defined by <cite>The Java&trade; Language Specification</cite>. * @jls 13.1 The Form of a Binary * @since 1.5 */ public boolean isSynthetic() { return (getModifiers() & SYNTHETIC) != 0;
*** 894,905 **** * * @return an array of {@code TypeVariable} objects that represent * the type variables declared by this generic declaration * @throws java.lang.reflect.GenericSignatureFormatError if the generic * signature of this generic declaration does not conform to ! * the format specified in ! * <cite>The Java&trade; Virtual Machine Specification</cite> * @since 1.5 */ @SuppressWarnings("unchecked") public TypeVariable<Class<T>>[] getTypeParameters() { ClassRepository info = getGenericInfo(); --- 894,905 ---- * * @return an array of {@code TypeVariable} objects that represent * the type variables declared by this generic declaration * @throws java.lang.reflect.GenericSignatureFormatError if the generic * signature of this generic declaration does not conform to ! * the format specified in section {@jvms 4.7.9} of the ! * <cite>The Java&trade; Virtual Machine Specification</cite>, * @since 1.5 */ @SuppressWarnings("unchecked") public TypeVariable<Class<T>>[] getTypeParameters() { ClassRepository info = getGenericInfo();
*** 943,952 **** --- 943,953 ---- * {@code Class} object representing the {@code Object} class is * returned. * * @throws java.lang.reflect.GenericSignatureFormatError if the generic * class signature does not conform to the format specified in + * section {@jvms 4.7.9} of the * <cite>The Java&trade; Virtual Machine Specification</cite> * @throws TypeNotPresentException if the generic superclass * refers to a non-existent type declaration * @throws java.lang.reflect.MalformedParameterizedTypeException if the * generic superclass refers to a parameterized type that cannot be
*** 1141,1151 **** * interfaces {@code Cloneable} and {@code java.io.Serializable} are * returned in that order. * * @throws java.lang.reflect.GenericSignatureFormatError * if the generic class signature does not conform to the format ! * specified in * <cite>The Java&trade; Virtual Machine Specification</cite> * @throws TypeNotPresentException if any of the generic * superinterfaces refers to a non-existent type declaration * @throws java.lang.reflect.MalformedParameterizedTypeException * if any of the generic superinterfaces refer to a parameterized --- 1142,1152 ---- * interfaces {@code Cloneable} and {@code java.io.Serializable} are * returned in that order. * * @throws java.lang.reflect.GenericSignatureFormatError * if the generic class signature does not conform to the format ! * specified in section {@jvms 4.7.9} of the * <cite>The Java&trade; Virtual Machine Specification</cite> * @throws TypeNotPresentException if any of the generic * superinterfaces refers to a non-existent type declaration * @throws java.lang.reflect.MalformedParameterizedTypeException * if any of the generic superinterfaces refer to a parameterized
*** 1199,1210 **** * primitive type or void, then its {@code final} modifier is always * {@code true} and its interface modifier is always * {@code false}. The values of its other modifiers are not determined * by this specification. * ! * <p> The modifier encodings are defined in <em>The Java Virtual Machine ! * Specification</em>, table 4.1. * * @return the {@code int} representing the modifiers for this class * @see java.lang.reflect.Modifier * @since 1.1 */ --- 1200,1211 ---- * primitive type or void, then its {@code final} modifier is always * {@code true} and its interface modifier is always * {@code false}. The values of its other modifiers are not determined * by this specification. * ! * <p> The modifier encodings are defined in section {@jvms 4.1} of the ! * <cite>The Java&trade; Virtual Machine Specification</cite>. * * @return the {@code int} representing the modifiers for this class * @see java.lang.reflect.Modifier * @since 1.1 */
*** 1609,1619 **** return getName(); } /** * Returns the canonical name of the underlying class as ! * defined by the Java Language Specification. Returns null if * the underlying class does not have a canonical name (i.e., if * it is a local or anonymous class or an array whose component * type does not have a canonical name). * @return the canonical name of the underlying class if it exists, and * {@code null} otherwise. --- 1610,1620 ---- return getName(); } /** * Returns the canonical name of the underlying class as ! * defined by <cite>The Java&trade; Language Specification</cite>, section {@jls 6.7}. Returns null if * the underlying class does not have a canonical name (i.e., if * it is a local or anonymous class or an array whose component * type does not have a canonical name). * @return the canonical name of the underlying class if it exists, and * {@code null} otherwise.
*** 1926,1936 **** * all the public constructors of the class represented by this * {@code Class} object. An array of length 0 is returned if the * class has no public constructors, or if the class is an array class, or * if the class reflects a primitive type or void. * ! * Note that while this method returns an array of {@code * Constructor<T>} objects (that is an array of constructors from * this class), the return type of this method is {@code * Constructor<?>[]} and <em>not</em> {@code Constructor<T>[]} as * might be expected. This less informative return type is * necessary since after being returned from this method, the --- 1927,1938 ---- * all the public constructors of the class represented by this * {@code Class} object. An array of length 0 is returned if the * class has no public constructors, or if the class is an array class, or * if the class reflects a primitive type or void. * ! * @apiNote ! * While this method returns an array of {@code * Constructor<T>} objects (that is an array of constructors from * this class), the return type of this method is {@code * Constructor<?>[]} and <em>not</em> {@code Constructor<T>[]} as * might be expected. This less informative return type is * necessary since after being returned from this method, the
*** 2399,2409 **** * class has a default constructor, it is included in the returned array. * This method returns an array of length 0 if this {@code Class} * object represents an interface, a primitive type, an array class, or * void. * ! * <p> See <em>The Java Language Specification</em>, section {@jls 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 --- 2401,2411 ---- * class has a default constructor, it is included in the returned array. * This method returns an array of length 0 if this {@code Class} * object represents an interface, a primitive type, an array class, or * void. * ! * <p> See <cite>The Java&trade; Language Specification</cite>, section {@jls 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
*** 3536,3548 **** * status pertains to this class, the most recent setting for the most * specific pertinent package default assertion status is returned; * otherwise, if this class is not a system class (i.e., it has a * class loader) its class loader's default assertion status is returned; * otherwise, the system class default assertion status is returned. ! * <p> * Few programmers will have any need for this method; it is provided ! * for the benefit of the JRE itself. (It allows a class to determine at * the time that it is initialized whether assertions should be enabled.) * Note that this method is not guaranteed to return the actual * assertion status that was (or will be) associated with the specified * class when it was (or will be) initialized. * --- 3538,3551 ---- * status pertains to this class, the most recent setting for the most * specific pertinent package default assertion status is returned; * otherwise, if this class is not a system class (i.e., it has a * class loader) its class loader's default assertion status is returned; * otherwise, the system class default assertion status is returned. ! * ! * @apiNote * Few programmers will have any need for this method; it is provided ! * for the benefit of the JDK itself. (It allows a class to determine at * the time that it is initialized whether assertions should be enabled.) * Note that this method is not guaranteed to return the actual * assertion status that was (or will be) associated with the specified * class when it was (or will be) initialized. *
*** 4023,4036 **** * a member of the nest by the nest host, then it is considered to belong * to its own nest and {@code this} is returned as the host. * * @apiNote A {@code class} file of version 55.0 or greater may record the * host of the nest to which it belongs by using the {@code NestHost} ! * attribute (JVMS 4.7.28). Alternatively, a {@code class} file of * version 55.0 or greater may act as a nest host by enumerating the nest's * other members with the ! * {@code NestMembers} attribute (JVMS 4.7.29). * A {@code class} file of version 54.0 or lower does not use these * attributes. * * @return the nest host of this class or interface * --- 4026,4039 ---- * a member of the nest by the nest host, then it is considered to belong * to its own nest and {@code this} is returned as the host. * * @apiNote A {@code class} file of version 55.0 or greater may record the * host of the nest to which it belongs by using the {@code NestHost} ! * attribute (JVMS {@jvms 4.7.28}). Alternatively, a {@code class} file of * version 55.0 or greater may act as a nest host by enumerating the nest's * other members with the ! * {@code NestMembers} attribute (JVMS {@jvms 4.7.29}). * A {@code class} file of version 54.0 or lower does not use these * attributes. * * @return the nest host of this class or interface *
< prev index next >