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


Java Repository类代码示例

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


Repository类属于org.apache.bcel包,在下文中一共展示了Repository类的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: checkSuper

import org.apache.bcel.Repository; //导入依赖的package包/类
private boolean checkSuper(MyMethod m, HashSet<MyMethod> others) {
	for (Iterator<MyMethod> i = others.iterator(); i.hasNext();) {
		MyMethod m2 = i.next();
		try {
			if (m.confusingMethodNames(m2)
			        && Repository.instanceOf(m.clazz, m2.clazz)) {
				MyMethod m3 = new MyMethod(m.clazz, m2.methodName, m.methodSig);
				boolean r = others.contains(m3);
				if (r) continue;
				bugReporter.reportBug(new BugInstance(this, "NM_VERY_CONFUSING", HIGH_PRIORITY)
				        .addClass(m.getClassName())
				        .addMethod(m.getClassName(), m.methodName, m.methodSig)
				        .addClass(m2.getClassName())
				        .addMethod(m2.getClassName(), m2.methodName, m2.methodSig));
				return true;
			}
		} catch (ClassNotFoundException e) {
		}
	}
	return false;
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:22,代码来源:Naming.java

示例4: 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

示例5: 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

示例6: 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

示例7: setRepositoryClassPath

import org.apache.bcel.Repository; //导入依赖的package包/类
/**
 * Based on Project settings, set the classpath to be used
 * by the Repository when looking up classes.
 * @throws IOException
 */
private void setRepositoryClassPath(List<String> additionalAuxClasspathEntryList)
		throws IOException {

	URLClassPathRepository repository =
		(URLClassPathRepository) Repository.getRepository();

	// Set aux classpath entries
	addCollectionToClasspath(project.getAuxClasspathEntryList(), repository);
	
	// Set implicit classpath entries
	addCollectionToClasspath(project.getImplicitClasspathEntryList(), repository);

	// Add "extra" aux classpath entries needed to ensure that
	// skipped classes can be referenced.
	addCollectionToClasspath(additionalAuxClasspathEntryList, repository);

	// Add system classpath entries
	repository.addSystemClasspathComponents();
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:25,代码来源:FindBugs.java

示例8: 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

示例9: 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

示例10: findNarrowestMethod

import org.apache.bcel.Repository; //导入依赖的package包/类
/**
 * Finds the narrowest method that is compatible with a method.
 * An invocation of the given method can be resolved as an invocation
 * of the narrowest method.
 * @param aClassName the class for the method.
 * @param aMethodName the name of the method.
 * @param aArgTypes the types for the method.
 * @return the narrowest compatible method.
 */
public MethodDefinition findNarrowestMethod(
    String aClassName,
    String aMethodName,
    Type[] aArgTypes)
{
    MethodDefinition result = null;
    final String javaClassName = mJavaClass.getClassName();
    if (Repository.instanceOf(aClassName, javaClassName)) {
        // check all
        for (int i = 0; i < mMethodDefs.length; i++) {
            // TODO: check access privileges
            if (mMethodDefs[i].isCompatible(aMethodName, aArgTypes)) {
                if (result == null) {
                    result = mMethodDefs[i];
                }
                //else if (mMethodDefs[i].isAsNarrow(result)) {
                else if (result.isCompatible(mMethodDefs[i])) {
                    result = mMethodDefs[i];
                }
            }
        }
    }
    return result;
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:34,代码来源:JavaClassDefinition.java

示例11: visitSet

import org.apache.bcel.Repository; //导入依赖的package包/类
/** @see com.puppycrawl.tools.checkstyle.bcel.IObjectSetVisitor */
public void visitSet(Set aSet)
{
    // register the JavaClasses in the Repository
    Repository.clearCache();
    Iterator it = aSet.iterator();
    while (it.hasNext()) {
        final JavaClass javaClass = (JavaClass) it.next();
        Repository.addClass(javaClass);
    }

    // visit the visitors
    it = getObjectSetVisitors().iterator();
    while (it.hasNext()) {
        final IObjectSetVisitor visitor = (IObjectSetVisitor) it.next();
        visitor.visitSet(aSet);
    }
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:19,代码来源:ClassFileSetCheck.java

示例12: do_verify

import org.apache.bcel.Repository; //导入依赖的package包/类
/**
 * Pass 2 is the pass where static properties of the
 * class file are checked without looking into "Code"
 * arrays of methods.
 * This verification pass is usually invoked when
 * a class is resolved; and it may be possible that
 * this verification pass has to load in other classes
 * such as superclasses or implemented interfaces.
 * Therefore, Pass 1 is run on them.<BR>
 * Note that most referenced classes are <B>not</B> loaded
 * in for verification or for an existance check by this
 * pass; only the syntactical correctness of their names
 * and descriptors (a.k.a. signatures) is checked.<BR>
 * Very few checks that conceptually belong here
 * are delayed until pass 3a in JustIce. JustIce does
 * not only check for syntactical correctness but also
 * for semantical sanity - therefore it needs access to
 * the "Code" array of methods in a few cases. Please
 * see the pass 3a documentation, too.
 *
 * @see org.apache.bcel.verifier.statics.Pass3aVerifier
 */
public VerificationResult do_verify(){
	VerificationResult vr1 = myOwner.doPass1();
	if (vr1.equals(VerificationResult.VR_OK)){
		
		// For every method, we could have information about the local variables out of LocalVariableTable attributes of
		// the Code attributes.
		localVariablesInfos = new LocalVariablesInfo[Repository.lookupClass(myOwner.getClassName()).getMethods().length];

		VerificationResult vr = VerificationResult.VR_OK; // default.
		try{
			constant_pool_entries_satisfy_static_constraints();
			field_and_method_refs_are_valid();
			every_class_has_an_accessible_superclass();
			final_methods_are_not_overridden();
		}
		catch (ClassConstraintException cce){
			vr = new VerificationResult(VerificationResult.VERIFIED_REJECTED, cce.getMessage());
		}
		return vr;
	}
	else
		return VerificationResult.VR_NOTYET;
}
 
开发者ID:linchaolong,项目名称:ApkToolPlus,代码行数:46,代码来源:Pass2Verifier.java

示例13: getDisplayList

import org.apache.bcel.Repository; //导入依赖的package包/类
public static VectorD getDisplayList(String sourceFileName, String className) {
VectorD displayList = (VectorD) table.get(sourceFileName);
String sourceFilePath;

if (displayList != null) return displayList;
if (sourceFileName.equals("UnknownFile.java")) return new VectorD();

BufferedReader r;
  
if (Debugger.DEMO) return getDemoList(sourceFileName);

ClassPath.ClassFile cf = Repository.lookupClassFile(className);

if (cf != null) sourceFilePath = getSourceFileName(cf, sourceFileName);
else sourceFilePath = getSourceFileName(className, sourceFileName);

r = getReader(sourceFilePath);
if (r == null) r = getReaderFN(sourceFileName, className); 
if (r == null) r = getReaderFN2(sourceFileName, className);
return(buildFileLines(r, sourceFileName));
   }
 
开发者ID:OmniscientDebugger,项目名称:LewisOmniscientDebugger,代码行数:22,代码来源:CodePane.java

示例14: rewrite

import org.apache.bcel.Repository; //导入依赖的package包/类
void rewrite(JavaClass javaClass, SpawnSignature[] spawnSignatures)
        throws NoSpawningClassException, ClassRewriteFailure, AssumptionFailure {
    String className = javaClass.getClassName();
    SpawningClass spawnableClass = 
        new SpawningClass(javaClass, spawnSignatures, new Debug(d.turnedOn(), 2));
    d.log(0, "%s is a spawning class\n", className);
    d.log(1, "it contains calls with spawn signatures:\n");
    print(spawnableClass.getSpawnSignatures(), 2);
    d.log(1, "rewriting %s\n", className);
    if (spawnableClass.rewrite(analyzer)) {
        Repository.removeClass(javaClass);
        javaClass = spawnableClass.getJavaClass();
        Repository.addClass(javaClass);
        setModified(wrapper.getInfo(javaClass));
    }
}
 
开发者ID:pieterhijma,项目名称:cashmere,代码行数:17,代码来源:SyncRewriter.java

示例15: 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


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