public class ClassInfo
extends java.lang.Object
ClassLoader.loadClass(String)
for example, but with BCEL
you have to manually load superclasses).TargetClass | impl. | impl. | ext. Iface1 Iface2 SuperClass1 | ext. |ext. | impl. | impl. Iface3 | Iface4 Iface5 |ext. | | ext. | | | loaded with BCEL ----------- | | | ------------------------ | | | loaded with class loader Iface6 SuperClass2 Iface7 |ext. |impl. |ext. Iface8 Iface9 SuperClass3
Modifier and Type | Field and Description |
---|---|
private java.util.Set<java.lang.String> |
bcelInterfaces
The set of names of the interfaces and their super interfaces which are
implemented by the target class and were loaded using BCEL.
|
private java.util.Set<java.lang.Class> |
loaderIterfaces
The set of the interfaces which are implemented by the target class and
were loaded using class loader.
|
private java.lang.Class |
rootSuperclass
The root superclass.
|
private java.util.List<org.apache.bcel.classfile.JavaClass> |
superclassChain
The list of superclasses.
|
Constructor and Description |
---|
ClassInfo(java.lang.Class targetClass)
Creates the class definitions container for the target class.
|
ClassInfo(org.apache.bcel.classfile.JavaClass targetClass)
Creates the class definitions container for the target class.
|
Modifier and Type | Method and Description |
---|---|
void |
addBcelInterface(java.lang.String iface)
Add to the list of the interfaces implemented by this class the
specified interfaces (loaded by BCEL).
|
void |
addInterface(java.lang.Class iface)
Add to the list of the interfaces implemented by this class the
specified interfaces (loaded by class loader).
|
void |
addSuperclass(org.apache.bcel.classfile.JavaClass superclass)
Add definitions of a superclass.
|
private static boolean |
compareMethods(org.apache.bcel.classfile.Method method1,
java.lang.reflect.Method method2)
Compares names, return types and argument types of two methods.
|
private static boolean |
compareMethods(java.lang.reflect.Method method1,
java.lang.reflect.Method method2)
Compares names, return types and argument types of two methods.
|
private static boolean |
compareMethods(org.apache.bcel.classfile.Method method1,
org.apache.bcel.classfile.Method method2)
Compares names, return types and argument types of two methods.
|
static boolean |
compareMethods(java.lang.Object method1,
java.lang.Object method2)
Compares names, return types and argument types of two methods.
|
java.lang.String |
getClassName()
Get the class name.
|
java.lang.String[] |
getFirstLevelBcelInterfaces()
Get the names of the interfaces which are directly implemented by the
superclasses (including the target class) which were loaded using BCEL.
|
java.lang.Object[] |
getPublicMethods()
Get the list of all public methods.
|
java.lang.Object[] |
getPublicStaticMethods()
Get the list of all public static methods.
|
boolean |
isAbstract()
Determines whether this class is abstract.
|
static boolean |
isAbstractMethod(java.lang.Object method)
Determines whether the specified method is abstract.
|
boolean |
isImplements(java.lang.Class iface)
Determines whether the class implements the target interface.
|
boolean |
isInterface()
Determines whether this class object represents an interface type.
|
boolean |
isPublic()
Determines whether the class is public.
|
boolean |
isStaticallyImplements(java.lang.Class iface)
Determines whether the class "statically implements" the target
interface, i.e.
|
void |
setRootSuperclass(java.lang.Class rootSuperclass)
Set the root superclass.
|
java.lang.String |
toString()
Get the string representation of the container.
|
private java.util.List<org.apache.bcel.classfile.JavaClass> superclassChain
null
then the zero element
contains definitions of the target class. If null
then the
target class is stored into rootSuperclass
variable.private java.lang.Class rootSuperclass
null
if all superclasses were
loaded using BCEL.private java.util.Set<java.lang.String> bcelInterfaces
private java.util.Set<java.lang.Class> loaderIterfaces
public ClassInfo(java.lang.Class targetClass)
targetClass
- Class object which represents the target class.public ClassInfo(org.apache.bcel.classfile.JavaClass targetClass)
targetClass
- JavaClass object which represents the target class.public static boolean compareMethods(java.lang.Object method1, java.lang.Object method2)
method1
- First method to compare. Can be
java.lang.reflect.Method or
org.apache.bcel.classfile.Method.method2
- Second method to compare. Can be
java.lang.reflect.Method or
org.apache.bcel.classfile.Method.true
if methods match.public static boolean isAbstractMethod(java.lang.Object method)
method
- Method to me checked. Can be java.lang.reflect.Method
or org.apache.bcel.classfile.Method.true
if the method is abstract.public void setRootSuperclass(java.lang.Class rootSuperclass)
rootSuperclass
- Root superclass to be set.public void addSuperclass(org.apache.bcel.classfile.JavaClass superclass)
superclass
- Superclass definitions to be added.public boolean isImplements(java.lang.Class iface)
iface
- Interface to be checked.true
if the class implements the target interface.public java.lang.String[] getFirstLevelBcelInterfaces()
public boolean isStaticallyImplements(java.lang.Class iface) throws java.lang.NoClassDefFoundError
iface
- Interface to be checked.true
if the class "statically implements" the
target interface.java.lang.NoClassDefFoundError
- If methods of the target interface cannot be resolved.public java.lang.String getClassName()
public boolean isPublic()
true
if the class is public.public boolean isInterface()
true
if this class object represents an interface
type.public boolean isAbstract()
true
if this class is abstract.public java.lang.Object[] getPublicMethods()
public java.lang.Object[] getPublicStaticMethods()
public void addInterface(java.lang.Class iface)
iface
- Interface to be addedpublic void addBcelInterface(java.lang.String iface)
iface
- The name of the interface to be added.public java.lang.String toString()
toString
in class java.lang.Object
private static boolean compareMethods(org.apache.bcel.classfile.Method method1, java.lang.reflect.Method method2)
method1
- First method to compare.method2
- Second method to compare.true
if methods match.private static boolean compareMethods(java.lang.reflect.Method method1, java.lang.reflect.Method method2)
method1
- First method to compare.method2
- Second method to compare.true
if methods match.private static boolean compareMethods(org.apache.bcel.classfile.Method method1, org.apache.bcel.classfile.Method method2)
method1
- First method to compare.method2
- Second method to compare.true
if methods match.