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


Java Method类代码示例

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


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

示例1: hasCustomReadObject

import org.apache.bcel.classfile.Method; //导入依赖的package包/类
/**
 * Check if the readObject is doing multiple external call beyond the basic readByte, readBoolean, etc..
 * @param m
 * @param classContext
 * @return
 * @throws CFGBuilderException
 * @throws DataflowAnalysisException
 */
private boolean hasCustomReadObject(Method m, ClassContext classContext,List<String> classesToIgnore)
        throws CFGBuilderException, DataflowAnalysisException {
    ConstantPoolGen cpg = classContext.getConstantPoolGen();
    CFG cfg = classContext.getCFG(m);
    int count = 0;
    for (Iterator<Location> i = cfg.locationIterator(); i.hasNext(); ) {
        Location location = i.next();
        Instruction inst = location.getHandle().getInstruction();
        //ByteCode.printOpCode(inst,cpg);
        if(inst instanceof InvokeInstruction) {
            InvokeInstruction invoke = (InvokeInstruction) inst;
            if (!READ_DESERIALIZATION_METHODS.contains(invoke.getMethodName(cpg))
                    && !classesToIgnore.contains(invoke.getClassName(cpg))) {
                count +=1;
            }
        }
    }
    return count > 3;
}
 
开发者ID:blackarbiter,项目名称:Android_Code_Arbiter,代码行数:28,代码来源:DeserializationGadgetDetector.java

示例2: analyzeMethod

import org.apache.bcel.classfile.Method; //导入依赖的package包/类
protected void analyzeMethod(ClassContext classContext, Method method)
        throws CheckedAnalysisException {
    TaintDataflow dataflow = getTaintDataFlow(classContext, method);
    ConstantPoolGen cpg = classContext.getConstantPoolGen();
    String currentMethod = getFullMethodName(classContext.getMethodGen(method));
    for (Iterator<Location> i = getLocationIterator(classContext, method); i.hasNext();) {
        Location location = i.next();
        InstructionHandle handle = location.getHandle();
        Instruction instruction = handle.getInstruction();
        if (!(instruction instanceof InvokeInstruction)) {
            continue;
        }
        InvokeInstruction invoke = (InvokeInstruction) instruction;
        TaintFrame fact = dataflow.getFactAtLocation(location);
        assert fact != null;
        if (!fact.isValid()) {
            continue;
        }
        analyzeLocation(classContext, method, handle, cpg, invoke, fact, currentMethod);
    }
}
 
开发者ID:blackarbiter,项目名称:Android_Code_Arbiter,代码行数:22,代码来源:AbstractTaintDetector.java

示例3: main

import org.apache.bcel.classfile.Method; //导入依赖的package包/类
/**
 * Command line driver, for testing.
 */
public static void main(String[] argv) throws Exception {
	if (argv.length != 1) {
		System.out.println("Usage: " + StackDepthAnalysis.class.getName() + " <class file>");
		System.exit(1);
	}

	DataflowTestDriver<StackDepth, StackDepthAnalysis> driver = new DataflowTestDriver<StackDepth, StackDepthAnalysis>() {
		public Dataflow<StackDepth, StackDepthAnalysis> createDataflow(ClassContext classContext, Method method)
		        throws CFGBuilderException, DataflowAnalysisException {

			DepthFirstSearch dfs = classContext.getDepthFirstSearch(method);
			CFG cfg = classContext.getCFG(method);

			StackDepthAnalysis analysis = new StackDepthAnalysis(classContext.getConstantPoolGen(), dfs);
			Dataflow<StackDepth, StackDepthAnalysis> dataflow = new Dataflow<StackDepth, StackDepthAnalysis>(cfg, analysis);
			dataflow.execute();

			return dataflow;
		}
	};

	driver.execute(argv[0]);
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:27,代码来源:StackDepthAnalysis.java

示例4: main

import org.apache.bcel.classfile.Method; //导入依赖的package包/类
public static void main(String[] argv) throws Exception {
	if (argv.length != 1) {
		System.err.println("Usage: " + ReturnPathAnalysis.class.getName() + " <classfile>");
		System.exit(1);
	}

	DataflowTestDriver<ReturnPath, ReturnPathAnalysis> driver = new DataflowTestDriver<ReturnPath, ReturnPathAnalysis>() {
		public Dataflow<ReturnPath, ReturnPathAnalysis>
		        createDataflow(ClassContext classContext, Method method)
		        throws CFGBuilderException, DataflowAnalysisException {
			return classContext.getReturnPathDataflow(method);
		}
	};

	driver.execute(argv[0]);
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:17,代码来源:ReturnPathAnalysis.java

示例5: visit

import org.apache.bcel.classfile.Method; //导入依赖的package包/类
public void visit(Method obj) {
	if (!validClass)
		return;
	validMethod = false;
	methodName = obj.getName();
	if (methodName.equals("setUp") || methodName.equals("tearDown")) {
		if (methodName.equals("setUp"))
			setUpAnnotation = MethodAnnotation.fromVisitedMethod(this);
		else if (methodName.equals("tearDown"))
			tearDownAnnotation = MethodAnnotation.fromVisitedMethod(this);
		validMethod = true;
		state = SEEN_NOTHING;
		super.visit(obj);
	} else if (methodName.equals("suite") && !obj.isStatic())
		bugReporter.reportBug(new BugInstance(this, "IJU_SUITE_NOT_STATIC", NORMAL_PRIORITY)
		        .addClass(this)
		        .addMethod(MethodAnnotation.fromVisitedMethod(this)));
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:19,代码来源:InvalidJUnitTest.java

示例6: main

import org.apache.bcel.classfile.Method; //导入依赖的package包/类
public static void main(String[] argv) throws Exception {
	if (argv.length != 3) {
		System.err.println("Usage: " + FindUnreleasedLock.class.getName() + " <class file> <method name> <bytecode offset>");
		System.exit(1);
	}

	String classFile = argv[0];
	String methodName = argv[1];
	int offset = Integer.parseInt(argv[2]);

	ResourceValueAnalysisTestDriver<Lock, LockResourceTracker> driver =
	        new ResourceValueAnalysisTestDriver<Lock, LockResourceTracker>() {
		        public LockResourceTracker createResourceTracker(ClassContext classContext, Method method)
		                throws CFGBuilderException, DataflowAnalysisException {

			        ValueNumberDataflow vnaDataflow = classContext.getValueNumberDataflow(method);
			        RepositoryLookupFailureCallback lookupFailureCallback = classContext.getLookupFailureCallback();

			        return new LockResourceTracker(lookupFailureCallback, vnaDataflow);
		        }
	        };

	driver.execute(classFile, methodName, offset);
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:25,代码来源:FindUnreleasedLock.java

示例7: visit

import org.apache.bcel.classfile.Method; //导入依赖的package包/类
public void visit(Method obj) {
	if (isAdapter) {
		String methodName = obj.getName();
		String signature = methodMap.get(methodName);
		if (!methodName.equals("<init>") && signature != null) {
			if (!signature.equals(obj.getSignature())) {
				if (!badOverrideMap.keySet().contains(methodName)) {
					badOverrideMap.put(methodName, new BugInstance(this, "BOA_BADLY_OVERRIDDEN_ADAPTER", NORMAL_PRIORITY)
							.addClassAndMethod(this)
							.addSourceLine(this));
				}
			}
			else {
				badOverrideMap.put(methodName, null);
			}
		}
	}
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:19,代码来源:BadlyOverriddenAdapter.java

示例8: reportMatch

import org.apache.bcel.classfile.Method; //导入依赖的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.Method; //导入依赖的package包/类
@Override
public void visitClassContext(ClassContext classContext) {
    JavaClass javaClass = classContext.getJavaClass();

    //The class extends HttpServletRequestWrapper
    boolean isRequestWrapper = InterfaceUtils.isSubtype(javaClass, "javax.servlet.http.HttpServletRequestWrapper");

    //Not the target of this detector
    if (!isRequestWrapper) return;

    Method[] methodList = javaClass.getMethods();

    for (Method m : methodList) {
        if (m.getName().equals("stripXSS")) {
            bugReporter.reportBug(new BugInstance(this, XSS_REQUEST_WRAPPER_TYPE, Priorities.NORMAL_PRIORITY) //
                    .addClassAndMethod(javaClass, m));
            return;
        }
    }

}
 
开发者ID:blackarbiter,项目名称:Android_Code_Arbiter,代码行数:22,代码来源:XSSRequestWrapperDetector.java

示例10: main

import org.apache.bcel.classfile.Method; //导入依赖的package包/类
public static void main(String[] argv) throws Exception {
	if (argv.length != 3) {
		System.err.println("Usage: " + FindOpenStream.class.getName() +
		        " <class file> <method name> <bytecode offset>");
		System.exit(1);
	}

	String classFile = argv[0];
	String methodName = argv[1];
	int offset = Integer.parseInt(argv[2]);

	ResourceValueAnalysisTestDriver<Stream, StreamResourceTracker> driver =
	        new ResourceValueAnalysisTestDriver<Stream, StreamResourceTracker>() {
		        public StreamResourceTracker createResourceTracker(ClassContext classContext, Method method) {
			        return new StreamResourceTracker(streamFactoryList, classContext.getLookupFailureCallback());
		        }
	        };

	driver.execute(classFile, methodName, offset);
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:21,代码来源:FindOpenStream.java

示例11: analyzeMethod

import org.apache.bcel.classfile.Method; //导入依赖的package包/类
private void analyzeMethod(Method m, ClassContext classContext) throws CFGBuilderException, DataflowAnalysisException {

        ConstantPoolGen cpg = classContext.getConstantPoolGen();
        CFG cfg = classContext.getCFG(m);
        
        for (Iterator<Location> i = cfg.locationIterator(); i.hasNext(); ) {
            Location location = i.next();

            Instruction inst = location.getHandle().getInstruction();
            
            if (inst instanceof LDC) {
                LDC ldc = (LDC) inst;
                if (ldc != null) {
                    if("java.naming.security.authentication".equals(ldc.getValue(cpg)) &&
                       "none".equals(ByteCode.getConstantLDC(location.getHandle().getNext(), cpg, String.class))){
                        JavaClass clz = classContext.getJavaClass();
                        bugReporter.reportBug(new BugInstance(this, LDAP_ANONYMOUS, Priorities.LOW_PRIORITY) //
                        .addClass(clz)
                        .addMethod(clz, m)
                        .addSourceLine(classContext, m, location));
                        break;
                    }
                }
            }            
        }
    }
 
开发者ID:blackarbiter,项目名称:Android_Code_Arbiter,代码行数:27,代码来源:AnonymousLdapDetector.java

示例12: buildResourceCollection

import org.apache.bcel.classfile.Method; //导入依赖的package包/类
private ResourceCollection<Resource> buildResourceCollection(ClassContext classContext,
                                                             Method method, ResourceTrackerType resourceTracker)
        throws CFGBuilderException, DataflowAnalysisException {

	ResourceCollection<Resource> resourceCollection = new ResourceCollection<Resource>();

	CFG cfg = classContext.getCFG(method);
	ConstantPoolGen cpg = classContext.getConstantPoolGen();

	for (Iterator<Location> i = cfg.locationIterator(); i.hasNext();) {
		Location location = i.next();
		Resource resource = resourceTracker.isResourceCreation(location.getBasicBlock(),
		        location.getHandle(), cpg);
		if (resource != null)
			resourceCollection.addCreatedResource(location, resource);
	}

	return resourceCollection;
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:20,代码来源:ResourceTrackingDetector.java

示例13: leaveSet

import org.apache.bcel.classfile.Method; //导入依赖的package包/类
/** @see com.puppycrawl.tools.checkstyle.bcel.IObjectSetVisitor */
public void leaveSet(Set aJavaClasses)
{
    final Iterator it = aJavaClasses.iterator();
    while (it.hasNext()) {
        final JavaClass javaClass = (JavaClass) it.next();
        final String className = javaClass.getClassName();
        final JavaClassDefinition classDef = findJavaClassDef(javaClass);
        final MethodDefinition[] methodDefs = classDef.getMethodDefs();
        for (int i = 0; i < methodDefs.length; i++) {
            if (!classDef.hasReference(methodDefs[i], getReferenceDAO())) {
                final Method method = methodDefs[i].getMethod();
                if (!ignore(className, method)) {
                    log(
                        javaClass,
                        0,
                        "unused.method",
                        new Object[] {methodDefs[i]});
                }
            }
        }
    }
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:24,代码来源:UnusedMethodCheck.java

示例14: visitClassContext

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

示例15: build

import org.apache.bcel.classfile.Method; //导入依赖的package包/类
public void build() throws ClassNotFoundException {
	JavaClass jclass = classContext.getJavaClass();

	// Build a set of all fields that could be assigned
	// by methods in this class
	HashSet<XField> assignableFieldSet = new HashSet<XField>();
	scanFields(jclass, assignableFieldSet);
	JavaClass[] superClassList = jclass.getSuperClasses();
	if (superClassList != null) {
		for (int i = 0; i < superClassList.length; ++i) {
			scanFields(superClassList[i], assignableFieldSet);
		}
	}

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

		scanMethod(method, assignableFieldSet);
	}
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:25,代码来源:AssignedFieldMap.java


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