use of sun.reflect.generics.visitor.Reifier in project jdk8u_jdk by JetBrains.
the class ClassRepository method getSuperInterfaces.
public Type[] getSuperInterfaces() {
Type[] superInterfaces = this.superInterfaces;
if (superInterfaces == null) {
// lazily initialize super interfaces
// first, extract super interface subtree(s) from AST
TypeTree[] ts = getTree().getSuperInterfaces();
// create array to store reified subtree(s)
superInterfaces = new Type[ts.length];
// reify all subtrees
for (int i = 0; i < ts.length; i++) {
// obtain visitor
Reifier r = getReifier();
// reify subtree
ts[i].accept(r);
// extract result from visitor and store it
superInterfaces[i] = r.getResult();
}
this.superInterfaces = superInterfaces;
}
// return cached result
return superInterfaces.clone();
}
use of sun.reflect.generics.visitor.Reifier in project jdk8u_jdk by JetBrains.
the class MethodRepository method getReturnType.
// public API
public Type getReturnType() {
if (returnType == null) {
// lazily initialize return type
// obtain visitor
Reifier r = getReifier();
// Extract return type subtree from AST and reify
getTree().getReturnType().accept(r);
// extract result from visitor and cache it
returnType = r.getResult();
}
// return cached result
return returnType;
}
use of sun.reflect.generics.visitor.Reifier in project jdk8u_jdk by JetBrains.
the class ClassRepository method getSuperclass.
// 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 getSuperclass() {
Type superclass = this.superclass;
if (superclass == null) {
// lazily initialize superclass
// obtain visitor
Reifier r = getReifier();
// Extract superclass subtree from AST and reify
getTree().getSuperclass().accept(r);
// extract result from visitor and cache it
superclass = r.getResult();
this.superclass = superclass;
}
// return cached result
return superclass;
}
use of sun.reflect.generics.visitor.Reifier 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);
}
use of sun.reflect.generics.visitor.Reifier 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();
}
Aggregations