use of com.jopdesign.common.graphutils.DescendingClassTraverser in project jop by jop-devel.
the class ConstantPoolReferenceFinder method findPoolReferences.
private static Set<Integer> findPoolReferences(MethodInfo methodInfo, Method method) {
ClassInfo classInfo = methodInfo.getClassInfo();
IdFinderVisitor visitor = new IdFinderVisitor(classInfo);
visitor.visitConstantUtf8(method.getNameIndex());
visitor.visitConstantUtf8(method.getSignatureIndex());
DescendingClassTraverser traverser = new DescendingClassTraverser(visitor);
// Code is an attribute, since we visit Method, not MethodGen
traverser.visitAttributes(methodInfo, method.getAttributes());
return visitor.getIds();
}
use of com.jopdesign.common.graphutils.DescendingClassTraverser in project jop by jop-devel.
the class ConstantPoolReferenceFinder method visitPoolReferences.
/**
* Helper method which applies a visitor to all constants given by a set of ids.
* @param classInfo the class containing the constant pool
* @param visitor the visitor to apply
* @param ids a set of ids of pool entries to visit
*/
private static void visitPoolReferences(ClassInfo classInfo, ClassElementVisitor visitor, Set<Integer> ids) {
DescendingClassTraverser traverser = new DescendingClassTraverser(visitor);
ConstantPoolGen cpg = classInfo.getConstantPoolGen();
// iterate over the given pool entries, call the visitor
for (Integer id : ids) {
traverser.visitConstant(classInfo, cpg.getConstant(id));
}
}
use of com.jopdesign.common.graphutils.DescendingClassTraverser in project jop by jop-devel.
the class ConstantPoolReferenceFinder method findPoolReferences.
private static Set<Integer> findPoolReferences(FieldInfo fieldInfo, Field field) {
ClassInfo classInfo = fieldInfo.getClassInfo();
// we do not need to handle invoke sites here specially, since we do not visit code here
IdFinderVisitor visitor = new IdFinderVisitor(classInfo);
visitor.visitConstantUtf8(field.getNameIndex());
visitor.visitConstantUtf8(field.getSignatureIndex());
DescendingClassTraverser traverser = new DescendingClassTraverser(visitor);
traverser.visitAttributes(fieldInfo, field.getAttributes());
return visitor.getIds();
}
use of com.jopdesign.common.graphutils.DescendingClassTraverser in project jop by jop-devel.
the class ConstantPoolReferenceFinder method findPoolReferences.
private static Set<Integer> findPoolReferences(ClassInfo classInfo, JavaClass javaClass) {
// we do not need to handle invoke sites here specially, since we do not visit code here
IdFinderVisitor visitor = new IdFinderVisitor(classInfo);
// now, find *every* used constantpool index in the class, except for methods and fields
visitor.visitConstantClass(javaClass.getClassNameIndex());
visitor.visitConstantClass(javaClass.getSuperclassNameIndex());
for (int index : javaClass.getInterfaceIndices()) {
visitor.visitConstantClass(index);
}
DescendingClassTraverser traverser = new DescendingClassTraverser(visitor);
traverser.visitAttributes(classInfo, javaClass.getAttributes());
return visitor.getIds();
}
use of com.jopdesign.common.graphutils.DescendingClassTraverser in project jop by jop-devel.
the class ConstantPoolReferenceFinder method findReferencedClasses.
/**
* Get a set of all classes referenced by the given class, including superclasses, interfaces and
* references from the code, from parameters and from attributes.
*
* @param classInfo the classInfo to search
* @return a set of all fully qualified class names referenced by this class.
*/
public static Set<String> findReferencedClasses(ClassInfo classInfo) {
final Set<String> names = new HashSet<String>();
ClassNameVisitor visitor = new ClassNameVisitor(names);
new DescendingClassTraverser(visitor).visitClass(classInfo);
return names;
}
Aggregations