sun.reflect.generics.repository.ClassRepository Java Examples

The following examples show how to use sun.reflect.generics.repository.ClassRepository. 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 6 votes vote down vote up
/**
 * 获取Class的泛型信息(Get generic information about class)
 *
 * @param javaClass Class
 * @return TypeArgument[]
 */
public static Map<String, TypeArgument[]> getClassGenericInfo(Class<?> javaClass)
{
    try {
        Map<String, TypeArgument[]> typeSignatureMap = new LinkedHashMap<>();
        ClassRepository classRepository = getReflectMethod(Class.class.getDeclaredMethod("getGenericInfo"), javaClass);

        if (classRepository == null) {
            return Collections.emptyMap();
        }
        //-----2
        ClassSignature tree = getReflectMethod(AbstractRepository.class.getDeclaredMethod("getTree"), classRepository);
        //FormalTypeParameter[] formalTypeParameters = tree.getFormalTypeParameters();  //type 个数  === type[]
        SimpleClassTypeSignature typeSignature = tree.getSuperclass().getPath().get(0);
        typeSignatureMap.put(typeSignature.getName(), typeSignature.getTypeArguments());

        for (ClassTypeSignature it : tree.getSuperInterfaces()) {
            typeSignature = it.getPath().get(0);
            typeSignatureMap.put(typeSignature.getName(), typeSignature.getTypeArguments());
        }
        return typeSignatureMap;
    }
    catch (Exception e) {
        throw throwsException(e);
    }
}
 
Example #2
Source File: Class.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
private ClassRepository getGenericInfo() {
    ClassRepository genericInfo = this.genericInfo;
    if (genericInfo == null) {
        String signature = getGenericSignature0();
        if (signature == null) {
            genericInfo = ClassRepository.NONE;
        } else {
            genericInfo = ClassRepository.make(signature, getFactory());
        }
        this.genericInfo = genericInfo;
    }
    return (genericInfo != ClassRepository.NONE) ? genericInfo : null;
}
 
Example #3
Source File: Class.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
private ClassRepository getGenericInfo() {
    ClassRepository genericInfo = this.genericInfo;
    if (genericInfo == null) {
        String signature = getGenericSignature0();
        if (signature == null) {
            genericInfo = ClassRepository.NONE;
        } else {
            genericInfo = ClassRepository.make(signature, getFactory());
        }
        this.genericInfo = genericInfo;
    }
    return (genericInfo != ClassRepository.NONE) ? genericInfo : null;
}
 
Example #4
Source File: Class.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
private ClassRepository getGenericInfo() {
    ClassRepository genericInfo = this.genericInfo;
    if (genericInfo == null) {
        String signature = getGenericSignature0();
        if (signature == null) {
            genericInfo = ClassRepository.NONE;
        } else {
            genericInfo = ClassRepository.make(signature, getFactory());
        }
        this.genericInfo = genericInfo;
    }
    return (genericInfo != ClassRepository.NONE) ? genericInfo : null;
}
 
Example #5
Source File: Class.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
private ClassRepository getGenericInfo() {
    ClassRepository genericInfo = this.genericInfo;
    if (genericInfo == null) {
        String signature = getGenericSignature0();
        if (signature == null) {
            genericInfo = ClassRepository.NONE;
        } else {
            genericInfo = ClassRepository.make(signature, getFactory());
        }
        this.genericInfo = genericInfo;
    }
    return (genericInfo != ClassRepository.NONE) ? genericInfo : null;
}
 
Example #6
Source File: Class.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
private ClassRepository getGenericInfo() {
    ClassRepository genericInfo = this.genericInfo;
    if (genericInfo == null) {
        String signature = getGenericSignature0();
        if (signature == null) {
            genericInfo = ClassRepository.NONE;
        } else {
            genericInfo = ClassRepository.make(signature, getFactory());
        }
        this.genericInfo = genericInfo;
    }
    return (genericInfo != ClassRepository.NONE) ? genericInfo : null;
}
 
Example #7
Source File: Class.java    From jdk-1.7-annotated with Apache License 2.0 5 votes vote down vote up
private ClassRepository getGenericInfo() {
    // lazily initialize repository if necessary
    if (genericInfo == null) {
        // create and cache generic info repository
        genericInfo = ClassRepository.make(getGenericSignature(),
                                           getFactory());
    }
    return genericInfo; //return cached repository
}
 
Example #8
Source File: Class.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
private ClassRepository getGenericInfo() {
    ClassRepository genericInfo = this.genericInfo;
    if (genericInfo == null) {
        String signature = getGenericSignature0();
        if (signature == null) {
            genericInfo = ClassRepository.NONE;
        } else {
            genericInfo = ClassRepository.make(signature, getFactory());
        }
        this.genericInfo = genericInfo;
    }
    return (genericInfo != ClassRepository.NONE) ? genericInfo : null;
}
 
Example #9
Source File: Class.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
private ClassRepository getGenericInfo() {
    ClassRepository genericInfo = this.genericInfo;
    if (genericInfo == null) {
        String signature = getGenericSignature0();
        if (signature == null) {
            genericInfo = ClassRepository.NONE;
        } else {
            genericInfo = ClassRepository.make(signature, getFactory());
        }
        this.genericInfo = genericInfo;
    }
    return (genericInfo != ClassRepository.NONE) ? genericInfo : null;
}
 
Example #10
Source File: Class.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
private ClassRepository getGenericInfo() {
    ClassRepository genericInfo = this.genericInfo;
    if (genericInfo == null) {
        String signature = getGenericSignature0();
        if (signature == null) {
            genericInfo = ClassRepository.NONE;
        } else {
            genericInfo = ClassRepository.make(signature, getFactory());
        }
        this.genericInfo = genericInfo;
    }
    return (genericInfo != ClassRepository.NONE) ? genericInfo : null;
}
 
Example #11
Source File: Class.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
private ClassRepository getGenericInfo() {
    ClassRepository genericInfo = this.genericInfo;
    if (genericInfo == null) {
        String signature = getGenericSignature0();
        if (signature == null) {
            genericInfo = ClassRepository.NONE;
        } else {
            genericInfo = ClassRepository.make(signature, getFactory());
        }
        this.genericInfo = genericInfo;
    }
    return (genericInfo != ClassRepository.NONE) ? genericInfo : null;
}
 
Example #12
Source File: Class.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
private ClassRepository getGenericInfo() {
    ClassRepository genericInfo = this.genericInfo;
    if (genericInfo == null) {
        String signature = getGenericSignature0();
        if (signature == null) {
            genericInfo = ClassRepository.NONE;
        } else {
            genericInfo = ClassRepository.make(signature, getFactory());
        }
        this.genericInfo = genericInfo;
    }
    return (genericInfo != ClassRepository.NONE) ? genericInfo : null;
}
 
Example #13
Source File: Class.java    From Java8CN with Apache License 2.0 5 votes vote down vote up
private ClassRepository getGenericInfo() {
    ClassRepository genericInfo = this.genericInfo;
    if (genericInfo == null) {
        String signature = getGenericSignature0();
        if (signature == null) {
            genericInfo = ClassRepository.NONE;
        } else {
            genericInfo = ClassRepository.make(signature, getFactory());
        }
        this.genericInfo = genericInfo;
    }
    return (genericInfo != ClassRepository.NONE) ? genericInfo : null;
}
 
Example #14
Source File: Class.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
private ClassRepository getGenericInfo() {
    ClassRepository genericInfo = this.genericInfo;
    if (genericInfo == null) {
        String signature = getGenericSignature0();
        if (signature == null) {
            genericInfo = ClassRepository.NONE;
        } else {
            genericInfo = ClassRepository.make(signature, getFactory());
        }
        this.genericInfo = genericInfo;
    }
    return (genericInfo != ClassRepository.NONE) ? genericInfo : null;
}
 
Example #15
Source File: Class.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
private ClassRepository getGenericInfo() {
    ClassRepository genericInfo = this.genericInfo;
    if (genericInfo == null) {
        String signature = getGenericSignature0();
        if (signature == null) {
            genericInfo = ClassRepository.NONE;
        } else {
            genericInfo = ClassRepository.make(signature, getFactory());
        }
        this.genericInfo = genericInfo;
    }
    return (genericInfo != ClassRepository.NONE) ? genericInfo : null;
}
 
Example #16
Source File: Class.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
private ClassRepository getGenericInfo() {
    ClassRepository genericInfo = this.genericInfo;
    if (genericInfo == null) {
        String signature = getGenericSignature0();
        if (signature == null) {
            genericInfo = ClassRepository.NONE;
        } else {
            genericInfo = ClassRepository.make(signature, getFactory());
        }
        this.genericInfo = genericInfo;
    }
    return (genericInfo != ClassRepository.NONE) ? genericInfo : null;
}
 
Example #17
Source File: Class.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private ClassRepository getGenericInfo() {
    ClassRepository genericInfo = this.genericInfo;
    if (genericInfo == null) {
        String signature = getGenericSignature0();
        if (signature == null) {
            genericInfo = ClassRepository.NONE;
        } else {
            genericInfo = ClassRepository.make(signature, getFactory());
        }
        this.genericInfo = genericInfo;
    }
    return (genericInfo != ClassRepository.NONE) ? genericInfo : null;
}
 
Example #18
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 #19
Source File: Class.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
private ClassRepository getGenericInfo() {
    ClassRepository genericInfo = this.genericInfo;
    if (genericInfo == null) {
        String signature = getGenericSignature0();
        if (signature == null) {
            genericInfo = ClassRepository.NONE;
        } else {
            genericInfo = ClassRepository.make(signature, getFactory());
        }
        this.genericInfo = genericInfo;
    }
    return (genericInfo != ClassRepository.NONE) ? genericInfo : null;
}
 
Example #20
Source File: Class.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
private ClassRepository getGenericInfo() {
    ClassRepository genericInfo = this.genericInfo;
    if (genericInfo == null) {
        String signature = getGenericSignature0();
        if (signature == null) {
            genericInfo = ClassRepository.NONE;
        } else {
            genericInfo = ClassRepository.make(signature, getFactory());
        }
        this.genericInfo = genericInfo;
    }
    return (genericInfo != ClassRepository.NONE) ? genericInfo : null;
}
 
Example #21
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 #22
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 #23
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 #24
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 #25
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 #26
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 #27
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 #28
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 #29
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 #30
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();
}