Search in sources :

Example 1 with FieldTypeSignature

use of sun.reflect.generics.tree.FieldTypeSignature in project jdk8u_jdk by JetBrains.

the class TypeVariableImpl method getBounds.

/**
     * Returns an array of <tt>Type</tt> objects representing the
     * upper bound(s) of this type variable.  Note that if no upper bound is
     * explicitly declared, the upper bound is <tt>Object</tt>.
     *
     * <p>For each upper bound B:
     * <ul>
     *  <li>if B is a parameterized type or a type variable, it is created,
     *  (see {@link #ParameterizedType} for the details of the creation
     *  process for parameterized types).
     *  <li>Otherwise, B is resolved.
     * </ul>
     *
     * @throws <tt>TypeNotPresentException</tt>  if any of the
     *     bounds refers to a non-existent type declaration
     * @throws <tt>MalformedParameterizedTypeException</tt> if any of the
     *     bounds refer to a parameterized type that cannot be instantiated
     *     for any reason
     * @return an array of Types representing the upper bound(s) of this
     *     type variable
    */
public Type[] getBounds() {
    // lazily initialize bounds if necessary
    if (bounds == null) {
        // get AST
        FieldTypeSignature[] fts = getBoundASTs();
        // allocate result array; note that
        // keeping ts and bounds separate helps with threads
        Type[] ts = new Type[fts.length];
        // iterate over bound trees, reifying each in turn
        for (int j = 0; j < fts.length; j++) {
            Reifier r = getReifier();
            fts[j].accept(r);
            ts[j] = r.getResult();
        }
        // cache result
        bounds = ts;
    // could throw away bound ASTs here; thread safety?
    }
    // return cached bounds
    return bounds.clone();
}
Also used : AnnotationType(sun.reflect.annotation.AnnotationType) AnnotatedType(java.lang.reflect.AnnotatedType) Type(java.lang.reflect.Type) Reifier(sun.reflect.generics.visitor.Reifier) FieldTypeSignature(sun.reflect.generics.tree.FieldTypeSignature)

Example 2 with FieldTypeSignature

use of sun.reflect.generics.tree.FieldTypeSignature in project jdk8u_jdk by JetBrains.

the class WildcardTypeImpl method getUpperBounds.

/**
     * Returns an array of <tt>Type</tt> objects representing the  upper
     * bound(s) of this type variable.  Note that if no upper bound is
     * explicitly declared, the upper bound is <tt>Object</tt>.
     *
     * <p>For each upper bound B :
     * <ul>
     *  <li>if B is a parameterized type or a type variable, it is created,
     *  (see {@link #ParameterizedType} for the details of the creation
     *  process for parameterized types).
     *  <li>Otherwise, B is resolved.
     * </ul>
     *
     * @return an array of Types representing the upper bound(s) of this
     *     type variable
     * @throws <tt>TypeNotPresentException</tt> if any of the
     *     bounds refers to a non-existent type declaration
     * @throws <tt>MalformedParameterizedTypeException</tt> if any of the
     *     bounds refer to a parameterized type that cannot be instantiated
     *     for any reason
     */
public Type[] getUpperBounds() {
    // lazily initialize bounds if necessary
    if (upperBounds == null) {
        // get AST
        FieldTypeSignature[] fts = getUpperBoundASTs();
        // allocate result array; note that
        // keeping ts and bounds separate helps with threads
        Type[] ts = new Type[fts.length];
        // iterate over bound trees, reifying each in turn
        for (int j = 0; j < fts.length; j++) {
            Reifier r = getReifier();
            fts[j].accept(r);
            ts[j] = r.getResult();
        }
        // cache result
        upperBounds = ts;
    // could throw away upper bound ASTs here; thread safety?
    }
    // return cached bounds
    return upperBounds.clone();
}
Also used : Type(java.lang.reflect.Type) WildcardType(java.lang.reflect.WildcardType) Reifier(sun.reflect.generics.visitor.Reifier) FieldTypeSignature(sun.reflect.generics.tree.FieldTypeSignature)

Example 3 with FieldTypeSignature

use of sun.reflect.generics.tree.FieldTypeSignature in project jdk8u_jdk by JetBrains.

the class ConstructorRepository method getExceptionTypes.

public Type[] getExceptionTypes() {
    if (exceptionTypes == null) {
        // lazily initialize exception types
        // first, extract exception type subtree(s) from AST
        FieldTypeSignature[] ets = getTree().getExceptionTypes();
        // create array to store reified subtree(s)
        Type[] es = new Type[ets.length];
        // reify all subtrees
        for (int i = 0; i < ets.length; i++) {
            // obtain visitor
            Reifier r = getReifier();
            // reify subtree
            ets[i].accept(r);
            // extract result from visitor and store it
            es[i] = r.getResult();
        }
        // cache overall result
        exceptionTypes = es;
    }
    // return cached result
    return exceptionTypes.clone();
}
Also used : Type(java.lang.reflect.Type) Reifier(sun.reflect.generics.visitor.Reifier) FieldTypeSignature(sun.reflect.generics.tree.FieldTypeSignature)

Example 4 with FieldTypeSignature

use of sun.reflect.generics.tree.FieldTypeSignature in project jdk8u_jdk by JetBrains.

the class WildcardTypeImpl method getLowerBounds.

/**
     * Returns an array of <tt>Type</tt> objects representing the
     * lower bound(s) of this type variable.  Note that if no lower bound is
     * explicitly declared, the lower bound is the type of <tt>null</tt>.
     * In this case, a zero length array is returned.
     *
     * <p>For each lower bound B :
     * <ul>
     *   <li>if B is a parameterized type or a type variable, it is created,
     *   (see {@link #ParameterizedType} for the details of the creation
     *   process for parameterized types).
     *   <li>Otherwise, B is resolved.
     * </ul>
     *
     * @return an array of Types representing the lower bound(s) of this
     *     type variable
     * @throws <tt>TypeNotPresentException</tt> if any of the
     *     bounds refers to a non-existent type declaration
     * @throws <tt>MalformedParameterizedTypeException</tt> if any of the
     *     bounds refer to a parameterized type that cannot be instantiated
     *     for any reason
     */
public Type[] getLowerBounds() {
    // lazily initialize bounds if necessary
    if (lowerBounds == null) {
        // get AST
        FieldTypeSignature[] fts = getLowerBoundASTs();
        // allocate result array; note that
        // keeping ts and bounds separate helps with threads
        Type[] ts = new Type[fts.length];
        // iterate over bound trees, reifying each in turn
        for (int j = 0; j < fts.length; j++) {
            Reifier r = getReifier();
            fts[j].accept(r);
            ts[j] = r.getResult();
        }
        // cache result
        lowerBounds = ts;
    // could throw away lower bound ASTs here; thread safety?
    }
    // return cached bounds
    return lowerBounds.clone();
}
Also used : Type(java.lang.reflect.Type) WildcardType(java.lang.reflect.WildcardType) Reifier(sun.reflect.generics.visitor.Reifier) FieldTypeSignature(sun.reflect.generics.tree.FieldTypeSignature)

Aggregations

Type (java.lang.reflect.Type)4 FieldTypeSignature (sun.reflect.generics.tree.FieldTypeSignature)4 Reifier (sun.reflect.generics.visitor.Reifier)4 WildcardType (java.lang.reflect.WildcardType)2 AnnotatedType (java.lang.reflect.AnnotatedType)1 AnnotationType (sun.reflect.annotation.AnnotationType)1