当前位置: 首页>>代码示例>>Java>>正文


Java Repository.lookupClass方法代码示例

本文整理汇总了Java中org.apache.bcel.Repository.lookupClass方法的典型用法代码示例。如果您正苦于以下问题:Java Repository.lookupClass方法的具体用法?Java Repository.lookupClass怎么用?Java Repository.lookupClass使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.bcel.Repository的用法示例。


在下文中一共展示了Repository.lookupClass方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: visit

import org.apache.bcel.Repository; //导入方法依赖的package包/类
public void visit(JavaClass obj) {
	if (recursiveDetector == null) return;
	try {
	if (getClassName().endsWith("package-info")) return;
	String packageName = getPackageName().replace('/', '.');
	if (!packages.add(packageName)) return;
	String packageInfo = "package-info";
	if (packageName.length() > 0)
		packageInfo = packageName + "." + packageInfo;
		
	JavaClass packageInfoClass = Repository.lookupClass(packageInfo);
	recursiveDetector.visitJavaClass(packageInfoClass);
	} catch (ClassNotFoundException e) {
		// ignore 
	}
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:17,代码来源:NoteSuppressedWarnings.java

示例2: findField

import org.apache.bcel.Repository; //导入方法依赖的package包/类
Field findField(String className, String fieldName) {
	try {
		// System.out.println("Looking for " + className);
		JavaClass fieldDefinedIn = getThisClass();
		if (!className.equals(getClassName())) {
			// System.out.println("Using repository to look for " + className);

			fieldDefinedIn = Repository.lookupClass(className);
		}
		Field[] f = fieldDefinedIn.getFields();
		for (int i = 0; i < f.length; i++)
			if (f[i].getName().equals(fieldName)) {
				// System.out.println("Found " + f[i]);
				return f[i];
			}
		return null;
	} catch (ClassNotFoundException e) {
		return null;
	}
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:21,代码来源:FindDoubleCheck.java

示例3: getJavaClass

import org.apache.bcel.Repository; //导入方法依赖的package包/类
public JavaClass getJavaClass() throws ClassNotFoundException {
	String baseSig;
	
	if (isPrimitive())
		return null;
		
	if (isArray()) {
		baseSig = getElementSignature();
	} else {
		baseSig = signature;
	}
	
	if (baseSig.length() == 0)
		return null;
	baseSig = baseSig.substring(1, baseSig.length() - 1);
	baseSig = baseSig.replace('/', '.');
	return Repository.lookupClass(baseSig);
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:19,代码来源:OpcodeStack.java

示例4: findField

import org.apache.bcel.Repository; //导入方法依赖的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

示例5: resolveClass

import org.apache.bcel.Repository; //导入方法依赖的package包/类
public void resolveClass(ClassType type, TypeRepository repos) throws ClassNotFoundException {
	// Find the representation of the class
	JavaClass javaClass = Repository.lookupClass(type.getClassName());

	// Determine whether the type is a class or an interface
	type.setIsInterface(javaClass.isInterface());

	// Set superclass link (if any)
	int superclassIndex = javaClass.getSuperclassNameIndex();
	if (superclassIndex > 0) {
		// Type has a superclass
		String superclassName = getClassString(javaClass, superclassIndex);
		repos.addSuperclassLink(type, repos.classTypeFromSlashedClassName(superclassName));
	}

	// Set interface links (if any)
	int[] interfaceIndexList = javaClass.getInterfaceIndices();
	for (int i = 0; i < interfaceIndexList.length; ++i) {
		int index = interfaceIndexList[i];
		String interfaceName = getClassString(javaClass, index);
		repos.addInterfaceLink(type, repos.classTypeFromSlashedClassName(interfaceName));
	}
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:24,代码来源:BCELRepositoryClassResolver.java

示例6: addFieldReference

import org.apache.bcel.Repository; //导入方法依赖的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

示例7: findFieldDef

import org.apache.bcel.Repository; //导入方法依赖的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

示例8: getOuterClass

import org.apache.bcel.Repository; //导入方法依赖的package包/类
/**
 * Determine the outer class of obj.
 * 
 * @param obj
 * @return JavaClass for outer class, or null if obj is not an outer class
 * @throws ClassNotFoundException
 */

@CheckForNull
public static JavaClass getOuterClass(JavaClass obj) throws ClassNotFoundException {
    for (Attribute a : obj.getAttributes())
        if (a instanceof InnerClasses) {
            for (InnerClass ic : ((InnerClasses) a).getInnerClasses()) {
                if (obj.getClassNameIndex() == ic.getInnerClassIndex()) {
                    // System.out.println("Outer class is " +
                    // ic.getOuterClassIndex());
                    ConstantClass oc = (ConstantClass) obj.getConstantPool().getConstant(ic.getOuterClassIndex());
                    String ocName = oc.getBytes(obj.getConstantPool());
                    return Repository.lookupClass(ocName);
                }
            }
        }
    return null;
}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:25,代码来源:Util.java

示例9: findField

import org.apache.bcel.Repository; //导入方法依赖的package包/类
Field findField(String className, String fieldName) {
    try {
        // System.out.println("Looking for " + className);
        JavaClass fieldDefinedIn = getThisClass();
        if (!className.equals(getClassName())) {
            // System.out.println("Using repository to look for " +
            // className);

            fieldDefinedIn = Repository.lookupClass(className);
        }
        Field[] f = fieldDefinedIn.getFields();
        for (Field aF : f)
            if (aF.getName().equals(fieldName)) {
                // System.out.println("Found " + f[i]);
                return aF;
            }
        return null;
    } catch (ClassNotFoundException e) {
        return null;
    }
}
 
开发者ID:OpenNTF,项目名称:FindBug-for-Domino-Designer,代码行数:22,代码来源:FindDoubleCheck.java

示例10: getJavaClass

import org.apache.bcel.Repository; //导入方法依赖的package包/类
/** Returns null for primitive and arrays */
public @CheckForNull
JavaClass getJavaClass() throws ClassNotFoundException {
    String baseSig;

    if (isPrimitive() || isArray())
        return null;

    baseSig = signature;

    if (baseSig.length() == 0)
        return null;
    baseSig = baseSig.substring(1, baseSig.length() - 1);
    baseSig = baseSig.replace('/', '.');
    return Repository.lookupClass(baseSig);
}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:17,代码来源:OpcodeStack.java

示例11: main

import org.apache.bcel.Repository; //导入方法依赖的package包/类
/**
 * Main class, to find strings in class files.
 * @param args Arguments to program.
 */
public static void main(String[] args) {
    try {
        JavaClass clazz = Repository.lookupClass(args[0]);
        ConstantPool cp = clazz.getConstantPool();
        Constant[] consts = cp.getConstantPool();


        for (int i = 0; i < consts.length; i++) {

            if (consts[i] instanceof ConstantString) {
                System.out.println("Found String: " +
                        ((ConstantString)consts[i]).getBytes(cp));
            }
        }
    }
    catch (Exception e) {
        e.printStackTrace();
    }
}
 
开发者ID:spacewalkproject,项目名称:spacewalk,代码行数:24,代码来源:FindStrings.java

示例12: isDeepRemote

import org.apache.bcel.Repository; //导入方法依赖的package包/类
public static double isDeepRemote(String refSig) {
    if (remote == null)
        return 0.1;

    String refName = getComponentClass(refSig);
    if (refName.equals("java.lang.Object"))
        return 0.99;

    JavaClass refJavaClass;
    try {
        refJavaClass = Repository.lookupClass(refName);
        return deepInstanceOf(refJavaClass, remote);
    } catch (ClassNotFoundException e) {
        return 0.99;
    }

}
 
开发者ID:OpenNTF,项目名称:FindBug-for-Domino-Designer,代码行数:18,代码来源:Analyze.java

示例13: visitGETSTATIC

import org.apache.bcel.Repository; //导入方法依赖的package包/类
/**
 * Checks if the constraints of operands of the said instruction(s) are satisfied.
 */
public void visitGETSTATIC(GETSTATIC o) {
    String field_name = o.getFieldName(cpg);
    JavaClass jc = Repository.lookupClass(o.getClassType(cpg).getClassName());
    Field[] fields = jc.getFields();
    Field f = null;
    for (Field field : fields) {
        if (field.getName().equals(field_name)) {
            f = field;
            break;
        }
    }
    if (f == null) {
        throw new AssertionViolatedException("Field not found?!?");
    }

    if (!(f.isStatic())) {
        constraintViolated(o, "Referenced field '" + f + "' is not static which it should be.");
    }
}
 
开发者ID:miuirussia,项目名称:KJBE,代码行数:23,代码来源:Pass3aVerifier.java

示例14: sawOpcode

import org.apache.bcel.Repository; //导入方法依赖的package包/类
public void sawOpcode(int seen) {
	if (DEBUG) System.out.println("State: " + state + "  Opcode: " + OPCODE_NAMES[seen]);

	switch (state) {
	case SEEN_NOTHING:
		if (seen == ICONST_0)
			state = SEEN_ICONST_0;
		break;

	case SEEN_ICONST_0:
		if (seen == ANEWARRAY) {
			state = SEEN_ANEWARRAY;
		} else
			state = SEEN_NOTHING;
		break;

	case SEEN_ANEWARRAY:
		if ((seen == INVOKEVIRTUAL)
		        && (getNameConstantOperand().equals("toArray"))
		        && (getSigConstantOperand().equals("([Ljava/lang/Object;)[Ljava/lang/Object;"))) {
			try {
				String clsName = getClassConstantOperand();
				JavaClass cls = Repository.lookupClass(clsName);
				if (cls.implementationOf(collectionClass))
					bugReporter.reportBug(new BugInstance(this, "ITA_INEFFICIENT_TO_ARRAY", LOW_PRIORITY)
					        .addClassAndMethod(this)
					        .addSourceLine(this));

			} catch (ClassNotFoundException cnfe) {
				bugReporter.reportMissingClass(cnfe);
			}
		}
		state = SEEN_NOTHING;
		break;

	default:
		state = SEEN_NOTHING;
		break;
	}
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:41,代码来源:InefficientToArray.java

示例15: BadAppletConstructor

import org.apache.bcel.Repository; //导入方法依赖的package包/类
public BadAppletConstructor(BugReporter bugReporter) {
	this.bugReporter = bugReporter;
	try {
		appletClass = Repository.lookupClass("java.applet.Applet");
	} catch (ClassNotFoundException cnfe) {
		bugReporter.reportMissingClass(cnfe);
		appletClass = null;
	}
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:10,代码来源:BadAppletConstructor.java


注:本文中的org.apache.bcel.Repository.lookupClass方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。