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


Java XMethod类代码示例

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


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

示例1: checkNonSuper

import edu.umd.cs.findbugs.ba.XMethod; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private boolean checkNonSuper(XMethod m, Set<XMethod> others) {
    if (m.isStatic())
        return false;
    if (m.getName().startsWith("<init>") || m.getName().startsWith("<clinit>"))
        return false;
    for (XMethod m2 : others) {
        if (confusingMethodNamesWrongCapitalization(m, m2)) {
            XMethod mm1 = m;
            XMethod mm2 = m2;
            if (m.compareTo(m2) < 0) {
                mm1 = m;
                mm2 = m2;
            } else {
                mm1 = m2;
                mm2 = m;
            }
            bugReporter.reportBug(new BugInstance(this, "NM_CONFUSING", LOW_PRIORITY).addClass(mm1.getClassName())
                    .addMethod(mm1).addClass(mm2.getClassName()).addMethod(mm2));
            return true;
        }
    }
    return false;
}
 
开发者ID:OpenNTF,项目名称:FindBug-for-Domino-Designer,代码行数:25,代码来源:Naming.java

示例2: visit

import edu.umd.cs.findbugs.ba.XMethod; //导入依赖的package包/类
@Override
public void visit(Code code) {
    if (getMethod().isStatic() || getMethod().isPrivate())
        return;
    XMethod overrides = Lookup.findSuperImplementorAsXMethod(getThisClass(), getMethodName(), getMethodSig(), bugReporter);

    if (overrides == null)
        return;
    AnnotationValue annotation = overrides.getAnnotation(mustOverrideAnnotation);
    if (annotation == null)
        return;
    sawCallToSuper = false;
    super.visit(code);
    if (!sawCallToSuper)
        bugReporter.reportBug(new BugInstance(this, "TESTING", NORMAL_PRIORITY).addClassAndMethod(this).addString(
                "Method must invoke override method in superclass"));
}
 
开发者ID:OpenNTF,项目名称:FindBug-for-Domino-Designer,代码行数:18,代码来源:CbeckMustOverrideSuperAnnotation.java

示例3: visit

import edu.umd.cs.findbugs.ba.XMethod; //导入依赖的package包/类
@Override
public void visit(Code m) {
    applicableApplications = new HashSet<TypeQualifierValue<?>>();
    XMethod xMethod = getXMethod();

    // Find the direct annotations on this method
    updateApplicableAnnotations(xMethod);

    // Find direct annotations on called methods and loaded fields
    super.visit(m);

    if (applicableApplications.size() > 0) {
        qualifiers.setDirectlyRelevantTypeQualifiers(getMethodDescriptor(), new ArrayList<TypeQualifierValue<?>>(
                applicableApplications));
    }
}
 
开发者ID:OpenNTF,项目名称:FindBug-for-Domino-Designer,代码行数:17,代码来源:NoteDirectlyRelevantTypeQualifiers.java

示例4: emitSourceWarning

import edu.umd.cs.findbugs.ba.XMethod; //导入依赖的package包/类
private void emitSourceWarning(String bugType, XMethod xMethod, TypeQualifierValue typeQualifierValue,
        FlowValue backwardsFlowValue, TypeQualifierValueSet backwardsFact, SourceSinkInfo source, ValueNumber vn,
        Location location) {

    BugInstance warning = new BugInstance(this, bugType, Priorities.NORMAL_PRIORITY).addClassAndMethod(xMethod);
    annotateWarningWithTypeQualifier(warning, typeQualifierValue);

    annotateWarningWithSourceSinkInfo(warning, xMethod, vn, source);

    Set<? extends SourceSinkInfo> sinkSet = (backwardsFlowValue == FlowValue.NEVER) ? backwardsFact.getWhereNever(vn) : backwardsFact
            .getWhereAlways(vn);
    for (SourceSinkInfo sink : sinkSet) {
        annotateWarningWithSourceSinkInfo(warning, xMethod, vn, sink);
    }

    bugReporter.reportBug(warning);
}
 
开发者ID:OpenNTF,项目名称:FindBug-for-Domino-Designer,代码行数:18,代码来源:CheckTypeQualifiers.java

示例5: checkForWeirdEquals

import edu.umd.cs.findbugs.ba.XMethod; //导入依赖的package包/类
/**
 * @param lhsSig
 * @param rhsSig
 * @param targets
 * @return
 */
private boolean checkForWeirdEquals(String lhsSig, String rhsSig, Set<XMethod> targets) {
    boolean allOk = false;
    try {
        ClassSummary classSummary = AnalysisContext.currentAnalysisContext().getClassSummary();

        ClassDescriptor expectedClassDescriptor = DescriptorFactory.createClassDescriptorFromSignature(lhsSig);
        ClassDescriptor actualClassDescriptor = DescriptorFactory.createClassDescriptorFromSignature(rhsSig);

        targets.addAll(Hierarchy2.resolveVirtualMethodCallTargets(expectedClassDescriptor, "equals", "(Ljava/lang/Object;)Z",
                false, false));
        allOk = targets.size() > 0;
        for (XMethod m2 : targets)
            if (!classSummary.mightBeEqualTo(m2.getClassDescriptor(), actualClassDescriptor))
                allOk = false;

    } catch (ClassNotFoundException e) {
        AnalysisContext.reportMissingClass(e);
    }
    return allOk;
}
 
开发者ID:OpenNTF,项目名称:FindBug-for-Domino-Designer,代码行数:27,代码来源:FindRefComparison.java

示例6: addMethodAnnotation

import edu.umd.cs.findbugs.ba.XMethod; //导入依赖的package包/类
public void addMethodAnnotation(String cName, String mName, String sig, boolean isStatic, NullnessAnnotation annotation) {
    if (DEBUG) {
        System.out.println("addMethodAnnotation: annotate " + cName + "." + mName + " with " + annotation);
    }
    XMethod xmethod = getXMethod(cName, mName, sig, isStatic);
    if (xmethod == null)
        return;
    // Get JSR-305 nullness annotation type
    ClassDescriptor nullnessAnnotationType = getNullnessAnnotationClassDescriptor(annotation);

    // Create an AnnotationValue
    AnnotationValue annotationValue = new AnnotationValue(nullnessAnnotationType);

    // Destructively add the annotation to the MethodInfo object
    xmethod.addAnnotation(annotationValue);
}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:17,代码来源:TypeQualifierNullnessAnnotationDatabase.java

示例7: visitParameterAnnotation

import edu.umd.cs.findbugs.ba.XMethod; //导入依赖的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:ytus,项目名称:findbugs-all-the-bugs,代码行数:22,代码来源:BuildNonNullAnnotationDatabase.java

示例8: checkForConflictingValues

import edu.umd.cs.findbugs.ba.XMethod; //导入依赖的package包/类
private void checkForConflictingValues(XMethod xMethod, CFG cfg,
        TypeQualifierValue typeQualifierValue, TypeQualifierValueSet forwardsFact, TypeQualifierValueSet backwardsFact,
        Location locationToReport, Location locationWhereDoomedValueIsObserved, ValueNumberFrame vnaFrame) throws CheckedAnalysisException {
    Set<ValueNumber> valueNumberSet = new HashSet<ValueNumber>();
    valueNumberSet.addAll(forwardsFact.getValueNumbers());
    valueNumberSet.addAll(backwardsFact.getValueNumbers());

    for (ValueNumber vn : valueNumberSet) {
        FlowValue forward = forwardsFact.getValue(vn);
        FlowValue backward = backwardsFact.getValue(vn);
        if (!FlowValue.valuesConflict(typeQualifierValue.isStrictQualifier() && !xMethod.isIdentity(), forward, backward))
            continue;

        if (DEBUG) {
            System.out.println("Check " + vn + ": forward=" + forward + ", backward=" + backward + " at " + checkLocation);
            forwardsFact.getValue(vn);
            backwardsFact.getValue(vn);
        }

        emitDataflowWarning(xMethod, typeQualifierValue, forwardsFact, backwardsFact, vn, forward, backward,
                locationToReport, locationWhereDoomedValueIsObserved, vnaFrame);

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

示例9: getInheritedTypeQualifierAnnotation

import edu.umd.cs.findbugs.ba.XMethod; //导入依赖的package包/类
/**
 * Get the effective inherited TypeQualifierAnnotation on given instance
 * method.
 *
 * @param o
 *            an XMethod
 * @param typeQualifierValue
 *            the kind of TypeQualifierValue we are looking for
 * @return effective TypeQualifierAnnotation inherited from overridden
 *         supertype methods, or null if there is no inherited
 *         TypeQualifierAnnotation
 */
public static TypeQualifierAnnotation getInheritedTypeQualifierAnnotation(XMethod o, TypeQualifierValue<?> typeQualifierValue) {
    assert !o.isStatic();

    ReturnTypeAnnotationAccumulator accumulator = new ReturnTypeAnnotationAccumulator(typeQualifierValue, o);
    try {
        AnalysisContext.currentAnalysisContext().getSubtypes2().traverseSupertypes(o.getClassDescriptor(), accumulator);
        TypeQualifierAnnotation result = accumulator.getResult().getEffectiveTypeQualifierAnnotation();
        if (result == null && accumulator.overrides())
            return TypeQualifierAnnotation.OVERRIDES_BUT_NO_ANNOTATION;
        return result;
    } catch (ClassNotFoundException e) {
        AnalysisContext.currentAnalysisContext().getLookupFailureCallback().reportMissingClass(e);
        return null;
    }
}
 
开发者ID:OpenNTF,项目名称:FindBug-for-Domino-Designer,代码行数:28,代码来源:TypeQualifierApplications.java

示例10: bad

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

    if (m == null)
        return false;
    Object value = right.getConstant();
    if (!(value instanceof Integer) || ((Integer) value).intValue() == 0)
        return false;
    if (m.isStatic() || !m.isPublic())
        return false;

    if (m.getName().equals("compareTo") && m.getSignature().equals("(Ljava/lang/Object;)I"))
        return true;
    if (m.getName().equals("compare") && m.getSignature().equals("(Ljava/lang/Object;Ljava/lang/Object;)I"))
        return true;

    return false;

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

示例11: safeCallToPrimateParseMethod

import edu.umd.cs.findbugs.ba.XMethod; //导入依赖的package包/类
private boolean safeCallToPrimateParseMethod(XMethod calledMethod, Location location) {
    int position = location.getHandle().getPosition();

    if (calledMethod.getClassName().equals("java.lang.Integer")) {

        ConstantPool constantPool = classContext.getJavaClass().getConstantPool();
        Code code = method.getCode();

        int catchSize;

        catchSize = Util.getSizeOfSurroundingTryBlock(constantPool, code, "java/lang/NumberFormatException", position);
        if (catchSize < Integer.MAX_VALUE)
            return true;
        catchSize = Util.getSizeOfSurroundingTryBlock(constantPool, code, "java/lang/IllegalArgumentException", position);
        if (catchSize < Integer.MAX_VALUE)
            return true;

        catchSize = Util.getSizeOfSurroundingTryBlock(constantPool, code, "java/lang/RuntimeException", position);
        if (catchSize < Integer.MAX_VALUE)
            return true;
        catchSize = Util.getSizeOfSurroundingTryBlock(constantPool, code, "java/lang/Exception", position);
        if (catchSize < Integer.MAX_VALUE)
            return true;
    }
    return false;
}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:27,代码来源:FindNullDeref.java

示例12: getEffectiveTypeQualifierAnnotation

import edu.umd.cs.findbugs.ba.XMethod; //导入依赖的package包/类
/**
 * Get the effective TypeQualifierAnnotation on given method parameter.
 * Takes into account inherited and default (outer scope) annotations. Also
 * takes exclusive qualifiers into account.
 *
 * @param xmethod
 *            a method
 * @param parameter
 *            a parameter (0 == first parameter)
 * @param typeQualifierValue
 *            the kind of TypeQualifierValue we are looking for
 * @return effective TypeQualifierAnnotation on the parameter, or null if
 *         there is no effective TypeQualifierAnnotation
 */
public static @CheckForNull
TypeQualifierAnnotation getEffectiveTypeQualifierAnnotation(final XMethod xmethod, final int parameter,
        TypeQualifierValue typeQualifierValue) {

    TypeQualifierAnnotation tqa = computeEffectiveTypeQualifierAnnotation(typeQualifierValue, xmethod, parameter);

    if (CHECK_EXCLUSIVE && tqa == null && typeQualifierValue.isExclusiveQualifier()) {
        tqa = computeExclusiveQualifier(typeQualifierValue, new ComputeEffectiveTypeQualifierAnnotation() {
            public TypeQualifierAnnotation compute(TypeQualifierValue tqv) {
                return computeEffectiveTypeQualifierAnnotation(tqv, xmethod, parameter);
            }

            @Override
            public String toString() {
                return "parameter " + parameter + " of " + xmethod;
            }
        });
    }

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

示例13: getInheritedTypeQualifierAnnotation

import edu.umd.cs.findbugs.ba.XMethod; //导入依赖的package包/类
/**
 * Get the effective inherited TypeQualifierAnnotation on the given instance
 * method parameter.
 *
 * @param xmethod
 *            an instance method
 * @param parameter
 *            a parameter (0 == first parameter)
 * @param typeQualifierValue
 *            the kind of TypeQualifierValue we are looking for
 * @return effective inherited TypeQualifierAnnotation on the parameter, or
 *         null if there is not effective TypeQualifierAnnotation
 */
private static @CheckForNull
TypeQualifierAnnotation getInheritedTypeQualifierAnnotation(XMethod xmethod, int parameter,
        TypeQualifierValue typeQualifierValue) {
    assert !xmethod.isStatic();

    ParameterAnnotationAccumulator accumulator = new ParameterAnnotationAccumulator(typeQualifierValue, xmethod, parameter);
    try {
        AnalysisContext.currentAnalysisContext().getSubtypes2().traverseSupertypes(xmethod.getClassDescriptor(), accumulator);
        TypeQualifierAnnotation result = accumulator.getResult().getEffectiveTypeQualifierAnnotation();
        if (result == null && accumulator.overrides())
            return TypeQualifierAnnotation.OVERRIDES_BUT_NO_ANNOTATION;
        return result;
    } catch (ClassNotFoundException e) {
        AnalysisContext.currentAnalysisContext().getLookupFailureCallback().reportMissingClass(e);
        return null;
    }
}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:31,代码来源:TypeQualifierApplications.java

示例14: getXMethodOperand

import edu.umd.cs.findbugs.ba.XMethod; //导入依赖的package包/类
public @CheckForNull
XMethod getXMethodOperand() {
    if (getReferencedXClass() != null && referencedXMethod == null) {
        referencedXMethod = Hierarchy2.findInvocationLeastUpperBound(getReferencedXClass(), nameConstantOperand,
                sigConstantOperand, opcode == INVOKESTATIC, opcode == INVOKEINTERFACE);
    }

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

示例15: isStaticOnlyClass

import edu.umd.cs.findbugs.ba.XMethod; //导入依赖的package包/类
private boolean isStaticOnlyClass(XClass xClass)  {

        if (xClass.getInterfaceDescriptorList().length > 0)
            return false;
        ClassDescriptor superclassDescriptor = xClass.getSuperclassDescriptor();
        if (superclassDescriptor == null)
            return false;
        String superClassName = superclassDescriptor.getClassName();
        if (!superClassName.equals("java/lang/Object"))
            return false;
        int staticCount = 0;

        List<? extends XMethod> methods = xClass.getXMethods();
        for (XMethod m : methods) {
            if (m.isStatic()) {
                staticCount++;
            } else if (!m.getName().equals("<init>") || !m.getSignature().equals("()V"))
                return false;
        }

        List<? extends XField> fields = xClass.getXFields();
        for (XField f : fields) {
            if (f.isStatic()) {
                staticCount++;
            } else if (!f.isPrivate())
                return false;
        }

        if (staticCount == 0)
            return false;
        return true;

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


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