use of sun.reflect.generics.visitor.Reifier in project jdk8u_jdk by JetBrains.
the class ConstructorRepository method getParameterTypes.
// public API
/*
* When queried for a particular piece of type information, the
* general pattern is to consult the corresponding cached value.
* If the corresponding field is non-null, it is returned.
* If not, it is created lazily. This is done by selecting the appropriate
* part of the tree and transforming it into a reflective object
* using a visitor.
* a visitor, which is created by feeding it the factory
* with which the repository was created.
*/
public Type[] getParameterTypes() {
if (paramTypes == null) {
// lazily initialize parameter types
// first, extract parameter type subtree(s) from AST
TypeSignature[] pts = getTree().getParameterTypes();
// create array to store reified subtree(s)
Type[] ps = new Type[pts.length];
// reify all subtrees
for (int i = 0; i < pts.length; i++) {
// obtain visitor
Reifier r = getReifier();
// reify subtree
pts[i].accept(r);
// extract result from visitor and store it
ps[i] = r.getResult();
}
// cache overall result
paramTypes = ps;
}
// return cached result
return paramTypes.clone();
}
use of sun.reflect.generics.visitor.Reifier in project jdk8u_jdk by JetBrains.
the class FieldRepository method getGenericType.
// public API
/*
* When queried for a particular piece of type information, the
* general pattern is to consult the corresponding cached value.
* If the corresponding field is non-null, it is returned.
* If not, it is created lazily. This is done by selecting the appropriate
* part of the tree and transforming it into a reflective object
* using a visitor.
* a visitor, which is created by feeding it the factory
* with which the repository was created.
*/
public Type getGenericType() {
if (genericType == null) {
// lazily initialize generic type
// obtain visitor
Reifier r = getReifier();
// reify subtree
getTree().accept(r);
// extract result from visitor and cache it
genericType = r.getResult();
}
// return cached result
return genericType;
}
use of sun.reflect.generics.visitor.Reifier in project jdk8u_jdk by JetBrains.
the class GenericDeclRepository method getTypeParameters.
// public API
/*
* When queried for a particular piece of type information, the
* general pattern is to consult the corresponding cached value.
* If the corresponding field is non-null, it is returned.
* If not, it is created lazily. This is done by selecting the appropriate
* part of the tree and transforming it into a reflective object
* using a visitor, which is created by feeding it the factory
* with which the repository was created.
*/
/**
* Return the formal type parameters of this generic declaration.
* @return the formal type parameters of this generic declaration
*/
public TypeVariable<?>[] getTypeParameters() {
TypeVariable<?>[] typeParams = this.typeParams;
if (typeParams == null) {
// lazily initialize type parameters
// first, extract type parameter subtree(s) from AST
FormalTypeParameter[] ftps = getTree().getFormalTypeParameters();
// create array to store reified subtree(s)
typeParams = new TypeVariable<?>[ftps.length];
// reify all subtrees
for (int i = 0; i < ftps.length; i++) {
// obtain visitor
Reifier r = getReifier();
// reify subtree
ftps[i].accept(r);
// extract result from visitor and store it
typeParams[i] = (TypeVariable<?>) r.getResult();
}
// cache overall result
this.typeParams = typeParams;
}
// return cached result
return typeParams.clone();
}
use of sun.reflect.generics.visitor.Reifier 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();
}
use of sun.reflect.generics.visitor.Reifier 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();
}
Aggregations