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


Java Method.isPublic方法代码示例

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


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

示例1: analyzeMethod

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

	boolean sawCallToEquals = false;
	JavaClass jclass = classContext.getJavaClass();
	ConstantPoolGen cpg = classContext.getConstantPoolGen();
	MethodGen methodGen = classContext.getMethodGen(method);

	// Report at most one String comparison per method.
	// We report the first highest priority warning.
	stringComparison = null;
	refComparison = null;

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

	// Perform type analysis using our special type merger
	// (which handles String types specially, keeping track of
	// which ones appear to be dynamically created)
	RefComparisonTypeMerger typeMerger =
	        new RefComparisonTypeMerger(bugReporter, exceptionSetFactory);
	TypeFrameModelingVisitor visitor =
	        new RefComparisonTypeFrameModelingVisitor(methodGen.getConstantPool(), bugReporter);
	TypeAnalysis typeAnalysis =
	        new TypeAnalysis(methodGen, cfg, dfs, typeMerger, visitor, bugReporter, exceptionSetFactory);
	TypeDataflow typeDataflow = new TypeDataflow(cfg, typeAnalysis);
	typeDataflow.execute();

	for (Iterator<Location> i = cfg.locationIterator(); i.hasNext();) {
		Location location = i.next();

		Instruction ins = location.getHandle().getInstruction();
		short opcode = ins.getOpcode();
		if (opcode == Constants.IF_ACMPEQ || opcode == Constants.IF_ACMPNE) {
			checkRefComparison(location, jclass, methodGen, typeDataflow);
		} else if (invokeInstanceSet.get(opcode)) {
			InvokeInstruction inv = (InvokeInstruction) ins;
			String methodName = inv.getMethodName(cpg);
			String methodSig = inv.getSignature(cpg);
			if ((methodName.equals("equals") && methodSig.equals("(Ljava/lang/Object;)Z"))
			        || (methodName.equals("equalIgnoreCases") && methodSig.equals("(Ljava/lang/String;)Z"))) {
				sawCallToEquals = true;
				checkEqualsComparison(location, jclass, methodGen, typeDataflow);
			}
		}
	}

	// If a String reference comparison was found in the method,
	// report it
	if (stringComparison != null) {
		if (sawCallToEquals &&
		        stringComparison.getPriority() >= NORMAL_PRIORITY) {
			// System.out.println("Reducing priority of " + stringComparison);
			stringComparison.setPriority(1 + stringComparison.getPriority());
		}
		if (stringComparison.getPriority() >= NORMAL_PRIORITY
		        && !(method.isPublic() ||
		        method.isProtected())) {
			// System.out.print("private/packed");
			stringComparison.setPriority(1 + stringComparison.getPriority());
		}
		if (stringComparison.getPriority() <= LOW_PRIORITY) {
			bugReporter.reportBug(stringComparison);
		}
	}
	if (refComparison != null) {
		if (false && sawCallToEquals) {
			// System.out.println("Reducing priority of " + refComparison);
			refComparison.setPriority(1 + refComparison.getPriority());
		}
		if (refComparison.getPriority() <= LOW_PRIORITY)
			bugReporter.reportBug(refComparison);
	}
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:77,代码来源:FindRefComparison.java


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