Java Code Examples for sun.reflect.generics.repository.ClassRepository#getSuperclass()

The following examples show how to use sun.reflect.generics.repository.ClassRepository#getSuperclass() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JavaTypes.java    From gadtry with Apache License 2.0 5 votes vote down vote up
public static List<Type> getClassGenericTypes(Class<?> javaClass)
{
    ClassRepository classRepository = noCatch(() -> getReflectMethod(Class.class.getDeclaredMethod("getGenericInfo"),
            javaClass));

    if (classRepository == null) {
        return Collections.emptyList();
    }

    classRepository.getSuperclass();
    return MutableList.asList(classRepository.getSuperclass(), classRepository.getSuperInterfaces());
}
 
Example 2
Source File: Class.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Returns the {@code Type} representing the direct superclass of
 * the entity (class, interface, primitive type or void) represented by
 * this {@code Class}.
 *
 * <p>If the superclass is a parameterized type, the {@code Type}
 * object returned must accurately reflect the actual type
 * parameters used in the source code. The parameterized type
 * representing the superclass is created if it had not been
 * created before. See the declaration of {@link
 * java.lang.reflect.ParameterizedType ParameterizedType} for the
 * semantics of the creation process for parameterized types.  If
 * this {@code Class} represents either the {@code Object}
 * class, an interface, a primitive type, or void, then null is
 * returned.  If this object represents an array class then the
 * {@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
 *     <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
 *     instantiated  for any reason
 * @return the direct superclass of the class represented by this object
 * @since 1.5
 */
public Type getGenericSuperclass() {
    ClassRepository info = getGenericInfo();
    if (info == null) {
        return getSuperclass();
    }

    // Historical irregularity:
    // Generic signature marks interfaces with superclass = Object
    // but this API returns null for interfaces
    if (isInterface()) {
        return null;
    }

    return info.getSuperclass();
}
 
Example 3
Source File: Class.java    From jdk8u-dev-jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Returns the {@code Type} representing the direct superclass of
 * the entity (class, interface, primitive type or void) represented by
 * this {@code Class}.
 *
 * <p>If the superclass is a parameterized type, the {@code Type}
 * object returned must accurately reflect the actual type
 * parameters used in the source code. The parameterized type
 * representing the superclass is created if it had not been
 * created before. See the declaration of {@link
 * java.lang.reflect.ParameterizedType ParameterizedType} for the
 * semantics of the creation process for parameterized types.  If
 * this {@code Class} represents either the {@code Object}
 * class, an interface, a primitive type, or void, then null is
 * returned.  If this object represents an array class then the
 * {@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
 *     <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
 *     instantiated  for any reason
 * @return the superclass of the class represented by this object
 * @since 1.5
 */
public Type getGenericSuperclass() {
    ClassRepository info = getGenericInfo();
    if (info == null) {
        return getSuperclass();
    }

    // Historical irregularity:
    // Generic signature marks interfaces with superclass = Object
    // but this API returns null for interfaces
    if (isInterface()) {
        return null;
    }

    return info.getSuperclass();
}
 
Example 4
Source File: Class.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Returns the {@code Type} representing the direct superclass of
 * the entity (class, interface, primitive type or void) represented by
 * this {@code Class}.
 *
 * <p>If the superclass is a parameterized type, the {@code Type}
 * object returned must accurately reflect the actual type
 * parameters used in the source code. The parameterized type
 * representing the superclass is created if it had not been
 * created before. See the declaration of {@link
 * java.lang.reflect.ParameterizedType ParameterizedType} for the
 * semantics of the creation process for parameterized types.  If
 * this {@code Class} represents either the {@code Object}
 * class, an interface, a primitive type, or void, then null is
 * returned.  If this object represents an array class then the
 * {@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
 *     <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
 *     instantiated  for any reason
 * @return the superclass of the class represented by this object
 * @since 1.5
 */
public Type getGenericSuperclass() {
    ClassRepository info = getGenericInfo();
    if (info == null) {
        return getSuperclass();
    }

    // Historical irregularity:
    // Generic signature marks interfaces with superclass = Object
    // but this API returns null for interfaces
    if (isInterface()) {
        return null;
    }

    return info.getSuperclass();
}
 
Example 5
Source File: Class.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Returns the {@code Type} representing the direct superclass of
 * the entity (class, interface, primitive type or void) represented by
 * this {@code Class}.
 *
 * <p>If the superclass is a parameterized type, the {@code Type}
 * object returned must accurately reflect the actual type
 * parameters used in the source code. The parameterized type
 * representing the superclass is created if it had not been
 * created before. See the declaration of {@link
 * java.lang.reflect.ParameterizedType ParameterizedType} for the
 * semantics of the creation process for parameterized types.  If
 * this {@code Class} represents either the {@code Object}
 * class, an interface, a primitive type, or void, then null is
 * returned.  If this object represents an array class then the
 * {@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
 *     <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
 *     instantiated  for any reason
 * @return the superclass of the class represented by this object
 * @since 1.5
 */
public Type getGenericSuperclass() {
    ClassRepository info = getGenericInfo();
    if (info == null) {
        return getSuperclass();
    }

    // Historical irregularity:
    // Generic signature marks interfaces with superclass = Object
    // but this API returns null for interfaces
    if (isInterface()) {
        return null;
    }

    return info.getSuperclass();
}
 
Example 6
Source File: Class.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Returns the {@code Type} representing the direct superclass of
 * the entity (class, interface, primitive type or void) represented by
 * this {@code Class}.
 *
 * <p>If the superclass is a parameterized type, the {@code Type}
 * object returned must accurately reflect the actual type
 * parameters used in the source code. The parameterized type
 * representing the superclass is created if it had not been
 * created before. See the declaration of {@link
 * java.lang.reflect.ParameterizedType ParameterizedType} for the
 * semantics of the creation process for parameterized types.  If
 * this {@code Class} represents either the {@code Object}
 * class, an interface, a primitive type, or void, then null is
 * returned.  If this object represents an array class then the
 * {@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
 *     <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
 *     instantiated  for any reason
 * @return the superclass of the class represented by this object
 * @since 1.5
 */
public Type getGenericSuperclass() {
    ClassRepository info = getGenericInfo();
    if (info == null) {
        return getSuperclass();
    }

    // Historical irregularity:
    // Generic signature marks interfaces with superclass = Object
    // but this API returns null for interfaces
    if (isInterface()) {
        return null;
    }

    return info.getSuperclass();
}
 
Example 7
Source File: Class.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Returns the {@code Type} representing the direct superclass of
 * the entity (class, interface, primitive type or void) represented by
 * this {@code Class}.
 *
 * <p>If the superclass is a parameterized type, the {@code Type}
 * object returned must accurately reflect the actual type
 * parameters used in the source code. The parameterized type
 * representing the superclass is created if it had not been
 * created before. See the declaration of {@link
 * java.lang.reflect.ParameterizedType ParameterizedType} for the
 * semantics of the creation process for parameterized types.  If
 * this {@code Class} represents either the {@code Object}
 * class, an interface, a primitive type, or void, then null is
 * returned.  If this object represents an array class then the
 * {@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
 *     <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
 *     instantiated  for any reason
 * @return the superclass of the class represented by this object
 * @since 1.5
 */
public Type getGenericSuperclass() {
    ClassRepository info = getGenericInfo();
    if (info == null) {
        return getSuperclass();
    }

    // Historical irregularity:
    // Generic signature marks interfaces with superclass = Object
    // but this API returns null for interfaces
    if (isInterface()) {
        return null;
    }

    return info.getSuperclass();
}
 
Example 8
Source File: Class.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Returns the {@code Type} representing the direct superclass of
 * the entity (class, interface, primitive type or void) represented by
 * this {@code Class}.
 *
 * <p>If the superclass is a parameterized type, the {@code Type}
 * object returned must accurately reflect the actual type
 * parameters used in the source code. The parameterized type
 * representing the superclass is created if it had not been
 * created before. See the declaration of {@link
 * java.lang.reflect.ParameterizedType ParameterizedType} for the
 * semantics of the creation process for parameterized types.  If
 * this {@code Class} represents either the {@code Object}
 * class, an interface, a primitive type, or void, then null is
 * returned.  If this object represents an array class then the
 * {@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
 *     <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
 *     instantiated  for any reason
 * @return the superclass of the class represented by this object
 * @since 1.5
 */
public Type getGenericSuperclass() {
    ClassRepository info = getGenericInfo();
    if (info == null) {
        return getSuperclass();
    }

    // Historical irregularity:
    // Generic signature marks interfaces with superclass = Object
    // but this API returns null for interfaces
    if (isInterface()) {
        return null;
    }

    return info.getSuperclass();
}
 
Example 9
Source File: Class.java    From Java8CN with Apache License 2.0 4 votes vote down vote up
/**
 * Returns the {@code Type} representing the direct superclass of
 * the entity (class, interface, primitive type or void) represented by
 * this {@code Class}.
 *
 * <p>If the superclass is a parameterized type, the {@code Type}
 * object returned must accurately reflect the actual type
 * parameters used in the source code. The parameterized type
 * representing the superclass is created if it had not been
 * created before. See the declaration of {@link
 * java.lang.reflect.ParameterizedType ParameterizedType} for the
 * semantics of the creation process for parameterized types.  If
 * this {@code Class} represents either the {@code Object}
 * class, an interface, a primitive type, or void, then null is
 * returned.  If this object represents an array class then the
 * {@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
 *     <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
 *     instantiated  for any reason
 * @return the superclass of the class represented by this object
 * @since 1.5
 */
public Type getGenericSuperclass() {
    ClassRepository info = getGenericInfo();
    if (info == null) {
        return getSuperclass();
    }

    // Historical irregularity:
    // Generic signature marks interfaces with superclass = Object
    // but this API returns null for interfaces
    if (isInterface()) {
        return null;
    }

    return info.getSuperclass();
}
 
Example 10
Source File: Class.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Returns the {@code Type} representing the direct superclass of
 * the entity (class, interface, primitive type or void) represented by
 * this {@code Class}.
 *
 * <p>If the superclass is a parameterized type, the {@code Type}
 * object returned must accurately reflect the actual type
 * parameters used in the source code. The parameterized type
 * representing the superclass is created if it had not been
 * created before. See the declaration of {@link
 * java.lang.reflect.ParameterizedType ParameterizedType} for the
 * semantics of the creation process for parameterized types.  If
 * this {@code Class} represents either the {@code Object}
 * class, an interface, a primitive type, or void, then null is
 * returned.  If this object represents an array class then the
 * {@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
 *     <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
 *     instantiated  for any reason
 * @return the superclass of the class represented by this object
 * @since 1.5
 */
public Type getGenericSuperclass() {
    ClassRepository info = getGenericInfo();
    if (info == null) {
        return getSuperclass();
    }

    // Historical irregularity:
    // Generic signature marks interfaces with superclass = Object
    // but this API returns null for interfaces
    if (isInterface()) {
        return null;
    }

    return info.getSuperclass();
}
 
Example 11
Source File: Class.java    From jdk1.8-source-analysis with Apache License 2.0 4 votes vote down vote up
/**
 * Returns the {@code Type} representing the direct superclass of
 * the entity (class, interface, primitive type or void) represented by
 * this {@code Class}.
 *
 * <p>If the superclass is a parameterized type, the {@code Type}
 * object returned must accurately reflect the actual type
 * parameters used in the source code. The parameterized type
 * representing the superclass is created if it had not been
 * created before. See the declaration of {@link
 * java.lang.reflect.ParameterizedType ParameterizedType} for the
 * semantics of the creation process for parameterized types.  If
 * this {@code Class} represents either the {@code Object}
 * class, an interface, a primitive type, or void, then null is
 * returned.  If this object represents an array class then the
 * {@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
 *     <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
 *     instantiated  for any reason
 * @return the superclass of the class represented by this object
 * @since 1.5
 */
public Type getGenericSuperclass() {
    ClassRepository info = getGenericInfo();
    if (info == null) {
        return getSuperclass();
    }

    // Historical irregularity:
    // Generic signature marks interfaces with superclass = Object
    // but this API returns null for interfaces
    if (isInterface()) {
        return null;
    }

    return info.getSuperclass();
}
 
Example 12
Source File: Class.java    From Bytecoder with Apache License 2.0 4 votes vote down vote up
/**
 * Returns the {@code Type} representing the direct superclass of
 * the entity (class, interface, primitive type or void) represented by
 * this {@code Class}.
 *
 * <p>If the superclass is a parameterized type, the {@code Type}
 * object returned must accurately reflect the actual type
 * arguments used in the source code. The parameterized type
 * representing the superclass is created if it had not been
 * created before. See the declaration of {@link
 * java.lang.reflect.ParameterizedType ParameterizedType} for the
 * semantics of the creation process for parameterized types.  If
 * this {@code Class} represents either the {@code Object}
 * class, an interface, a primitive type, or void, then null is
 * returned.  If this object represents an array class then the
 * {@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
 *     <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
 *     instantiated  for any reason
 * @return the direct superclass of the class represented by this object
 * @since 1.5
 */
public Type getGenericSuperclass() {
    ClassRepository info = getGenericInfo();
    if (info == null) {
        return getSuperclass();
    }

    // Historical irregularity:
    // Generic signature marks interfaces with superclass = Object
    // but this API returns null for interfaces
    if (isInterface()) {
        return null;
    }

    return info.getSuperclass();
}
 
Example 13
Source File: Class.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Returns the {@code Type} representing the direct superclass of
 * the entity (class, interface, primitive type or void) represented by
 * this {@code Class}.
 *
 * <p>If the superclass is a parameterized type, the {@code Type}
 * object returned must accurately reflect the actual type
 * parameters used in the source code. The parameterized type
 * representing the superclass is created if it had not been
 * created before. See the declaration of {@link
 * java.lang.reflect.ParameterizedType ParameterizedType} for the
 * semantics of the creation process for parameterized types.  If
 * this {@code Class} represents either the {@code Object}
 * class, an interface, a primitive type, or void, then null is
 * returned.  If this object represents an array class then the
 * {@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
 *     <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
 *     instantiated  for any reason
 * @return the superclass of the class represented by this object
 * @since 1.5
 */
public Type getGenericSuperclass() {
    ClassRepository info = getGenericInfo();
    if (info == null) {
        return getSuperclass();
    }

    // Historical irregularity:
    // Generic signature marks interfaces with superclass = Object
    // but this API returns null for interfaces
    if (isInterface()) {
        return null;
    }

    return info.getSuperclass();
}
 
Example 14
Source File: Class.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Returns the {@code Type} representing the direct superclass of
 * the entity (class, interface, primitive type or void) represented by
 * this {@code Class}.
 *
 * <p>If the superclass is a parameterized type, the {@code Type}
 * object returned must accurately reflect the actual type
 * parameters used in the source code. The parameterized type
 * representing the superclass is created if it had not been
 * created before. See the declaration of {@link
 * java.lang.reflect.ParameterizedType ParameterizedType} for the
 * semantics of the creation process for parameterized types.  If
 * this {@code Class} represents either the {@code Object}
 * class, an interface, a primitive type, or void, then null is
 * returned.  If this object represents an array class then the
 * {@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
 *     <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
 *     instantiated  for any reason
 * @return the superclass of the class represented by this object
 * @since 1.5
 */
public Type getGenericSuperclass() {
    ClassRepository info = getGenericInfo();
    if (info == null) {
        return getSuperclass();
    }

    // Historical irregularity:
    // Generic signature marks interfaces with superclass = Object
    // but this API returns null for interfaces
    if (isInterface()) {
        return null;
    }

    return info.getSuperclass();
}
 
Example 15
Source File: Class.java    From JDKSourceCode1.8 with MIT License 4 votes vote down vote up
/**
 * Returns the {@code Type} representing the direct superclass of
 * the entity (class, interface, primitive type or void) represented by
 * this {@code Class}.
 *
 * <p>If the superclass is a parameterized type, the {@code Type}
 * object returned must accurately reflect the actual type
 * parameters used in the source code. The parameterized type
 * representing the superclass is created if it had not been
 * created before. See the declaration of {@link
 * java.lang.reflect.ParameterizedType ParameterizedType} for the
 * semantics of the creation process for parameterized types.  If
 * this {@code Class} represents either the {@code Object}
 * class, an interface, a primitive type, or void, then null is
 * returned.  If this object represents an array class then the
 * {@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
 *     <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
 *     instantiated  for any reason
 * @return the superclass of the class represented by this object
 * @since 1.5
 */
public Type getGenericSuperclass() {
    ClassRepository info = getGenericInfo();
    if (info == null) {
        return getSuperclass();
    }

    // Historical irregularity:
    // Generic signature marks interfaces with superclass = Object
    // but this API returns null for interfaces
    if (isInterface()) {
        return null;
    }

    return info.getSuperclass();
}
 
Example 16
Source File: Class.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Returns the {@code Type} representing the direct superclass of
 * the entity (class, interface, primitive type or void) represented by
 * this {@code Class}.
 *
 * <p>If the superclass is a parameterized type, the {@code Type}
 * object returned must accurately reflect the actual type
 * parameters used in the source code. The parameterized type
 * representing the superclass is created if it had not been
 * created before. See the declaration of {@link
 * java.lang.reflect.ParameterizedType ParameterizedType} for the
 * semantics of the creation process for parameterized types.  If
 * this {@code Class} represents either the {@code Object}
 * class, an interface, a primitive type, or void, then null is
 * returned.  If this object represents an array class then the
 * {@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
 *     <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
 *     instantiated  for any reason
 * @return the superclass of the class represented by this object
 * @since 1.5
 */
public Type getGenericSuperclass() {
    ClassRepository info = getGenericInfo();
    if (info == null) {
        return getSuperclass();
    }

    // Historical irregularity:
    // Generic signature marks interfaces with superclass = Object
    // but this API returns null for interfaces
    if (isInterface()) {
        return null;
    }

    return info.getSuperclass();
}
 
Example 17
Source File: Class.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Returns the {@code Type} representing the direct superclass of
 * the entity (class, interface, primitive type or void) represented by
 * this {@code Class}.
 *
 * <p>If the superclass is a parameterized type, the {@code Type}
 * object returned must accurately reflect the actual type
 * parameters used in the source code. The parameterized type
 * representing the superclass is created if it had not been
 * created before. See the declaration of {@link
 * java.lang.reflect.ParameterizedType ParameterizedType} for the
 * semantics of the creation process for parameterized types.  If
 * this {@code Class} represents either the {@code Object}
 * class, an interface, a primitive type, or void, then null is
 * returned.  If this object represents an array class then the
 * {@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
 *     <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
 *     instantiated  for any reason
 * @return the superclass of the class represented by this object
 * @since 1.5
 */
public Type getGenericSuperclass() {
    ClassRepository info = getGenericInfo();
    if (info == null) {
        return getSuperclass();
    }

    // Historical irregularity:
    // Generic signature marks interfaces with superclass = Object
    // but this API returns null for interfaces
    if (isInterface()) {
        return null;
    }

    return info.getSuperclass();
}
 
Example 18
Source File: Class.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Returns the {@code Type} representing the direct superclass of
 * the entity (class, interface, primitive type or void) represented by
 * this {@code Class}.
 *
 * <p>If the superclass is a parameterized type, the {@code Type}
 * object returned must accurately reflect the actual type
 * parameters used in the source code. The parameterized type
 * representing the superclass is created if it had not been
 * created before. See the declaration of {@link
 * java.lang.reflect.ParameterizedType ParameterizedType} for the
 * semantics of the creation process for parameterized types.  If
 * this {@code Class} represents either the {@code Object}
 * class, an interface, a primitive type, or void, then null is
 * returned.  If this object represents an array class then the
 * {@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
 *     <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
 *     instantiated  for any reason
 * @return the superclass of the class represented by this object
 * @since 1.5
 */
public Type getGenericSuperclass() {
    ClassRepository info = getGenericInfo();
    if (info == null) {
        return getSuperclass();
    }

    // Historical irregularity:
    // Generic signature marks interfaces with superclass = Object
    // but this API returns null for interfaces
    if (isInterface()) {
        return null;
    }

    return info.getSuperclass();
}