use of org.apache.bcel.classfile.JavaClass in project jop by jop-devel.
the class TransitiveHull method add.
private void add(String class_name) {
class_name = class_name.replace('/', '.');
// }
for (int i = 0; i < excluded.length; ++i) {
if (excluded[i].equals(class_name)) {
return;
}
}
// we ignore array classes
if (class_name.startsWith("[")) {
return;
}
JavaClass clazz;
try {
clazz = Repository.lookupClass(class_name);
} catch (ClassNotFoundException e) {
e.printStackTrace();
throw new Error();
}
if (clazz == null) {
System.out.println("lookupClass(" + class_name + ") failed in TransitiveHull");
System.exit(1);
}
if (clazz != null && _set.add(clazz)) {
_queue.enqueue(clazz);
}
}
use of org.apache.bcel.classfile.JavaClass in project jop by jop-devel.
the class TransitiveHull method main.
public static void main(String[] argv) {
JavaClass java_class;
try {
if (argv.length == 0) {
System.err.println("transitive: No input files specified");
} else {
java_class = Repository.lookupClass(argv[0]);
TransitiveHull hull = new TransitiveHull(java_class);
hull.start();
System.out.println(Arrays.asList(hull.getClassNames()));
}
} catch (Exception e) {
e.printStackTrace();
}
}
use of org.apache.bcel.classfile.JavaClass in project jop by jop-devel.
the class OldAppInfo method iterate.
/**
* Iterate over all classes and run the visitor.
*
* @param v
*/
public void iterate(Visitor v) {
Iterator<? extends OldClassInfo> it = cliMap.values().iterator();
while (it.hasNext()) {
JavaClass clz = it.next().clazz;
new DescendingVisitor(clz, v).visit();
}
}
use of org.apache.bcel.classfile.JavaClass in project jop by jop-devel.
the class OldClassInfo method genClassInfoMap.
/**
* Create ClassInfos and the map from class names to ClassInfo
* @param jc
* @return
*/
Map<String, ? extends OldClassInfo> genClassInfoMap(JavaClass[] jc, OldAppInfo ai) {
Map<String, OldClassInfo> map = new HashMap<String, OldClassInfo>();
for (int i = 0; i < jc.length; ++i) {
OldClassInfo cli = newClassInfo(jc[i], ai);
map.put(cli.clazz.getClassName(), cli);
}
// second iteration over all class infos for additional information setting
CliVisitor v = newCliVisitor(map);
Iterator<? extends OldClassInfo> it = map.values().iterator();
while (it.hasNext()) {
JavaClass clz = it.next().clazz;
new DescendingVisitor(clz, v).visit();
}
return map;
}
use of org.apache.bcel.classfile.JavaClass in project jop by jop-devel.
the class ConstantPoolReferenceFinder method findPoolReferences.
// //////////////////////////////////////////////////////////////
// Find/replace references, member names, Pool entries
// //////////////////////////////////////////////////////////////
public static Set<Integer> findPoolReferences(ClassInfo classInfo, boolean checkMembers) {
JavaClass javaClass = classInfo.compile();
Set<Integer> ids = findPoolReferences(classInfo, javaClass);
if (checkMembers) {
for (Field field : javaClass.getFields()) {
FieldInfo fieldInfo = classInfo.getFieldInfo(field.getName());
ids.addAll(findPoolReferences(fieldInfo, field));
}
for (Method method : javaClass.getMethods()) {
MethodInfo methodInfo = classInfo.getMethodInfo(method.getName() + method.getSignature());
ids.addAll(findPoolReferences(methodInfo, method));
}
}
return ids;
}
Aggregations