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


Java XMethod.isResolved方法代码示例

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


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

示例1: badUseOfCompareResult

import edu.umd.cs.findbugs.ba.XMethod; //导入方法依赖的package包/类
private boolean badUseOfCompareResult(Item left, Item right) {
    XMethod m = left.getReturnValueOf();

    if (m == null)
        return false;
    String name = m.getName();
    
    if (!name.startsWith("compare"))
        return false;
   
    Object value = right.getConstant();
    if (!(value instanceof Integer) || ((Integer) value).intValue() == 0)
        return false;
    if (!m.isPublic() && m.isResolved())
        return false;
    
    
    if (m.isStatic() || !m.isResolved()) {
        if (name.equals("compare") && m.getClassName().startsWith("com.google.common.primitives."))
            return true;
    }
    if (!m.isStatic() || !m.isResolved()) {
        if (name.equals("compareTo") && m.getSignature().equals("(Ljava/lang/Object;)I"))
            return true;
        if (name.equals("compare") && m.getSignature().equals("(Ljava/lang/Object;Ljava/lang/Object;)I"))
            return true;
    }

    return false;

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

示例2: registerReturnValueSource

import edu.umd.cs.findbugs.ba.XMethod; //导入方法依赖的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

示例3: sawOpcode

import edu.umd.cs.findbugs.ba.XMethod; //导入方法依赖的package包/类
@Override
public void sawOpcode(int seen) {
    if (seen != INVOKEVIRTUAL) {
        return;
    }
    if (!getClassName().equals(getClassConstantOperand())) {
        return;
    }
    XMethod invokedMethod = XFactory.createXMethod(getDottedClassConstantOperand(), getNameConstantOperand(),
            getSigConstantOperand(), false);
    if (invokedMethod.isResolved() && invokedMethod.getClassName().equals(getDottedClassConstantOperand())) {
        // method is not inherited
        return;
    }
    // method is inherited
    String possibleTargetClass = getDottedClassName();
    String superClassName = getDottedSuperclassName();
    while (true) {
        int i = possibleTargetClass.lastIndexOf('$');
        if (i <= 0) {
            break;
        }
        possibleTargetClass = possibleTargetClass.substring(0, i);
        if (possibleTargetClass.equals(superClassName)) {
            break;
        }
        XMethod alternativeMethod = XFactory.createXMethod(possibleTargetClass, getNameConstantOperand(),
                getSigConstantOperand(), false);
        if (alternativeMethod.isResolved() && alternativeMethod.getClassName().equals(possibleTargetClass)) {
            String targetPackage = invokedMethod.getPackageName();
            String alternativePackage = alternativeMethod.getPackageName();
            int priority = HIGH_PRIORITY;
            if (targetPackage.equals(alternativePackage)) {
                priority++;
            }
            if (targetPackage.startsWith("javax.swing") || targetPackage.startsWith("java.awt")) {
                priority += 2;
            }
            if (invokedMethod.getName().equals(getMethodName())) {
                priority++;
            }

            bugAccumulator.accumulateBug(
                    new BugInstance(this, "IA_AMBIGUOUS_INVOCATION_OF_INHERITED_OR_OUTER_METHOD", priority)
                            .addClassAndMethod(this).addMethod(invokedMethod).describe("METHOD_INHERITED")
                            .addMethod(alternativeMethod).describe("METHOD_ALTERNATIVE_TARGET"), this);
            break;
        }
    }

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

示例4: sawOpcode

import edu.umd.cs.findbugs.ba.XMethod; //导入方法依赖的package包/类
@Override
    public void sawOpcode(int seen) {
//        System.out.printf("%3d : %s%n", getPC(), OPCODE_NAMES[seen]);
        if (seen != INVOKEVIRTUAL) {
            return;
        }
        if (!getClassName().equals(getClassConstantOperand())) {
            return;
        }
        XMethod invokedMethod = XFactory.createXMethod(getDottedClassConstantOperand(), getNameConstantOperand(),
                getSigConstantOperand(), false);
        if (invokedMethod.isResolved() && invokedMethod.getClassName().equals(getDottedClassConstantOperand())
                || invokedMethod.isSynthetic()) {
            return;
        }
        // method is inherited
        String possibleTargetClass = getDottedClassName();
        String superClassName = getDottedSuperclassName();
        while (true) {
            int i = possibleTargetClass.lastIndexOf('$');
            if (i <= 0) {
                break;
            }
            possibleTargetClass = possibleTargetClass.substring(0, i);
            if (possibleTargetClass.equals(superClassName)) {
                break;
            }
            XMethod alternativeMethod = XFactory.createXMethod(possibleTargetClass, getNameConstantOperand(),
                    getSigConstantOperand(), false);
            if (alternativeMethod.isResolved() && alternativeMethod.getClassName().equals(possibleTargetClass)) {
                String targetPackage = invokedMethod.getPackageName();
                String alternativePackage = alternativeMethod.getPackageName();
                int priority = HIGH_PRIORITY;
                if (targetPackage.equals(alternativePackage)) {
                    priority++;
                }
                if (targetPackage.startsWith("javax.swing") || targetPackage.startsWith("java.awt")) {
                    priority += 2;
                }
                if (invokedMethod.getName().equals(getMethodName())) {
                    priority++;
                }

//                System.out.println("Found it");
                bugAccumulator.accumulateBug(
                        new BugInstance(this, "IA_AMBIGUOUS_INVOCATION_OF_INHERITED_OR_OUTER_METHOD", priority)
                                .addClassAndMethod(this).addMethod(invokedMethod).describe("METHOD_INHERITED")
                                .addMethod(alternativeMethod).describe("METHOD_ALTERNATIVE_TARGET"), this);
                break;
            }
        }

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


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