Methods Summary |
---|
public static com.sun.org.apache.bcel.internal.classfile.JavaClass | addClass(com.sun.org.apache.bcel.internal.classfile.JavaClass clazz)Add clazz to repository if there isn't an equally named class already in there.
String name = clazz.getClassName();
JavaClass cl = (JavaClass)classes.get(name);
if(cl == null)
classes.put(name, cl = clazz);
return cl;
|
public static void | clearCache()Clear the repository.
classes = new HashMap();
OBJECT = lookupClass("java.lang.Object");
if(OBJECT == null)
System.err.println("Warning: java.lang.Object not found on CLASSPATH!");
else
classes.put("java.lang.Object", OBJECT);
|
public static com.sun.org.apache.bcel.internal.classfile.JavaClass[] | getInterfaces(com.sun.org.apache.bcel.internal.classfile.JavaClass clazz)
ClassVector vec = new ClassVector();
ClassQueue queue = new ClassQueue();
queue.enqueue(clazz);
while(!queue.empty()) {
clazz = queue.dequeue();
String s = clazz.getSuperclassName();
String[] interfaces = clazz.getInterfaceNames();
if(clazz.isInterface())
vec.addElement(clazz);
else if(!s.equals("java.lang.Object"))
queue.enqueue(lookupClass(s));
for(int i=0; i < interfaces.length; i++)
queue.enqueue(lookupClass(interfaces[i]));
}
return vec.toArray();
|
public static com.sun.org.apache.bcel.internal.classfile.JavaClass[] | getInterfaces(java.lang.String class_name)
return getInterfaces(lookupClass(class_name));
|
private static final com.sun.org.apache.bcel.internal.classfile.JavaClass | getSuperClass(com.sun.org.apache.bcel.internal.classfile.JavaClass clazz)
if(clazz == OBJECT)
return null;
return lookupClass(clazz.getSuperclassName());
|
public static com.sun.org.apache.bcel.internal.classfile.JavaClass[] | getSuperClasses(com.sun.org.apache.bcel.internal.classfile.JavaClass clazz)
ClassVector vec = new ClassVector();
for(clazz = getSuperClass(clazz); clazz != null; clazz = getSuperClass(clazz))
vec.addElement(clazz);
return vec.toArray();
|
public static com.sun.org.apache.bcel.internal.classfile.JavaClass[] | getSuperClasses(java.lang.String class_name)
JavaClass jc = lookupClass(class_name);
return (jc == null? null : getSuperClasses(jc));
|
public static boolean | implementationOf(com.sun.org.apache.bcel.internal.classfile.JavaClass clazz, com.sun.org.apache.bcel.internal.classfile.JavaClass inter)
if(clazz == inter)
return true;
JavaClass[] super_interfaces = getInterfaces(clazz);
for(int i=0; i < super_interfaces.length; i++)
if(super_interfaces[i] == inter)
return true;
return false;
|
public static boolean | implementationOf(java.lang.String clazz, java.lang.String inter)
return implementationOf(lookupClass(clazz), lookupClass(inter));
|
public static boolean | implementationOf(com.sun.org.apache.bcel.internal.classfile.JavaClass clazz, java.lang.String inter)
return implementationOf(clazz, lookupClass(inter));
|
public static boolean | implementationOf(java.lang.String clazz, com.sun.org.apache.bcel.internal.classfile.JavaClass inter)
return implementationOf(lookupClass(clazz), inter);
|
public static boolean | instanceOf(com.sun.org.apache.bcel.internal.classfile.JavaClass clazz, com.sun.org.apache.bcel.internal.classfile.JavaClass super_class)
if(clazz == super_class)
return true;
JavaClass[] super_classes = getSuperClasses(clazz);
for(int i=0; i < super_classes.length; i++)
if(super_classes[i] == super_class)
return true;
if(super_class.isInterface())
return implementationOf(clazz, super_class);
return false;
|
public static boolean | instanceOf(java.lang.String clazz, java.lang.String super_class)
return instanceOf(lookupClass(clazz), lookupClass(super_class));
|
public static boolean | instanceOf(com.sun.org.apache.bcel.internal.classfile.JavaClass clazz, java.lang.String super_class)
return instanceOf(clazz, lookupClass(super_class));
|
public static boolean | instanceOf(java.lang.String clazz, com.sun.org.apache.bcel.internal.classfile.JavaClass super_class)
return instanceOf(lookupClass(clazz), super_class);
|
public static com.sun.org.apache.bcel.internal.classfile.JavaClass | lookupClass(java.lang.String class_name) // should be final ...
clearCache();
if(class_name == null || class_name.equals(""))
throw new RuntimeException("Invalid class name");
class_name = class_name.replace('/", '.");
JavaClass clazz = (JavaClass)classes.get(class_name);
if(clazz == null) {
try {
InputStream is = class_path.getInputStream(class_name);
clazz = new ClassParser(is, class_name).parse();
class_name = clazz.getClassName();
} catch(IOException e) { return null; }
classes.put(class_name, clazz);
}
return clazz;
|
public static ClassPath.ClassFile | lookupClassFile(java.lang.String class_name)
try {
return class_path.getClassFile(class_name);
} catch(IOException e) { return null; }
|
public static void | removeClass(java.lang.String clazz)Remove class with given (fully qualifid) name from repository.
classes.remove(clazz);
|
public static void | removeClass(com.sun.org.apache.bcel.internal.classfile.JavaClass clazz)Remove given class from repository.
removeClass(clazz.getClassName());
|