< prev index next >

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

Print this page




 900      * entity (class, interface, primitive type or void) represented by
 901      * this {@code Class}.  If this {@code Class} represents either the
 902      * {@code Object} class, an interface, a primitive type, or void, then
 903      * null is returned.  If this object represents an array class then the
 904      * {@code Class} object representing the {@code Object} class is
 905      * returned.
 906      *
 907      * @return the direct superclass of the class represented by this object
 908      */
 909     @HotSpotIntrinsicCandidate
 910     public native Class<? super T> getSuperclass();
 911 
 912 
 913     /**
 914      * Returns the {@code Type} representing the direct superclass of
 915      * the entity (class, interface, primitive type or void) represented by
 916      * this {@code Class}.
 917      *
 918      * <p>If the superclass is a parameterized type, the {@code Type}
 919      * object returned must accurately reflect the actual type
 920      * arguments used in the source code. The parameterized type
 921      * representing the superclass is created if it had not been
 922      * created before. See the declaration of {@link
 923      * java.lang.reflect.ParameterizedType ParameterizedType} for the
 924      * semantics of the creation process for parameterized types.  If
 925      * this {@code Class} represents either the {@code Object}
 926      * class, an interface, a primitive type, or void, then null is
 927      * returned.  If this object represents an array class then the
 928      * {@code Class} object representing the {@code Object} class is
 929      * returned.
 930      *
 931      * @throws java.lang.reflect.GenericSignatureFormatError if the generic
 932      *     class signature does not conform to the format specified in
 933      *     <cite>The Java&trade; Virtual Machine Specification</cite>
 934      * @throws TypeNotPresentException if the generic superclass
 935      *     refers to a non-existent type declaration
 936      * @throws java.lang.reflect.MalformedParameterizedTypeException if the
 937      *     generic superclass refers to a parameterized type that cannot be
 938      *     instantiated  for any reason
 939      * @return the direct superclass of the class represented by this object
 940      * @since 1.5


1080         } else {
1081             Class<?>[] interfaces = rd.interfaces;
1082             if (interfaces == null) {
1083                 interfaces = getInterfaces0();
1084                 rd.interfaces = interfaces;
1085             }
1086             // defensively copy if requested
1087             return cloneArray ? interfaces.clone() : interfaces;
1088         }
1089     }
1090 
1091     private native Class<?>[] getInterfaces0();
1092 
1093     /**
1094      * Returns the {@code Type}s representing the interfaces
1095      * directly implemented by the class or interface represented by
1096      * this object.
1097      *
1098      * <p>If a superinterface is a parameterized type, the
1099      * {@code Type} object returned for it must accurately reflect
1100      * the actual type arguments used in the source code. The
1101      * parameterized type representing each superinterface is created
1102      * if it had not been created before. See the declaration of
1103      * {@link java.lang.reflect.ParameterizedType ParameterizedType}
1104      * for the semantics of the creation process for parameterized
1105      * types.
1106      *
1107      * <p>If this object represents a class, the return value is an array
1108      * containing objects representing all interfaces directly implemented by
1109      * the class.  The order of the interface objects in the array corresponds
1110      * to the order of the interface names in the {@code implements} clause of
1111      * the declaration of the class represented by this object.
1112      *
1113      * <p>If this object represents an interface, the array contains objects
1114      * representing all interfaces directly extended by the interface.  The
1115      * order of the interface objects in the array corresponds to the order of
1116      * the interface names in the {@code extends} clause of the declaration of
1117      * the interface represented by this object.
1118      *
1119      * <p>If this object represents a class or interface that implements no
1120      * interfaces, the method returns an array of length 0.




 900      * entity (class, interface, primitive type or void) represented by
 901      * this {@code Class}.  If this {@code Class} represents either the
 902      * {@code Object} class, an interface, a primitive type, or void, then
 903      * null is returned.  If this object represents an array class then the
 904      * {@code Class} object representing the {@code Object} class is
 905      * returned.
 906      *
 907      * @return the direct superclass of the class represented by this object
 908      */
 909     @HotSpotIntrinsicCandidate
 910     public native Class<? super T> getSuperclass();
 911 
 912 
 913     /**
 914      * Returns the {@code Type} representing the direct superclass of
 915      * the entity (class, interface, primitive type or void) represented by
 916      * this {@code Class}.
 917      *
 918      * <p>If the superclass is a parameterized type, the {@code Type}
 919      * object returned must accurately reflect the actual type
 920      * parameters used in the source code. The parameterized type
 921      * representing the superclass is created if it had not been
 922      * created before. See the declaration of {@link
 923      * java.lang.reflect.ParameterizedType ParameterizedType} for the
 924      * semantics of the creation process for parameterized types.  If
 925      * this {@code Class} represents either the {@code Object}
 926      * class, an interface, a primitive type, or void, then null is
 927      * returned.  If this object represents an array class then the
 928      * {@code Class} object representing the {@code Object} class is
 929      * returned.
 930      *
 931      * @throws java.lang.reflect.GenericSignatureFormatError if the generic
 932      *     class signature does not conform to the format specified in
 933      *     <cite>The Java&trade; Virtual Machine Specification</cite>
 934      * @throws TypeNotPresentException if the generic superclass
 935      *     refers to a non-existent type declaration
 936      * @throws java.lang.reflect.MalformedParameterizedTypeException if the
 937      *     generic superclass refers to a parameterized type that cannot be
 938      *     instantiated  for any reason
 939      * @return the direct superclass of the class represented by this object
 940      * @since 1.5


1080         } else {
1081             Class<?>[] interfaces = rd.interfaces;
1082             if (interfaces == null) {
1083                 interfaces = getInterfaces0();
1084                 rd.interfaces = interfaces;
1085             }
1086             // defensively copy if requested
1087             return cloneArray ? interfaces.clone() : interfaces;
1088         }
1089     }
1090 
1091     private native Class<?>[] getInterfaces0();
1092 
1093     /**
1094      * Returns the {@code Type}s representing the interfaces
1095      * directly implemented by the class or interface represented by
1096      * this object.
1097      *
1098      * <p>If a superinterface is a parameterized type, the
1099      * {@code Type} object returned for it must accurately reflect
1100      * the actual type parameters used in the source code. The
1101      * parameterized type representing each superinterface is created
1102      * if it had not been created before. See the declaration of
1103      * {@link java.lang.reflect.ParameterizedType ParameterizedType}
1104      * for the semantics of the creation process for parameterized
1105      * types.
1106      *
1107      * <p>If this object represents a class, the return value is an array
1108      * containing objects representing all interfaces directly implemented by
1109      * the class.  The order of the interface objects in the array corresponds
1110      * to the order of the interface names in the {@code implements} clause of
1111      * the declaration of the class represented by this object.
1112      *
1113      * <p>If this object represents an interface, the array contains objects
1114      * representing all interfaces directly extended by the interface.  The
1115      * order of the interface objects in the array corresponds to the order of
1116      * the interface names in the {@code extends} clause of the declaration of
1117      * the interface represented by this object.
1118      *
1119      * <p>If this object represents a class or interface that implements no
1120      * interfaces, the method returns an array of length 0.


< prev index next >