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


Java XFactory.createXMethod方法代码示例

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


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

示例1: getJumpInfoFromStackMap

import edu.umd.cs.findbugs.ba.XFactory; //导入方法依赖的package包/类
private JumpInfoFromStackMap getJumpInfoFromStackMap() {
    IAnalysisCache analysisCache = Global.getAnalysisCache();
    XMethod xMethod = XFactory.createXMethod(v.getThisClass(), v.getMethod());
    if (xMethod instanceof MethodInfo) {
        MethodInfo mi = (MethodInfo) xMethod;
        if (!mi.hasBackBranch())
            return null;
    }
    
    try {
        return analysisCache.getMethodAnalysis(JumpInfoFromStackMap.class, xMethod.getMethodDescriptor());
        
    } catch (CheckedAnalysisException e) {
        AnalysisContext.logError("Error getting jump information from StackMap", e);
        return null;
    }
}
 
开发者ID:OpenNTF,项目名称:FindBug-for-Domino-Designer,代码行数:18,代码来源:OpcodeStack.java

示例2: visitAnnotation

import edu.umd.cs.findbugs.ba.XFactory; //导入方法依赖的package包/类
@Override
public void visitAnnotation(String annotationClass, Map<String, ElementValue> map, boolean runtimeVisible) {

    if (!annotationClass.startsWith(NET_JCIP_ANNOTATIONS))
        return;
    annotationClass = annotationClass.substring(NET_JCIP_ANNOTATIONS.length());
    ElementValue value = map.get("value");
    ClassMember member;
    if (visitingField())
        member = XFactory.createXField(this);
    else if (visitingMethod())
        member = XFactory.createXMethod(this);
    else {
        Map<String, ElementValue> annotationsOfThisClass = AnalysisContext.currentAnalysisContext()
                .getJCIPAnnotationDatabase().getEntryForClass(getDottedClassName());
        annotationsOfThisClass.put(annotationClass, value);
        return;
    }
    Map<String, ElementValue> annotationsOfThisMember = AnalysisContext.currentAnalysisContext().getJCIPAnnotationDatabase()
            .getEntryForClassMember(member);
    annotationsOfThisMember.put(annotationClass, value);
}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:23,代码来源:NoteJCIPAnnotation.java

示例3: visitParameterAnnotation

import edu.umd.cs.findbugs.ba.XFactory; //导入方法依赖的package包/类
@Override
public void visitParameterAnnotation(int p, String annotationClass, Map<String, ElementValue> map, boolean runtimeVisible) {
    if (database == null) {
        return;
    }

    NullnessAnnotation n = NullnessAnnotation.Parser.parse(annotationClass);
    annotationClass = lastPortion(annotationClass);
    if (n == null)
        return;

    XMethod xmethod = XFactory.createXMethod(this);
    if (DEBUG) {
        System.out.println("Parameter " + p + " @" + annotationClass.substring(annotationClass.lastIndexOf('/') + 1) + " in "
                + xmethod.toString());
    }
    XMethodParameter xparameter = new XMethodParameter(xmethod, p);

    database.addDirectAnnotation(xparameter, n);

}
 
开发者ID:OpenNTF,项目名称:FindBug-for-Domino-Designer,代码行数:22,代码来源:BuildNonNullAnnotationDatabase.java

示例4: computeJumpInfo

import edu.umd.cs.findbugs.ba.XFactory; //导入方法依赖的package包/类
/**
 * @param jclass
 * @param method
 * @param stack
 * @param branchAnalysis
 * @return
 */
public static JumpInfo computeJumpInfo(JavaClass jclass, Method method, final OpcodeStack stack,
        DismantleBytecode branchAnalysis) {
    branchAnalysis.setupVisitorForClass(jclass);
    MethodInfo xMethod = (MethodInfo) XFactory.createXMethod(jclass, method);
    int oldCount = 0;
    while (true) {
        stack.resetForMethodEntry0(ClassName.toSlashedClassName(jclass.getClassName()), method);
        branchAnalysis.doVisitMethod(method);
        int newCount = stack.jumpEntries.size();
        if (xMethod.hasBackBranch() != stack.backwardsBranch && !stack.encountedTop) {
            AnalysisContext.logError(
                    String.format("For %s, mismatch on existence of backedge: %s for precomputation, %s for bytecode analysis",
                            xMethod, xMethod.hasBackBranch(), stack.backwardsBranch));
        }
        if (newCount == oldCount || !stack.encountedTop || !stack.backwardsBranch)
            break;
        oldCount = newCount;
    }

    return new JumpInfo(stack.jumpEntries, stack.jumpStackEntries, stack.jumpEntryLocations);
}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:29,代码来源:OpcodeStack.java

示例5: addPropertiesForMethodContainingWarning

import edu.umd.cs.findbugs.ba.XFactory; //导入方法依赖的package包/类
/**
 * @param propertySet
 * @param xMethod
 */
private void addPropertiesForMethodContainingWarning(WarningPropertySet<WarningProperty> propertySet) {
    XMethod xMethod = XFactory.createXMethod(classContext.getJavaClass(), method);

    boolean uncallable = !AnalysisContext.currentXFactory().isCalledDirectlyOrIndirectly(xMethod) && xMethod.isPrivate();

    if (uncallable)
        propertySet.addProperty(GeneralWarningProperty.IN_UNCALLABLE_METHOD);
}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:13,代码来源:NoiseNullDeref.java

示例6: sawOpcode

import edu.umd.cs.findbugs.ba.XFactory; //导入方法依赖的package包/类
@Override
public void sawOpcode(int seen) {
    switch (seen) {
    case INVOKEVIRTUAL:
    case INVOKESPECIAL:
    case INVOKESTATIC:
        XMethod callSeen = XFactory.createXMethod(MethodAnnotation.fromCalledMethod(this));
        DefaultEncodingAnnotation annotation = defaultEncodingAnnotationDatabase.getDirectAnnotation(callSeen);
        if (annotation != null) {
            bugAccumulator.accumulateBug(new BugInstance(this, "DM_DEFAULT_ENCODING", HIGH_PRIORITY).addClassAndMethod(this)
                    .addCalledMethod(this), this);
        }
    }
}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:15,代码来源:DefaultEncodingDetector.java

示例7: sawOpcode

import edu.umd.cs.findbugs.ba.XFactory; //导入方法依赖的package包/类
@Override
public void sawOpcode(int seen) {
    switch (seen) {
    case Constants.INVOKESTATIC:
    case Constants.INVOKEVIRTUAL:
    case Constants.INVOKEINTERFACE:
    case Constants.INVOKESPECIAL:
        MethodDescriptor called = getMethodDescriptorOperand();
        XMethod calledXMethod = XFactory.createXMethod(called);
        InterproceduralCallGraphVertex calledVertex = findVertex(calledXMethod);
        callGraph.createEdge(currentVertex, calledVertex);
    }
}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:14,代码来源:BuildInterproceduralCallGraph.java

示例8: getMethodNullnessAnnotation

import edu.umd.cs.findbugs.ba.XFactory; //导入方法依赖的package包/类
public static NullnessAnnotation getMethodNullnessAnnotation(ClassContext classContext, Method method) {

        if (method.getSignature().indexOf(")L") >= 0 || method.getSignature().indexOf(")[") >= 0) {

            XMethod m = XFactory.createXMethod(classContext.getJavaClass(), method);
            return AnalysisContext.currentAnalysisContext().getNullnessAnnotationDatabase().getResolvedAnnotation(m, false);
        }
        return NullnessAnnotation.UNKNOWN_NULLNESS;
    }
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:10,代码来源:DerefFinder.java

示例9: registerReturnValueSource

import edu.umd.cs.findbugs.ba.XFactory; //导入方法依赖的package包/类
private void registerReturnValueSource(Location location) throws DataflowAnalysisException {
    // Nothing to do if called method does not return a value
    InvokeInstruction inv = (InvokeInstruction) location.getHandle().getInstruction();
    String calledMethodSig = inv.getSignature(cpg);
    if (calledMethodSig.endsWith(")V")) {
        return;
    }

    XMethod calledXMethod = XFactory.createXMethod(inv, cpg);
    if (TypeQualifierDataflowAnalysis.isIdentifyFunctionForTypeQualifiers(calledXMethod))
        return;

    if (calledXMethod.isResolved()) {
        TypeQualifierAnnotation tqa = TypeQualifierApplications.getEffectiveTypeQualifierAnnotation(calledXMethod,
                typeQualifierValue);

        boolean interproc = false;
        if (TypeQualifierDatabase.USE_DATABASE && tqa == null) {
            // See if there's an entry in the interprocedural
            // type qualifier database.
            TypeQualifierDatabase tqdb = Global.getAnalysisCache().getDatabase(TypeQualifierDatabase.class);
            tqa = tqdb.getReturnValue(calledXMethod.getMethodDescriptor(), typeQualifierValue);
            if (tqa != null) {
                interproc = true;
            }
        }

        When when = (tqa != null) ? tqa.when : When.UNKNOWN;
        registerTopOfStackSource(SourceSinkType.RETURN_VALUE_OF_CALLED_METHOD, location, when, interproc, null);
    }
}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:32,代码来源:ForwardTypeQualifierDataflowAnalysis.java

示例10: analyze

import edu.umd.cs.findbugs.ba.XFactory; //导入方法依赖的package包/类
public ObligationDataflow analyze(IAnalysisCache analysisCache, MethodDescriptor methodDescriptor)
        throws CheckedAnalysisException {
    CFG cfg = analysisCache.getMethodAnalysis(CFG.class, methodDescriptor);
    DepthFirstSearch dfs = analysisCache.getMethodAnalysis(DepthFirstSearch.class, methodDescriptor);
    XMethod xmethod = XFactory.createXMethod(methodDescriptor);
    ConstantPoolGen cpg = analysisCache.getClassAnalysis(ConstantPoolGen.class, methodDescriptor.getClassDescriptor());

    ObligationPolicyDatabase database = analysisCache.getDatabase(ObligationPolicyDatabase.class);

    TypeDataflow typeDataflow = analysisCache.getMethodAnalysis(TypeDataflow.class, methodDescriptor);
    IsNullValueDataflow invDataflow = analysisCache.getMethodAnalysis(IsNullValueDataflow.class, methodDescriptor);

    ObligationFactory factory = database.getFactory();

    ObligationAnalysis analysis = new ObligationAnalysis(dfs, xmethod, cpg, factory, database, typeDataflow, invDataflow,
            analysisCache.getErrorLogger());
    ObligationDataflow dataflow = new ObligationDataflow(cfg, analysis);

    Profiler profiler = analysisCache.getProfiler();
    profiler.start(analysis.getClass());
    try {
        dataflow.execute();
    } finally {
        profiler.end(analysis.getClass());
    }

    if (DEBUG_PRINTCFG) {
        System.out.println("Dataflow CFG:");
        DataflowCFGPrinter.printCFG(dataflow, System.out);
    }

    return dataflow;
}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:34,代码来源:ObligationDataflowFactory.java

示例11: writeKey

import edu.umd.cs.findbugs.ba.XFactory; //导入方法依赖的package包/类
@Override
protected void writeKey(Writer writer, MethodDescriptor method) throws IOException {
    writer.write(method.getClassDescriptor().toDottedClassName());
    writer.write(",");
    writer.write(method.getName());
    writer.write(",");
    writer.write(method.getSignature());
    writer.write(",");
    XMethod xMethod =  XFactory.createXMethod(method);
    writer.write(Integer.toString(xMethod.getAccessFlags() & 0xf));
}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:12,代码来源:MethodPropertyDatabase.java

示例12: transferInstruction

import edu.umd.cs.findbugs.ba.XFactory; //导入方法依赖的package包/类
@Override
public void transferInstruction(InstructionHandle handle, BasicBlock basicBlock, UnconditionalValueDerefSet fact)
        throws DataflowAnalysisException {

    Instruction instruction = handle.getInstruction();
    if (fact.isTop())
        return;
    Location location = new Location(handle, basicBlock);

    // If this is a call to an assertion method,
    // change the dataflow value to be TOP.
    // We don't want to report future derefs that would
    // be guaranteed only if the assertion methods
    // returns normally.
    // TODO: at some point, evaluate whether we should revisit this
    if (isAssertion(handle) // || handle.getInstruction() instanceof ATHROW
    ) {
        if (DEBUG)
            System.out.println("MAKING BOTTOM0 AT: " + location);
        fact.clear();
        return;
    }

    // Get value number frame
    ValueNumberFrame vnaFrame = vnaDataflow.getFactAtLocation(location);
    if (!vnaFrame.isValid()) {
        if (DEBUG)
            System.out.println("MAKING TOP1 AT: " + location);
        // Probably dead code.
        // Assume this location can't be reached.
        makeFactTop(fact);
        return;
    }
    if (isNullCheck(handle, methodGen.getConstantPool())) {
        handleNullCheck(location, vnaFrame, fact);
    }

    // Check for calls to a method that unconditionally dereferences
    // a parameter. Mark any such arguments as derefs.
    if (CHECK_CALLS && instruction instanceof InvokeInstruction) {
        checkUnconditionalDerefDatabase(location, vnaFrame, fact);
    }

    // If this is a method call instruction,
    // check to see if any of the parameters are @NonNull,
    // and treat them as dereferences.
    if (CHECK_ANNOTATIONS && instruction instanceof InvokeInstruction) {
        checkNonNullParams(location, vnaFrame, fact);
    }

    if (CHECK_ANNOTATIONS && instruction instanceof ARETURN) {
        XMethod thisMethod = XFactory.createXMethod(methodGen);
        checkNonNullReturnValue(thisMethod, location, vnaFrame, fact);
    }

    if (CHECK_ANNOTATIONS && (instruction instanceof PUTFIELD || instruction instanceof PUTSTATIC)) {
        checkNonNullPutField(location, vnaFrame, fact);
    }

    // Check to see if an instance value is dereferenced here
    checkInstance(location, vnaFrame, fact);

    if (false)
        fact.cleanDerefSet(location, vnaFrame);

    if (DEBUG && fact.isTop())
        System.out.println("MAKING TOP2 At: " + location);

}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:70,代码来源:UnconditionalValueDerefAnalysis.java

示例13: analyzeMethod

import edu.umd.cs.findbugs.ba.XFactory; //导入方法依赖的package包/类
private void analyzeMethod(ClassContext classContext, Method method) throws CFGBuilderException, DataflowAnalysisException {
    if (BCELUtil.isSynthetic(method) || (method.getAccessFlags() & Constants.ACC_BRIDGE) == Constants.ACC_BRIDGE)
        return;
    CFG cfg = classContext.getCFG(method);

    ConstantPoolGen cpg = classContext.getConstantPoolGen();
    TypeDataflow typeDataflow = classContext.getTypeDataflow(method);

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

        // Check if it's a method invocation.
        if (!basicBlock.isExceptionThrower())
            continue;
        InstructionHandle thrower = basicBlock.getExceptionThrower();
        Instruction ins = thrower.getInstruction();
        if (!(ins instanceof InvokeInstruction))
            continue;

        InvokeInstruction inv = (InvokeInstruction) ins;
        boolean foundThrower = false;
        boolean foundNonThrower = false;

        if (inv instanceof INVOKEINTERFACE)
            continue;

        String className = inv.getClassName(cpg);

        Location loc = new Location(thrower, basicBlock);
        TypeFrame typeFrame = typeDataflow.getFactAtLocation(loc);
        XMethod primaryXMethod = XFactory.createXMethod(inv, cpg);
        // if (primaryXMethod.isAbstract()) continue;
        Set<XMethod> targetSet = null;
        try {

            if (className.startsWith("["))
                continue;
            String methodSig = inv.getSignature(cpg);
            if (!methodSig.endsWith("V"))
                continue;

            targetSet = Hierarchy2.resolveMethodCallTargets(inv, typeFrame, cpg);

            for (XMethod xMethod : targetSet) {
                if (DEBUG)
                    System.out.println("\tFound " + xMethod);

                boolean isUnconditionalThrower = xMethod.isUnconditionalThrower() && !xMethod.isUnsupported()
                        && !xMethod.isSynthetic();
                if (isUnconditionalThrower) {
                    foundThrower = true;
                    if (DEBUG)
                        System.out.println("Found thrower");
                } else {
                    foundNonThrower = true;
                    if (DEBUG)
                        System.out.println("Found non thrower");
                }

            }
        } catch (ClassNotFoundException e) {
            analysisContext.getLookupFailureCallback().reportMissingClass(e);
        }
        boolean newResult = foundThrower && !foundNonThrower;
        if (newResult)
            bugReporter.reportBug(new BugInstance(this, "TESTING", Priorities.NORMAL_PRIORITY)
                    .addClassAndMethod(classContext.getJavaClass(), method)
                    .addString("Call to method that always throws Exception").addMethod(primaryXMethod)
                    .describe(MethodAnnotation.METHOD_CALLED).addSourceLine(classContext, method, loc));

    }

}
 
开发者ID:OpenNTF,项目名称:FindBug-for-Domino-Designer,代码行数:74,代码来源:CallToUnconditionalThrower.java

示例14: resolveAccessMethodForMethod

import edu.umd.cs.findbugs.ba.XFactory; //导入方法依赖的package包/类
public XMethod resolveAccessMethodForMethod() {
    MethodDescriptor access = getAccessMethodForMethod();
    if (access != null)
        return XFactory.createXMethod(access);
    return this;
}
 
开发者ID:OpenNTF,项目名称:FindBug-for-Domino-Designer,代码行数:7,代码来源:MethodInfo.java

示例15: handle

import edu.umd.cs.findbugs.ba.XFactory; //导入方法依赖的package包/类
private void handle(@SlashedClassName String className, boolean isFloatingPoint, String sig) {
    XMethod boxingMethod = XFactory.createXMethod(ClassName.toDottedClassName(className), "valueOf", sig + "L" + className +";", true);
    XMethod parsingMethod = XFactory.createXMethod(ClassName.toDottedClassName(className), "valueOf", "(Ljava/lang/String;)" + "L" + className +";", true);
    boxClasses.put(className, new Pair(boxingMethod, parsingMethod));
}
 
开发者ID:OpenNTF,项目名称:FindBug-for-Domino-Designer,代码行数:6,代码来源:NumberConstructor.java


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