本文整理汇总了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);
}
}
示例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"));
}
示例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);
}
示例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());
}
示例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();
}