use of sun.reflect.generics.tree.TypeSignature 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.tree.TypeSignature in project jdk8u_jdk by JetBrains.
the class AnnotationParser method parseSig.
private static Class<?> parseSig(String sig, Class<?> container) {
if (sig.equals("V"))
return void.class;
SignatureParser parser = SignatureParser.make();
TypeSignature typeSig = parser.parseTypeSig(sig);
GenericsFactory factory = CoreReflectionFactory.make(container, ClassScope.make(container));
Reifier reify = Reifier.make(factory);
typeSig.accept(reify);
Type result = reify.getResult();
return toClass(result);
}
Aggregations