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


Java Method.isPrivate方法代码示例

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


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

示例1: visitMethod

import org.apache.bcel.classfile.Method; //导入方法依赖的package包/类
public void visitMethod(Method obj) {
	super.visitMethod(obj);
	if (obj.isPrivate()
	        && !getMethodName().equals("writeReplace")
	        && !getMethodName().equals("readResolve")
	        && !getMethodName().equals("readObject")
	        && !getMethodName().equals("readObjectNoData")
	        && !getMethodName().equals("writeObject")
	        && getMethodName().indexOf("debug") == -1
	        && getMethodName().indexOf("Debug") == -1
	        && getMethodName().indexOf("trace") == -1
	        && getMethodName().indexOf("Trace") == -1
	        && !getMethodName().equals("<init>")
	        && !getMethodName().equals("<clinit>")
	)
		definedPrivateMethods.add(MethodAnnotation.fromVisitedMethod(this));
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:18,代码来源:FindUncalledPrivateMethods.java

示例2: execute

import org.apache.bcel.classfile.Method; //导入方法依赖的package包/类
public void execute() throws CFGBuilderException, DataflowAnalysisException {
	if (CONSERVE_SPACE) throw new IllegalStateException("This should not happen");

	HashSet<Edge> deletedEdgeSet = new HashSet<Edge>();

	if (DEBUG)
		System.out.println("PruneUnconditionalExceptionThrowerEdges: examining " +
		        SignatureConverter.convertMethodSignature(methodGen));

	for (Iterator<BasicBlock> i = cfg.blockIterator(); i.hasNext();) {
		BasicBlock basicBlock = i.next();
		if (!basicBlock.isExceptionThrower())
			continue;

		Instruction exceptionThrower = basicBlock.getExceptionThrower().getInstruction();
		if (!(exceptionThrower instanceof InvokeInstruction))
			continue;

		InvokeInstruction inv = (InvokeInstruction) exceptionThrower;
		try {
			String className = inv.getClassName(cpg);
			if (className.startsWith("["))
				continue;
			JavaClass javaClass = Repository.lookupClass(className);
			ClassContext classContext = analysisContext.getClassContext(javaClass);

			if (DEBUG) System.out.println("\tlooking up method for " + basicBlock.getExceptionThrower());
			Method method = Hierarchy.findExactMethod(inv, cpg);
			if (method == null) {
				if (DEBUG) System.out.println("\tNOT FOUND");
				continue;
			}
			if (DEBUG) System.out.println("\tFound " + method.toString());

			// FIXME: for now, only allow static and private methods.
			// Could also allow final methods (but would require class hierarchy
			// search).
			if (!(method.isStatic() || method.isPrivate()))
				continue;

			// Ignore abstract and native methods
			MethodGen calledMethodGen = classContext.getMethodGen(method);
			if (calledMethodGen == null)
				continue;

			// Analyze exception paths of called method
			// to see if it always throws an unhandled exception.
			CFG calledCFG = classContext.getCFG(method);
			ReturnPathDataflow pathDataflow = classContext.getReturnPathDataflow(method);
			ReturnPath pathValue = pathDataflow.getStartFact(calledCFG.getExit());

			if (pathValue.getKind() != ReturnPath.RETURNS) {
				// Method always throws an unhandled exception
				// or calls System.exit().
				// Remove the normal control flow edge from the CFG.
				Edge fallThrough = cfg.getOutgoingEdgeWithType(basicBlock, FALL_THROUGH_EDGE);
				if (fallThrough != null) {
					if (DEBUG) {
						System.out.println("\tREMOVING normal return for:");
						System.out.println("\t  Call to " + SignatureConverter.convertMethodSignature(calledMethodGen));
						System.out.println("\t  In method " + SignatureConverter.convertMethodSignature(methodGen));
					}
					deletedEdgeSet.add(fallThrough);
				}
			}
		} catch (ClassNotFoundException e) {
			analysisContext.getLookupFailureCallback().reportMissingClass(e);
		}
	}

	// Remove all edges marked for deletion
	for (Iterator<Edge> i = deletedEdgeSet.iterator(); i.hasNext();) {
		Edge edge = i.next();
		cfg.removeEdge(edge);
	}
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:77,代码来源:PruneUnconditionalExceptionThrowerEdges.java

示例3: visitObject

import org.apache.bcel.classfile.Method; //导入方法依赖的package包/类
/** @see com.puppycrawl.tools.checkstyle.bcel.IObjectSetVisitor */
public void visitObject(Object aJavaClass)
{
    final JavaClass javaClass = (JavaClass) aJavaClass;
    final String className = javaClass.getClassName();
    final JavaClass[] superClasses = javaClass.getSuperClasses();
    final Method[] methods = javaClass.getMethods();
    // Check all methods
    for (int i = 0; i < methods.length; i++) {
        final Method method = methods[i];
        // Check that the method is a possible match
        if (!method.isPrivate() && method.isStatic())  {
            // Go through all their superclasses
            for (int j = 0; j < superClasses.length; j++) {
                final JavaClass superClass = superClasses[j];
                final String superClassName = superClass.getClassName();
                final Method[] superClassMethods = superClass.getMethods();
                // Go through the methods of the superclasses
                for (int k = 0; k < superClassMethods.length; k++) {
                    final Method superClassMethod = superClassMethods[k];
                    if (superClassMethod.getName().equals(method.getName()) &&
                        !ignore(className, method)) {
                        Type[] methodTypes = method.getArgumentTypes();
                        Type[] superTypes = superClassMethod.
                            getArgumentTypes();
                        if (methodTypes.length == superTypes.length) {
                            boolean match = true;
                            for (int arg = 0; arg < methodTypes.length; arg++) {
                                if (!methodTypes[arg].equals(superTypes[arg])) {
                                    match = false;
                                }
                            }
                            // Same method parameters
                            if (match) {
                                log(
                                    javaClass,
                                    0,
                                    "hidden.static.method",
                                    new Object[] {method, superClassName});
                            }
                        }
                    }
                }
            }
        }
    }
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:48,代码来源:HiddenStaticMethodCheck.java


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