use of sun.reflect.generics.visitor.Reifier 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();
}
Aggregations