Package org.apache.bcel
Class Repository
java.lang.Object
org.apache.bcel.Repository
The 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:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic JavaClassAdds clazz to repository if there isn't an equally named class already in there.static voidClears the repository.static JavaClass[]getInterfaces(String class_name) static JavaClass[]getInterfaces(JavaClass clazz) static Repositorystatic JavaClass[]getSuperClasses(String class_name) static JavaClass[]getSuperClasses(JavaClass clazz) static booleanimplementationOf(String clazz, String inter) static booleanimplementationOf(String clazz, JavaClass inter) static booleanimplementationOf(JavaClass clazz, String inter) static booleanimplementationOf(JavaClass clazz, JavaClass inter) static booleaninstanceOf(String clazz, String super_class) static booleaninstanceOf(String clazz, JavaClass super_class) static booleaninstanceOf(JavaClass clazz, String super_class) static booleaninstanceOf(JavaClass clazz, JavaClass super_class) Equivalent to runtime "instanceof" operator.static JavaClasslookupClass(Class<?> clazz) Tries to find class source using the internal repository instance.static JavaClasslookupClass(String class_name) Lookups class somewhere found on your CLASSPATH, or whereever the repository instance looks for it.static ClassPath.ClassFilelookupClassFile(String class_name) static voidremoveClass(String clazz) Removes class with given (fully qualified) name from repository.static voidremoveClass(JavaClass clazz) Removes given class from repository.static voidsetRepository(Repository rep) Sets repository instance to be used for class loading
-
Constructor Details
-
Repository
public Repository()
-
-
Method Details
-
getRepository
- Returns:
- currently used repository instance
-
setRepository
Sets repository instance to be used for class loading -
lookupClass
Lookups class somewhere found on your CLASSPATH, or whereever the repository instance looks for it.- Returns:
- class object for given fully qualified class name
- Throws:
ClassNotFoundException- if the class could not be found or parsed correctly
-
lookupClass
Tries to find class source using the internal repository instance.- Returns:
- JavaClass object for given runtime class
- Throws:
ClassNotFoundException- if the class could not be found or parsed correctly- See Also:
-
lookupClassFile
- 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()Clears the repository. -
addClass
Adds clazz to repository if there isn't an equally named class already in there.- Returns:
- old entry in repository
-
removeClass
Removes class with given (fully qualified) name from repository. -
removeClass
Removes given class from repository. -
getSuperClasses
- Returns:
- list of super classes of clazz in ascending order, i.e., Object is always the last element
- Throws:
ClassNotFoundException- if any of the superclasses can't be found
-
getSuperClasses
- Returns:
- list of super classes of clazz in ascending order, i.e., Object is always the last element.
- Throws:
ClassNotFoundException- if the named class or any of its superclasses can't be found
-
getInterfaces
- 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:
ClassNotFoundException- if any of the class's superclasses or superinterfaces can't be found
-
getInterfaces
- Returns:
- all interfaces implemented by class and its super classes and the interfaces that extend those interfaces, and so on
- Throws:
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(JavaClass clazz, JavaClass super_class) throws ClassNotFoundException Equivalent to runtime "instanceof" operator.- Returns:
- true, if clazz is an instance of super_class
- Throws:
ClassNotFoundException- if any superclasses or superinterfaces of clazz can't be found
-
instanceOf
- Returns:
- true, if clazz is an instance of super_class
- Throws:
ClassNotFoundException- if either clazz or super_class can't be found
-
instanceOf
- Returns:
- true, if clazz is an instance of super_class
- Throws:
ClassNotFoundException- if super_class can't be found
-
instanceOf
- Returns:
- true, if clazz is an instance of super_class
- Throws:
ClassNotFoundException- if clazz can't be found
-
implementationOf
public static boolean implementationOf(JavaClass clazz, JavaClass inter) throws ClassNotFoundException - Returns:
- true, if clazz is an implementation of interface inter
- Throws:
ClassNotFoundException- if any superclasses or superinterfaces of clazz can't be found
-
implementationOf
- Returns:
- true, if clazz is an implementation of interface inter
- Throws:
ClassNotFoundException- if clazz, inter, or any superclasses or superinterfaces of clazz can't be found
-
implementationOf
- Returns:
- true, if clazz is an implementation of interface inter
- Throws:
ClassNotFoundException- if inter or any superclasses or superinterfaces of clazz can't be found
-
implementationOf
- Returns:
- true, if clazz is an implementation of interface inter
- Throws:
ClassNotFoundException- if clazz or any superclasses or superinterfaces of clazz can't be found
-