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


Java XMethod.getAnnotation方法代码示例

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


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

示例1: visitClass

import edu.umd.cs.findbugs.ba.XMethod; //导入方法依赖的package包/类
public void visitClass(ClassDescriptor classDescriptor) throws CheckedAnalysisException {

        XClass xclass = Global.getAnalysisCache().getClassAnalysis(XClass.class, classDescriptor);

        // Is this class an obligation type?
        Obligation thisClassObligation = database.getFactory().getObligationByType(xclass.getClassDescriptor());

        // Scan methods for uses of obligation-related annotations
        for (XMethod xmethod : xclass.getXMethods()) {
            // Is this method marked with @CreatesObligation?
            if (thisClassObligation != null) {
                if (xmethod.getAnnotation(createsObligation) != null) {
                    database.addEntry(new MatchMethodEntry(xmethod, ObligationPolicyDatabaseActionType.ADD,
                            ObligationPolicyDatabaseEntryType.STRONG, thisClassObligation));
                }

                // Is this method marked with @DischargesObligation?
                if (xmethod.getAnnotation(dischargesObligation) != null) {
                    database.addEntry(new MatchMethodEntry(xmethod, ObligationPolicyDatabaseActionType.DEL,
                            ObligationPolicyDatabaseEntryType.STRONG, thisClassObligation));
                }
            }

            addObligations(xmethod);
        }
    }
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:27,代码来源:BuildObligationPolicyDatabase.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:ytus,项目名称:findbugs-all-the-bugs,代码行数:18,代码来源:CbeckMustOverrideSuperAnnotation.java

示例3: check

import edu.umd.cs.findbugs.ba.XMethod; //导入方法依赖的package包/类
private void check(XMethod xmethod, ClassDescriptor annotation, boolean expectWarnings, int priority) {
    AnnotationValue expect = xmethod.getAnnotation(annotation);
    if (expect == null)
        return;
    if (DEBUG) {
        System.out.println("*** Found " + annotation + " annotation on " + xmethod);
    }
    FieldOrMethodDescriptor descriptor = xmethod.getMethodDescriptor();
    Collection<BugInstance> warnings = warningsByMethod.get(descriptor);
    check(expect, descriptor, warnings, expectWarnings, priority);
}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:12,代码来源:CheckExpectedWarnings.java

示例4: check

import edu.umd.cs.findbugs.ba.XMethod; //导入方法依赖的package包/类
private void check(XMethod xmethod, ClassDescriptor annotation, boolean expectWarnings, int priority) {
    AnnotationValue expect = xmethod.getAnnotation(annotation);
    if (expect == null)
        return;
    if (DEBUG) {
        System.out.println("*** Found " + annotation + " annotation on " + xmethod);
    }
    FieldOrMethodDescriptor descriptor = xmethod.getMethodDescriptor();
    Collection<BugInstance> warnings = warningsByMethod.get(descriptor);
    check(expect, descriptor, warnings, expectWarnings, priority, descriptor.getClassDescriptor());
}
 
开发者ID:OpenNTF,项目名称:FindBug-for-Domino-Designer,代码行数:12,代码来源:CheckExpectedWarnings.java

示例5: analyzeMethod

import edu.umd.cs.findbugs.ba.XMethod; //导入方法依赖的package包/类
private void analyzeMethod(ClassContext classContext, Method method) throws DataflowAnalysisException, CFGBuilderException

    {
        if (DEBUG || DEBUG_NULLARG)
            System.out.println("Pre FND ");

        if ((method.getAccessFlags() & Constants.ACC_VOLATILE) != 0)
            return;

        MethodGen methodGen = classContext.getMethodGen(method);

        if (methodGen == null)
            return;
        if (!checkedDatabases) {
            checkDatabases();
            checkedDatabases = true;
        }

        XMethod xMethod = XFactory.createXMethod(classContext.getJavaClass(), method);

        ClassDescriptor junitTestAnnotation = DescriptorFactory.createClassDescriptor("org/junit/Test");
        AnnotationValue av = xMethod.getAnnotation(junitTestAnnotation);
        if (av != null) {
            Object value = av.getValue("expected");

            if (value instanceof Type) {
                String className = ((Type) value).getClassName();
                if (className.equals("java.lang.NullPointerException"))
                    return;
            }
        }

        // UsagesRequiringNonNullValues uses =
        // classContext.getUsagesRequiringNonNullValues(method);
        this.method = method;
        this.methodAnnotation = getMethodNullnessAnnotation();

        if (DEBUG || DEBUG_NULLARG)
            System.out.println("FND: " + SignatureConverter.convertMethodSignature(methodGen));

        this.previouslyDeadBlocks = findPreviouslyDeadBlocks();

        // Get the IsNullValueDataflow for the method from the ClassContext
        invDataflow = classContext.getIsNullValueDataflow(method);

        vnaDataflow = classContext.getValueNumberDataflow(method);

        // Create a NullDerefAndRedundantComparisonFinder object to do the
        // actual
        // work. It will call back to report null derefs and redundant null
        // comparisons
        // through the NullDerefAndRedundantComparisonCollector interface we
        // implement.
        NullDerefAndRedundantComparisonFinder worker = new NullDerefAndRedundantComparisonFinder(classContext, method, this);
        worker.execute();

        checkCallSitesAndReturnInstructions();

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


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