當前位置: 首頁>>代碼示例>>Java>>正文


Java JavaClass.getSuperClass方法代碼示例

本文整理匯總了Java中org.apache.bcel.classfile.JavaClass.getSuperClass方法的典型用法代碼示例。如果您正苦於以下問題:Java JavaClass.getSuperClass方法的具體用法?Java JavaClass.getSuperClass怎麽用?Java JavaClass.getSuperClass使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.bcel.classfile.JavaClass的用法示例。


在下文中一共展示了JavaClass.getSuperClass方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: visit

import org.apache.bcel.classfile.JavaClass; //導入方法依賴的package包/類
public void visit(JavaClass obj) {
	try {
		methodMap.clear();
		badOverrideMap.clear();
		JavaClass superClass = obj.getSuperClass();
		if (superClass == null) return;
		String packageName = superClass.getPackageName();
		String className = superClass.getClassName();
		isAdapter = ((className.endsWith("Adapter")) && (packageName.equals("java.awt.event") || packageName.equals("javax.swing.event")));
		if (isAdapter) {
			Method[] methods = superClass.getMethods();
			for (int i = 0; i < methods.length; i++) {
				methodMap.put(methods[i].getName(), methods[i].getSignature());
			}
		}
	} catch (ClassNotFoundException cnfe) {
		bugReporter.reportMissingClass(cnfe);
	}
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:20,代碼來源:BadlyOverriddenAdapter.java

示例2: findField

import org.apache.bcel.classfile.JavaClass; //導入方法依賴的package包/類
/**
 * Find a field with given name defined in given class.
 *
 * @param className the name of the class
 * @param fieldName the name of the field
 * @return the Field, or null if no such field could be found
 */
public static Field findField(String className, String fieldName) throws ClassNotFoundException {
	JavaClass jclass = Repository.lookupClass(className);

	while (jclass != null) {
		Field[] fieldList = jclass.getFields();
		for (int i = 0; i < fieldList.length; ++i) {
			Field field = fieldList[i];
			if (field.getName().equals(fieldName)) {
				return field;
			}
		}

		jclass = jclass.getSuperClass();
	}

	return null;
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:25,代碼來源:Hierarchy.java

示例3: addFieldReference

import org.apache.bcel.classfile.JavaClass; //導入方法依賴的package包/類
/**
 * Adds a reference to a field.
 * @param aFieldRef the field reference.
 */
public void addFieldReference(FieldReference aFieldRef)
{
    final String className = aFieldRef.getClassName();
    JavaClass javaClass = Repository.lookupClass(className);
    final String fieldName = aFieldRef.getName();
    // search up the class hierarchy for the class containing the
    // method definition.
    FieldDefinition fieldDef = null;
    while ((javaClass != null) && (fieldDef == null)) {
        final JavaClassDefinition javaClassDef =
            (JavaClassDefinition) mJavaClasses.get(javaClass);
        if (javaClassDef != null) {
            fieldDef = javaClassDef.findFieldDef(fieldName);
            if (fieldDef != null) {
                fieldDef.addReference(aFieldRef);
            }
        }
        //search the parent
        javaClass = javaClass.getSuperClass();
    }
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:26,代碼來源:ReferenceDAO.java

示例4: findFieldDef

import org.apache.bcel.classfile.JavaClass; //導入方法依賴的package包/類
/**
 * Finds the definition of the field of a field reference.
 * @param aFieldRef the reference to a field.
 * @return the definition of the field for aFieldRef.
 */
public FieldDefinition findFieldDef(FieldReference aFieldRef)
{
    final String className = aFieldRef.getClassName();
    JavaClass javaClass = Repository.lookupClass(className);
    final String fieldName = aFieldRef.getName();
    // search up the class hierarchy for the class containing the
    // method definition.
    FieldDefinition result = null;
    while ((javaClass != null) && (result == null)) {
        final JavaClassDefinition javaClassDef =
            (JavaClassDefinition) mJavaClasses.get(javaClass);
        if (javaClassDef != null) {
            result = javaClassDef.findFieldDef(fieldName);
        }
        //search the parent
        javaClass = javaClass.getSuperClass();
    }
    return result;
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:25,代碼來源:ReferenceDAO.java

示例5: findXField

import org.apache.bcel.classfile.JavaClass; //導入方法依賴的package包/類
/**
 * Look up a field with given name and signature in given class,
 * returning it as an {@link XField XField} object.
 * If a field can't be found in the immediate class,
 * its superclass is search, and so forth.
 *
 * @param className name of the class through which the field
 *                  is referenced
 * @param fieldName name of the field
 * @param fieldSig  signature of the field
 * @return an XField object representing the field, or null if no such field could be found
 */
public static XField findXField(String className, String fieldName, String fieldSig)
        throws ClassNotFoundException {

	JavaClass classDefiningField = Repository.lookupClass(className);

	Field field = null;
	loop:
		while (classDefiningField != null) {
			Field[] fieldList = classDefiningField.getFields();
			for (int i = 0; i < fieldList.length; ++i) {
				field = fieldList[i];
				if (field.getName().equals(fieldName) && field.getSignature().equals(fieldSig)) {
					break loop;
				}
			}

			classDefiningField = classDefiningField.getSuperClass();
		}

	if (classDefiningField == null)
		return null;
	else {
		String realClassName = classDefiningField.getClassName();
		int accessFlags = field.getAccessFlags();
		return field.isStatic()
		        ? (XField) new StaticField(realClassName, fieldName, fieldSig, accessFlags)
		        : (XField) new InstanceField(realClassName, fieldName, fieldSig, accessFlags);
	}
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:42,代碼來源:Hierarchy.java

示例6: addInvokeReference

import org.apache.bcel.classfile.JavaClass; //導入方法依賴的package包/類
/**
 * Adds a reference for an invocation in the invoked method definition.
 * The invocation is of the form class.method(args).
 * @param aInvokeRef the invocation reference.
 */
public void addInvokeReference(InvokeReference aInvokeRef)
{
    // find the class for the instruction
    final String className = aInvokeRef.getClassName();
    JavaClass javaClass = Repository.lookupClass(className);
    final String methodName = aInvokeRef.getName();
    final Type[] argTypes = aInvokeRef.getArgTypes();

    // search up the class hierarchy for the class containing the
    // method definition.
    MethodDefinition narrowest = null;
    while ((javaClass != null) && (narrowest == null)) {
        final JavaClassDefinition javaClassDef =
            (JavaClassDefinition) mJavaClasses.get(javaClass);
        if (javaClassDef != null) {
            // find narrowest compatible in the current class
            narrowest =
                javaClassDef.findNarrowestMethod(
                    className,
                    methodName,
                    argTypes);
            if (narrowest != null) {
                narrowest.addReference(aInvokeRef);
            }
        }
        // search the parent
        javaClass = javaClass.getSuperClass();
    }
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:35,代碼來源:ReferenceDAO.java

示例7: hasReference

import org.apache.bcel.classfile.JavaClass; //導入方法依賴的package包/類
/**
 * Determines whether there is reference to a given Method in this JavaClass
 * definition or a definition in a superclass.
 * @param aMethodDef the Method to check.
 * @param aReferenceDAO reference DAO.
 * @return true if there is a reference to the method of aMethodDef in
 * this JavaClass or a superclass.
 */
public boolean hasReference(
    MethodDefinition aMethodDef,
    ReferenceDAO aReferenceDAO)
{
    final String methodName = aMethodDef.getName();
    final Type[] argTypes = aMethodDef.getArgumentTypes();

    // search the inheritance hierarchy
    JavaClass currentJavaClass = getJavaClass();
    while (currentJavaClass != null) {
        final JavaClassDefinition javaClassDef =
            aReferenceDAO.findJavaClassDef(currentJavaClass);
        if (javaClassDef != null) {
            final MethodDefinition methodDef =
                javaClassDef.findNarrowestMethod(
                    getJavaClass().getClassName(),
                    methodName,
                    argTypes);
            if ((methodDef != null)
                && (methodDef.hasReference(getJavaClass())))
            {
                return true;
            }
        }
        currentJavaClass = currentJavaClass.getSuperClass();
    }
    return false;
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:37,代碼來源:JavaClassDefinition.java


注:本文中的org.apache.bcel.classfile.JavaClass.getSuperClass方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。