- java.lang.Object
-
- org.apache.bcel.Repository
-
public abstract class Repository extends java.lang.ObjectThe repository maintains informations about class interdependencies, e.g., whether a class is a sub-class of another. Delegates actual class loading to SyntheticRepository with current class path by default.- See Also:
Repository,SyntheticRepository
-
-
Constructor Summary
Constructors Constructor Description Repository()
-
Method Summary
Modifier and Type Method Description static org.apache.bcel.classfile.JavaClassaddClass(org.apache.bcel.classfile.JavaClass clazz)Add clazz to repository if there isn't an equally named class already in there.static voidclearCache()Clear the repository.static org.apache.bcel.classfile.JavaClass[]getInterfaces(java.lang.String class_name)static org.apache.bcel.classfile.JavaClass[]getInterfaces(org.apache.bcel.classfile.JavaClass clazz)static org.apache.bcel.util.RepositorygetRepository()static org.apache.bcel.classfile.JavaClass[]getSuperClasses(java.lang.String class_name)static org.apache.bcel.classfile.JavaClass[]getSuperClasses(org.apache.bcel.classfile.JavaClass clazz)static booleanimplementationOf(java.lang.String clazz, java.lang.String inter)static booleanimplementationOf(java.lang.String clazz, org.apache.bcel.classfile.JavaClass inter)static booleanimplementationOf(org.apache.bcel.classfile.JavaClass clazz, java.lang.String inter)static booleanimplementationOf(org.apache.bcel.classfile.JavaClass clazz, org.apache.bcel.classfile.JavaClass inter)static booleaninstanceOf(java.lang.String clazz, java.lang.String super_class)static booleaninstanceOf(java.lang.String clazz, org.apache.bcel.classfile.JavaClass super_class)static booleaninstanceOf(org.apache.bcel.classfile.JavaClass clazz, java.lang.String super_class)static booleaninstanceOf(org.apache.bcel.classfile.JavaClass clazz, org.apache.bcel.classfile.JavaClass super_class)Equivalent to runtime "instanceof" operator.static org.apache.bcel.classfile.JavaClasslookupClass(java.lang.Class<?> clazz)Try to find class source using the internal repository instance.static org.apache.bcel.classfile.JavaClasslookupClass(java.lang.String class_name)Lookup class somewhere found on your CLASSPATH, or whereever the repository instance looks for it.static org.apache.bcel.util.ClassPath.ClassFilelookupClassFile(java.lang.String class_name)static voidremoveClass(java.lang.String clazz)Remove class with given (fully qualified) name from repository.static voidremoveClass(org.apache.bcel.classfile.JavaClass clazz)Remove given class from repository.static voidsetRepository(org.apache.bcel.util.Repository rep)Set repository instance to be used for class loading
-
-
-
Method Detail
-
getRepository
public static org.apache.bcel.util.Repository getRepository()
- Returns:
- currently used repository instance
-
setRepository
public static void setRepository(org.apache.bcel.util.Repository rep)
Set repository instance to be used for class loading
-
lookupClass
public static org.apache.bcel.classfile.JavaClass lookupClass(java.lang.String class_name) throws java.lang.ClassNotFoundExceptionLookup class somewhere found on your CLASSPATH, or whereever the repository instance looks for it.- Returns:
- class object for given fully qualified class name
- Throws:
java.lang.ClassNotFoundException- if the class could not be found or parsed correctly
-
lookupClass
public static org.apache.bcel.classfile.JavaClass lookupClass(java.lang.Class<?> clazz) throws java.lang.ClassNotFoundExceptionTry to find class source using the internal repository instance.- Returns:
- JavaClass object for given runtime class
- Throws:
java.lang.ClassNotFoundException- if the class could not be found or parsed correctly- See Also:
Class
-
lookupClassFile
public static org.apache.bcel.util.ClassPath.ClassFile lookupClassFile(java.lang.String class_name)
- Returns:
- class file object for given Java class by looking on the system class path; returns null if the class file can't be found
-
clearCache
public static void clearCache()
Clear the repository.
-
addClass
public static org.apache.bcel.classfile.JavaClass addClass(org.apache.bcel.classfile.JavaClass clazz)
Add clazz to repository if there isn't an equally named class already in there.- Returns:
- old entry in repository
-
removeClass
public static void removeClass(java.lang.String clazz)
Remove class with given (fully qualified) name from repository.
-
removeClass
public static void removeClass(org.apache.bcel.classfile.JavaClass clazz)
Remove given class from repository.
-
getSuperClasses
public static org.apache.bcel.classfile.JavaClass[] getSuperClasses(org.apache.bcel.classfile.JavaClass clazz) throws java.lang.ClassNotFoundException- Returns:
- list of super classes of clazz in ascending order, i.e., Object is always the last element
- Throws:
java.lang.ClassNotFoundException- if any of the superclasses can't be found
-
getSuperClasses
public static org.apache.bcel.classfile.JavaClass[] getSuperClasses(java.lang.String class_name) throws java.lang.ClassNotFoundException- Returns:
- list of super classes of clazz in ascending order, i.e., Object is always the last element.
- Throws:
java.lang.ClassNotFoundException- if the named class or any of its superclasses can't be found
-
getInterfaces
public static org.apache.bcel.classfile.JavaClass[] getInterfaces(org.apache.bcel.classfile.JavaClass clazz) throws java.lang.ClassNotFoundException- Returns:
- all interfaces implemented by class and its super classes and the interfaces that those interfaces extend, and so on. (Some people call this a transitive hull).
- Throws:
java.lang.ClassNotFoundException- if any of the class's superclasses or superinterfaces can't be found
-
getInterfaces
public static org.apache.bcel.classfile.JavaClass[] getInterfaces(java.lang.String class_name) throws java.lang.ClassNotFoundException- Returns:
- all interfaces implemented by class and its super classes and the interfaces that extend those interfaces, and so on
- Throws:
java.lang.ClassNotFoundException- if the named class can't be found, or if any of its superclasses or superinterfaces can't be found
-
instanceOf
public static boolean instanceOf(org.apache.bcel.classfile.JavaClass clazz, org.apache.bcel.classfile.JavaClass super_class) throws java.lang.ClassNotFoundExceptionEquivalent to runtime "instanceof" operator.- Returns:
- true, if clazz is an instance of super_class
- Throws:
java.lang.ClassNotFoundException- if any superclasses or superinterfaces of clazz can't be found
-
instanceOf
public static boolean instanceOf(java.lang.String clazz, java.lang.String super_class) throws java.lang.ClassNotFoundException- Returns:
- true, if clazz is an instance of super_class
- Throws:
java.lang.ClassNotFoundException- if either clazz or super_class can't be found
-
instanceOf
public static boolean instanceOf(org.apache.bcel.classfile.JavaClass clazz, java.lang.String super_class) throws java.lang.ClassNotFoundException- Returns:
- true, if clazz is an instance of super_class
- Throws:
java.lang.ClassNotFoundException- if super_class can't be found
-
instanceOf
public static boolean instanceOf(java.lang.String clazz, org.apache.bcel.classfile.JavaClass super_class) throws java.lang.ClassNotFoundException- Returns:
- true, if clazz is an instance of super_class
- Throws:
java.lang.ClassNotFoundException- if clazz can't be found
-
implementationOf
public static boolean implementationOf(org.apache.bcel.classfile.JavaClass clazz, org.apache.bcel.classfile.JavaClass inter) throws java.lang.ClassNotFoundException- Returns:
- true, if clazz is an implementation of interface inter
- Throws:
java.lang.ClassNotFoundException- if any superclasses or superinterfaces of clazz can't be found
-
implementationOf
public static boolean implementationOf(java.lang.String clazz, java.lang.String inter) throws java.lang.ClassNotFoundException- Returns:
- true, if clazz is an implementation of interface inter
- Throws:
java.lang.ClassNotFoundException- if clazz, inter, or any superclasses or superinterfaces of clazz can't be found
-
implementationOf
public static boolean implementationOf(org.apache.bcel.classfile.JavaClass clazz, java.lang.String inter) throws java.lang.ClassNotFoundException- Returns:
- true, if clazz is an implementation of interface inter
- Throws:
java.lang.ClassNotFoundException- if inter or any superclasses or superinterfaces of clazz can't be found
-
implementationOf
public static boolean implementationOf(java.lang.String clazz, org.apache.bcel.classfile.JavaClass inter) throws java.lang.ClassNotFoundException- Returns:
- true, if clazz is an implementation of interface inter
- Throws:
java.lang.ClassNotFoundException- if clazz or any superclasses or superinterfaces of clazz can't be found
-
-