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


Java JavaClass.getMethods方法代碼示例

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


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

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

示例2: visitClassContext

import org.apache.bcel.classfile.JavaClass; //導入方法依賴的package包/類
@Override
public void visitClassContext(ClassContext classContext) {
    JavaClass javaClass = classContext.getJavaClass();
    for (Method m : javaClass.getMethods()) {

        for (AnnotationEntry ae : m.getAnnotationEntries()) {

            //Every method mark with @javax.jws.WebMethod is mark as an Endpoint
            if (ae.getAnnotationType().equals("Ljavax/jws/WebMethod;")) {
                bugReporter.reportBug(new BugInstance(this, JAXWS_ENDPOINT_TYPE, Priorities.LOW_PRIORITY) //
                        .addClassAndMethod(javaClass, m));
            }
        }
    }
}
 
開發者ID:blackarbiter,項目名稱:Android_Code_Arbiter,代碼行數:16,代碼來源:JaxWsEndpointDetector.java

示例3: visit

import org.apache.bcel.classfile.JavaClass; //導入方法依賴的package包/類
@Override
public void visit(JavaClass javaClass) {
    staticInitializerSeen = false;
    Method[] methods = javaClass.getMethods();
    for (Method method : methods) {
        if (method.getName().equals(STATIC_INITIALIZER_NAME)) {
            // check field initialization before visiting methods
            doVisitMethod(method);
            staticInitializerSeen = true;
            break;
        }
    }
    isFirstArrayStore = false;
    wasToConstArrayConversion = false;
}
 
開發者ID:blackarbiter,項目名稱:Android_Code_Arbiter,代碼行數:16,代碼來源:ConstantPasswordDetector.java

示例4: visitClassContext

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

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

		analyzeMethod(classContext, method);
	}
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:13,代碼來源:FindJSR166LockMonitorenter.java

示例5: visitClassContext

import org.apache.bcel.classfile.JavaClass; //導入方法依賴的package包/類
@Override
public void visitClassContext(ClassContext classContext) {
    JavaClass javaClass = classContext.getJavaClass();
    method : for (Method m : javaClass.getMethods()) {

        for (AnnotationEntry ae : m.getAnnotationEntries()) {

            if (REQUEST_MAPPING_ANNOTATION_TYPES.contains(ae.getAnnotationType())) {
                bugReporter.reportBug(new BugInstance(this, SPRING_ENDPOINT_TYPE, Priorities.LOW_PRIORITY) //
                        .addClassAndMethod(javaClass, m));
                continue method;
            }
        }
    }
}
 
開發者ID:blackarbiter,項目名稱:Android_Code_Arbiter,代碼行數:16,代碼來源:SpringMvcEndpointDetector.java

示例6: findMethod

import org.apache.bcel.classfile.JavaClass; //導入方法依賴的package包/類
Method findMethod(JavaClass clazz, String name, String sig) {
	Method[] m = clazz.getMethods();
	for (int i = 0; i < m.length; i++)
		if (m[i].getName().equals(name)
		        && m[i].getSignature().equals(sig))
			return m[i];
	return null;
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:9,代碼來源:FindHEmismatch.java

示例7: visitClassContext

import org.apache.bcel.classfile.JavaClass; //導入方法依賴的package包/類
@Override
public void visitClassContext(ClassContext classContext) {
    JavaClass javaClass = classContext.getJavaClass();
    for (Method m : javaClass.getMethods()) {

        for (AnnotationEntry ae : m.getAnnotationEntries()) {

            //Every method mark with @javax.ws.rs.Path is mark as an Endpoint
            if (ae.getAnnotationType().equals("Ljavax/ws/rs/Path;")) {
                bugReporter.reportBug(new BugInstance(this, JAXRS_ENDPOINT_TYPE, Priorities.LOW_PRIORITY) //
                        .addClassAndMethod(javaClass, m));
            }
        }
    }
}
 
開發者ID:blackarbiter,項目名稱:Android_Code_Arbiter,代碼行數:16,代碼來源:JaxRsEndpointDetector.java

示例8: findMethod

import org.apache.bcel.classfile.JavaClass; //導入方法依賴的package包/類
/**
 * Find a method in given class.
 *
 * @param javaClass  the class
 * @param methodName the name of the method
 * @param methodSig  the signature of the method
 * @return the Method, or null if no such method exists in the class
 */
public static Method findMethod(JavaClass javaClass, String methodName, String methodSig) {
	Method[] methodList = javaClass.getMethods();
	for (int i = 0; i < methodList.length; ++i) {
		Method method = methodList[i];
		if (method.getName().equals(methodName) && method.getSignature().equals(methodSig))
			return method;
	}

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

示例9: main

import org.apache.bcel.classfile.JavaClass; //導入方法依賴的package包/類
/**
 * Test driver.
 */
public static void main(String[] argv) throws Exception {
	if (argv.length != 1) {
		System.err.println("Usage: " + BetterCFGBuilder2.class.getName() + " <class file>");
		System.exit(1);
	}

	String methodName = System.getProperty("cfgbuilder.method");

	JavaClass jclass = new ClassParser(argv[0]).parse();
	ClassGen classGen = new ClassGen(jclass);

	Method[] methodList = jclass.getMethods();
	for (int i = 0; i < methodList.length; ++i) {
		Method method = methodList[i];

		if (method.isAbstract() || method.isNative())
			continue;

		if (methodName != null && !method.getName().equals(methodName))
			continue;

		MethodGen methodGen = new MethodGen(method, jclass.getClassName(), classGen.getConstantPool());

		CFGBuilder cfgBuilder = new BetterCFGBuilder2(methodGen);
		cfgBuilder.build();

		CFG cfg = cfgBuilder.getCFG();

		CFGPrinter cfgPrinter = new CFGPrinter(cfg);
		System.out.println("---------------------------------------------------------------------");
		System.out.println("Method: " + SignatureConverter.convertMethodSignature(methodGen));
		System.out.println("---------------------------------------------------------------------");
		cfgPrinter.print(System.out);
	}
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:39,代碼來源:BetterCFGBuilder2.java

示例10: visitClassContext

import org.apache.bcel.classfile.JavaClass; //導入方法依賴的package包/類
@Override
public void visitClassContext(ClassContext classContext) {
    JavaClass javaClass = classContext.getJavaClass();
    Method[] methodList = javaClass.getMethods();
    for (Method m : methodList) {
        try {
            analyzeMethod(m, classContext);
        } catch (CFGBuilderException | DataflowAnalysisException e) {
            AnalysisContext.logError("Cannot analyze method", e);
        }
    }
}
 
開發者ID:blackarbiter,項目名稱:Android_Code_Arbiter,代碼行數:13,代碼來源:StaticIvDetector.java

示例11: JavaClassDefinition

import org.apache.bcel.classfile.JavaClass; //導入方法依賴的package包/類
/**
 * Creates a JavaClassDefinition from a JavaClass. The fields and
 * methods of the JavaClassDefinition are those whose scopes are
 * in restricted sets of Scopes.
 * @param aJavaClass the JavaClass for the definition.
 * @param aFieldScopes the restricted set of field scopes.
 * @param aMethodScopes the restriced set of method scopes.
 */
public JavaClassDefinition(
    JavaClass aJavaClass,
    Set aFieldScopes,
    Set aMethodScopes)
{
    mJavaClass = aJavaClass;

    // create method definitions, restricted by scope
    final Method[] methods = aJavaClass.getMethods();
    final Set methodSet = new HashSet();
    mMethodDefs = new MethodDefinition[methods.length];
    for (int i = 0; i < methods.length; i++) {
        if (Utils.inScope(methods[i], aMethodScopes)) {
            methodSet.add(new MethodDefinition(methods[i]));
        }
    }
    mMethodDefs =
        (MethodDefinition[]) methodSet.toArray(
            new MethodDefinition[methodSet.size()]);

    // create field definitions, restricted by scope
    final Field[] fields = aJavaClass.getFields();
    mFieldDefs = new HashMap(fields.length);
    for (int i = 0; i < fields.length; i++) {
        if (Utils.inScope(fields[i], aFieldScopes)) {
            mFieldDefs.put(
                fields[i].getName(),
                new FieldDefinition(fields[i]));
        }
    }
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:40,代碼來源:JavaClassDefinition.java

示例12: visitClassContext

import org.apache.bcel.classfile.JavaClass; //導入方法依賴的package包/類
@Override
public void visitClassContext(ClassContext classContext) {
    JavaClass clazz = classContext.getJavaClass();

    if (hasRequestMapping(clazz)) {
        Method[] methods = clazz.getMethods();
        for (Method m: methods) {

            try {
                analyzeMethod(m, classContext);
            } catch (CFGBuilderException e){
            }
        }
    }
}
 
開發者ID:blackarbiter,項目名稱:Android_Code_Arbiter,代碼行數:16,代碼來源:SpringUnvalidatedRedirectDetector.java

示例13: hasRequestMapping

import org.apache.bcel.classfile.JavaClass; //導入方法依賴的package包/類
private boolean hasRequestMapping(JavaClass clazz) {
    Method[] methods = clazz.getMethods();
    for (Method m: methods) {
        AnnotationEntry[] annotations = m.getAnnotationEntries();

        for (AnnotationEntry ae: annotations) {
            if (REQUEST_MAPPING_ANNOTATION_TYPES.contains(ae.getAnnotationType())) {
                return true;
            }
        }
    }
    return false;
}
 
開發者ID:blackarbiter,項目名稱:Android_Code_Arbiter,代碼行數:14,代碼來源:SpringUnvalidatedRedirectDetector.java

示例14: visitClassContext

import org.apache.bcel.classfile.JavaClass; //導入方法依賴的package包/類
@Override
public void visitClassContext(ClassContext classContext) {
    JavaClass javaClass = classContext.getJavaClass();

    boolean isActionForm = InterfaceUtils.isSubtype(javaClass, "org.apache.struts.action.ActionForm");
    boolean isValidatorForm = InterfaceUtils.isSubtype(javaClass, "org.apache.struts.validator.ValidatorForm");
    boolean isDynaValidatorForm = InterfaceUtils.isSubtype(javaClass, "org.apache.struts.validator.DynaValidatorForm");

    if (isActionForm && !(isValidatorForm || isDynaValidatorForm)) {
        bugReporter.reportBug(new BugInstance(this, STRUTS_FORM_VALIDATION_TYPE, Priorities.NORMAL_PRIORITY) //
                .addClass(javaClass) //
                .addString("ActionForm"));
        return;
    }

    if (!isValidatorForm && !isDynaValidatorForm) return; //Not form implementation

    final String expectedSig = "(Lorg/apache/struts/action/ActionMapping;Ljavax/servlet/http/HttpServletRequest;)Lorg/apache/struts/action/ActionErrors;";
    boolean validateMethodFound = false;
    for (Method m : javaClass.getMethods()) {

        if ("validate".equals(m.getName()) && expectedSig.equals(m.getSignature())) {
            validateMethodFound = true;
        }
    }

    //ValidatorForm without a validate method is just like a regular ActionForm
    if (!validateMethodFound) {
        bugReporter.reportBug(new BugInstance(this, STRUTS_FORM_VALIDATION_TYPE, Priorities.LOW_PRIORITY) //
                .addClass(javaClass) //
                .addString("ValidatorForm"));
    }
}
 
開發者ID:blackarbiter,項目名稱:Android_Code_Arbiter,代碼行數:34,代碼來源:StrutsValidatorFormDetector.java

示例15: visitClassContext

import org.apache.bcel.classfile.JavaClass; //導入方法依賴的package包/類
@Override
public void visitClassContext(ClassContext classContext) {
    JavaClass javaClass = classContext.getJavaClass();

    Method[] methodList = javaClass.getMethods();

    for (Method m : methodList) {
        try {
            analyzeMethod(m,classContext);
        } catch (CFGBuilderException e) {
        }
    }
}
 
開發者ID:blackarbiter,項目名稱:Android_Code_Arbiter,代碼行數:14,代碼來源:CookieFlagsDetector.java


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