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


Java JavaClass類代碼示例

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


JavaClass類屬於org.apache.bcel.classfile包,在下文中一共展示了JavaClass類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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: visitSet

import org.apache.bcel.classfile.JavaClass; //導入依賴的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

示例3: visitClassContext

import org.apache.bcel.classfile.JavaClass; //導入依賴的package包/類
public void visitClassContext(ClassContext classContext) {
	try {
		JavaClass javaClass = classContext.getJavaClass();
		Method[] methodList = javaClass.getMethods();

		for (int i = 0; i < methodList.length; ++i) {
			Method method = methodList[i];
			if (classContext.getMethodGen(method) == null)
				continue;

			CFG cfg = classContext.getCFG(method);
			for (Iterator<BasicBlock> j = cfg.blockIterator(); j.hasNext();) {
				BasicBlock basicBlock = j.next();
				analyzeBasicBlock(classContext, method, basicBlock);
			}
		}

	} catch (CFGBuilderException e) {
		throw new AnalysisException("FindLocalSelfAssignment caught exception: " + e, e);
	}
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:22,代碼來源:FindLocalSelfAssignment.java

示例4: findField

import org.apache.bcel.classfile.JavaClass; //導入依賴的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

示例5: visit

import org.apache.bcel.classfile.JavaClass; //導入依賴的package包/類
public void visit(JavaClass obj) {
	String name = obj.getClassName();
	String[] parts = name.split("[$+.]");
	baseClassName = parts[parts.length - 1];
	classIsPublicOrProtected = obj.isPublic() || obj.isProtected();
	if (baseClassName.length() == 1) return;
	if(Character.isLetter(baseClassName.charAt(0))
	   && !Character.isUpperCase(baseClassName.charAt(0))
	   && baseClassName.indexOf("_") ==-1 
		)
		bugReporter.reportBug(new BugInstance(this, 
			"NM_CLASS_NAMING_CONVENTION", 
			classIsPublicOrProtected 
			? NORMAL_PRIORITY
			: LOW_PRIORITY
				)
		        .addClass(this));
	super.visit(obj);
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:20,代碼來源:Naming.java

示例6: visitClassContext

import org.apache.bcel.classfile.JavaClass; //導入依賴的package包/類
public void visitClassContext(ClassContext classContext) {
	try {
		setUpAnnotation = null;
		tearDownAnnotation = null;
		validClass = false;
		validMethod = false;
		sawSetUp = false;
		sawTearDown = false;
		JavaClass[] superClasses = classContext.getJavaClass().getSuperClasses();
		for (int i = 0; i < superClasses.length; i++) {
			JavaClass sc = superClasses[i];
			if (sc.getClassName().equals("junit.framework.TestCase")) {
				validClass = true;
				classContext.getJavaClass().accept(this);
				break;
			}
		}
	} catch (ClassNotFoundException cnfe) {
		bugReporter.reportMissingClass(cnfe);
	}
		
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:23,代碼來源:InvalidJUnitTest.java

示例7: inspectResult

import org.apache.bcel.classfile.JavaClass; //導入依賴的package包/類
public void inspectResult(JavaClass javaClass, MethodGen methodGen, CFG cfg,
                          Dataflow<ResourceValueFrame, ResourceValueAnalysis<Lock>> dataflow, Lock resource) {

	ResourceValueFrame exitFrame = dataflow.getResultFact(cfg.getExit());
	int exitStatus = exitFrame.getStatus();

	if (exitStatus == ResourceValueFrame.OPEN || exitStatus == ResourceValueFrame.OPEN_ON_EXCEPTION_PATH) {
		String bugType;
		int priority;
		if (exitStatus == ResourceValueFrame.OPEN) {
			bugType = "UL_UNRELEASED_LOCK";
			priority = HIGH_PRIORITY;
		} else {
			bugType = "UL_UNRELEASED_LOCK_EXCEPTION_PATH";
			priority = NORMAL_PRIORITY;
		}

		String sourceFile = javaClass.getSourceFileName();
		bugReporter.reportBug(new BugInstance(this, bugType, priority)
		        .addClassAndMethod(methodGen, sourceFile)
		        .addSourceLine(methodGen, sourceFile, resource.getLocation().getHandle()));
	}
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:24,代碼來源:FindUnreleasedLock.java

示例8: reportMatch

import org.apache.bcel.classfile.JavaClass; //導入依賴的package包/類
public void reportMatch(ClassContext classContext, Method method, ByteCodePatternMatch match) {
	MethodGen methodGen = classContext.getMethodGen(method);
	JavaClass javaClass = classContext.getJavaClass();

	BindingSet bindingSet = match.getBindingSet();

	// Note that the lookup of "h" cannot fail, and
	// it is guaranteed to be bound to a FieldVariable.
	Binding binding = bindingSet.lookup("h");
	FieldVariable field = (FieldVariable) binding.getVariable();

	// Ignore fields generated for accesses to Foo.class
	if (field.getFieldName().startsWith("class$"))
		return;

	// Find start and end instructions (for reporting source lines)
	InstructionHandle start = match.getLabeledInstruction("startDC");
	InstructionHandle end = match.getLabeledInstruction("endDC");

	String sourceFile = javaClass.getSourceFileName();
	bugReporter.reportBug(new BugInstance(this, "BCPDC_DOUBLECHECK", NORMAL_PRIORITY)
	        .addClassAndMethod(methodGen, sourceFile)
	        .addField(field).describe("FIELD_ON")
	        .addSourceLine(methodGen, sourceFile, start, end));
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:26,代碼來源:BCPDoubleCheck.java

示例9: visitClassContext

import org.apache.bcel.classfile.JavaClass; //導入依賴的package包/類
@Override
public void visitClassContext(ClassContext classContext) {
    JavaClass javaClass = classContext.getJavaClass();
    
    //The class extends WebChromeClient
    boolean isWebChromeClient = InterfaceUtils.isSubtype(javaClass, "android.webkit.WebChromeClient");
    
    //Not the target of this detector
    if (!isWebChromeClient) {
        return;
    }
    Method[] methodList = javaClass.getMethods();
    for (Method m : methodList) {
        if (DEBUG) {
            System.out.println(">>> Method: " + m.getName());
        }
        //The presence of onGeolocationPermissionsShowPrompt is not enforce for the moment
        if (!m.getName().equals("onGeolocationPermissionsShowPrompt")) {
            continue;
        }
        //Since the logic implemented need to be analyze by a human, all implementation will be flagged.
        bugReporter.reportBug(new BugInstance(this, ANDROID_GEOLOCATION_TYPE, Priorities.NORMAL_PRIORITY) //
                .addClassAndMethod(javaClass, m));
    }
}
 
開發者ID:blackarbiter,項目名稱:Android_Code_Arbiter,代碼行數:26,代碼來源:GeolocationDetector.java

示例10: getJavaClass

import org.apache.bcel.classfile.JavaClass; //導入依賴的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

示例11: analyzeField

import org.apache.bcel.classfile.JavaClass; //導入依賴的package包/類
private void analyzeField(Field field, JavaClass javaClass) {
    for (AnnotationEntry annotation : field.getAnnotationEntries())  {
        if (ANNOTATION_TYPES.contains(annotation.getAnnotationType()) ||
                annotation.getAnnotationType().contains("JsonTypeInfo")) {
            for (ElementValuePair elementValuePair : annotation.getElementValuePairs()) {
                if ("use".equals((elementValuePair.getNameString())) &&
                        VULNERABLE_USE_NAMES.contains(elementValuePair.getValue().stringifyValue())) {
                    bugReporter.reportBug(new BugInstance(this, DESERIALIZATION_TYPE, HIGH_PRIORITY)
                            .addClass(javaClass)
                            .addString(javaClass.getClassName() + " on field " +
                                    field.getName() + " of type " + field.getType() +
                                    " annotated with " + annotation.toShortString())
                            .addField(FieldAnnotation.fromBCELField(javaClass, field))
                            .addString("")
                    );
                }
            }
        }
    }
}
 
開發者ID:blackarbiter,項目名稱:Android_Code_Arbiter,代碼行數:21,代碼來源:UnsafeJacksonDeserializationDetector.java

示例12: apply

import org.apache.bcel.classfile.JavaClass; //導入依賴的package包/類
@Override
public final void apply(final ClassPath classPath, final ClassNames classNames, final Path workingDirectory) {
    final String cpString = classPath.paths()
        .map(Object::toString)
        .reduce((s1, s2) -> s1 + ":" + s2);

    final ClassPathRepository classPathRepository = new ClassPathRepository(
        new org.apache.bcel.util.ClassPath(
            cpString
        )
    );

    try {
        for (String className : classNames.classNames()) {
            final JavaClass javaClass = classPathRepository.loadClass(className);
            final ClassGen classGen = new ClassGen(javaClass);
            plugin.operateOn(classGen,javaClass, classPathRepository);
        }
    } catch(Exception ex) {
        throw new RuntimeException(ex);
    }
}
 
開發者ID:project-avral,項目名稱:oo-atom,代碼行數:23,代碼來源:BcelStage.java

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

示例14: resolveClass

import org.apache.bcel.classfile.JavaClass; //導入依賴的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

示例15: visitClassContext

import org.apache.bcel.classfile.JavaClass; //導入依賴的package包/類
@Override
public void visitClassContext(ClassContext classContext) {
    JavaClass javaClass = classContext.getJavaClass();
    if (OBJECT_MAPPER_CLASSES.contains(javaClass.getClassName())) {
        return;
    }
    for (Field field : javaClass.getFields()) {
        analyzeField(field, javaClass);
    }
    for (Method m : javaClass.getMethods()) {
        try {
            analyzeMethod(m, classContext);
        }
        catch (CFGBuilderException | DataflowAnalysisException e) {
        }
    }
}
 
開發者ID:blackarbiter,項目名稱:Android_Code_Arbiter,代碼行數:18,代碼來源:UnsafeJacksonDeserializationDetector.java


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