本文整理匯總了Java中org.apache.bcel.classfile.JavaClass.getSuperClasses方法的典型用法代碼示例。如果您正苦於以下問題:Java JavaClass.getSuperClasses方法的具體用法?Java JavaClass.getSuperClasses怎麽用?Java JavaClass.getSuperClasses使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.bcel.classfile.JavaClass
的用法示例。
在下文中一共展示了JavaClass.getSuperClasses方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: build
import org.apache.bcel.classfile.JavaClass; //導入方法依賴的package包/類
public void build() throws ClassNotFoundException {
JavaClass jclass = classContext.getJavaClass();
// Build a set of all fields that could be assigned
// by methods in this class
HashSet<XField> assignableFieldSet = new HashSet<XField>();
scanFields(jclass, assignableFieldSet);
JavaClass[] superClassList = jclass.getSuperClasses();
if (superClassList != null) {
for (int i = 0; i < superClassList.length; ++i) {
scanFields(superClassList[i], assignableFieldSet);
}
}
Method[] methodList = jclass.getMethods();
for (int i = 0; i < methodList.length; ++i) {
Method method = methodList[i];
MethodGen methodGen = classContext.getMethodGen(method);
if (methodGen == null)
continue;
scanMethod(method, assignableFieldSet);
}
}
示例2: visitObject
import org.apache.bcel.classfile.JavaClass; //導入方法依賴的package包/類
/** @see com.puppycrawl.tools.checkstyle.bcel.IObjectSetVisitor */
public void visitObject(Object aJavaClass)
{
final JavaClass javaClass = (JavaClass) aJavaClass;
final String className = javaClass.getClassName();
final JavaClass[] superClasses = javaClass.getSuperClasses();
final Field[] fields = javaClass.getFields();
// Check all fields
for (int i = 0; i < fields.length; i++) {
final Field field = fields[i];
// Go through all superclasses
for (int j = 0; j < superClasses.length; j++) {
final JavaClass superClass = superClasses[j];
final String superClassName = superClass.getClassName();
final Field[] superClassFields = superClass.getFields();
// Go through the filds of the superclasses
for (int k = 0; k < superClassFields.length; k++) {
final Field superClassField = superClassFields[k];
if (!superClassField.isPrivate() &&
superClassField.getName().equals(field.getName()) &&
!ignore(className, field)) {
log(
javaClass,
0,
"hidden.inherited.field",
new Object[] {fields[i], superClassName});
}
}
}
}
}
示例3: visitObject
import org.apache.bcel.classfile.JavaClass; //導入方法依賴的package包/類
/** @see com.puppycrawl.tools.checkstyle.bcel.IObjectSetVisitor */
public void visitObject(Object aJavaClass)
{
final JavaClass javaClass = (JavaClass) aJavaClass;
final String className = javaClass.getClassName();
final JavaClass[] superClasses = javaClass.getSuperClasses();
final Method[] methods = javaClass.getMethods();
// Check all methods
for (int i = 0; i < methods.length; i++) {
final Method method = methods[i];
// Check that the method is a possible match
if (!method.isPrivate() && method.isStatic()) {
// Go through all their superclasses
for (int j = 0; j < superClasses.length; j++) {
final JavaClass superClass = superClasses[j];
final String superClassName = superClass.getClassName();
final Method[] superClassMethods = superClass.getMethods();
// Go through the methods of the superclasses
for (int k = 0; k < superClassMethods.length; k++) {
final Method superClassMethod = superClassMethods[k];
if (superClassMethod.getName().equals(method.getName()) &&
!ignore(className, method)) {
Type[] methodTypes = method.getArgumentTypes();
Type[] superTypes = superClassMethod.
getArgumentTypes();
if (methodTypes.length == superTypes.length) {
boolean match = true;
for (int arg = 0; arg < methodTypes.length; arg++) {
if (!methodTypes[arg].equals(superTypes[arg])) {
match = false;
}
}
// Same method parameters
if (match) {
log(
javaClass,
0,
"hidden.static.method",
new Object[] {method, superClassName});
}
}
}
}
}
}
}
}