本文整理汇总了Java中edu.umd.cs.findbugs.ba.XMethod.getName方法的典型用法代码示例。如果您正苦于以下问题:Java XMethod.getName方法的具体用法?Java XMethod.getName怎么用?Java XMethod.getName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类edu.umd.cs.findbugs.ba.XMethod
的用法示例。
在下文中一共展示了XMethod.getName方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: parameterMustBeNonNull
import edu.umd.cs.findbugs.ba.XMethod; //导入方法依赖的package包/类
public boolean parameterMustBeNonNull(XMethod m, int param) {
if (DEBUG) {
System.out.print("Checking " + m + " param " + param + " for @Nonnull...");
}
TypeQualifierAnnotation tqa = TypeQualifierApplications.getEffectiveTypeQualifierAnnotation(m, param,
nonnullTypeQualifierValue);
if (tqa == null && param == 0) {
String name = m.getName();
String signature = m.getSignature();
if (name.equals("main") && signature.equals("([Ljava/lang/String;)V") && m.isStatic() && m.isPublic())
return true;
else if (NullnessAnnotationDatabase.assertsFirstParameterIsNonnull(m))
return true;
else if (name.equals("compareTo") && signature.substring(signature.indexOf(";") + 1).equals(")Z") && !m.isStatic())
return true;
}
boolean answer = (tqa != null) && tqa.when == When.ALWAYS;
if (DEBUG) {
System.out.println(answer ? "yes" : "no");
}
return answer;
}
示例2: parameterMustBeNonNull
import edu.umd.cs.findbugs.ba.XMethod; //导入方法依赖的package包/类
public boolean parameterMustBeNonNull(XMethod m, int param) {
if (DEBUG) {
System.out.print("Checking " + m + " param " + param + " for @Nonnull...");
}
TypeQualifierAnnotation tqa = TypeQualifierApplications.getEffectiveTypeQualifierAnnotation(m, param,
nonnullTypeQualifierValue);
if (tqa == null && param == 0) {
String name = m.getName();
String signature = m.getSignature();
if (name.equals("main") && signature.equals("([Ljava/lang/String;)V") && m.isStatic() && m.isPublic())
return true;
else if (assertsFirstParameterIsNonnull(m))
return true;
else if (name.equals("compareTo") && signature.substring(signature.indexOf(";") + 1).equals(")Z") && !m.isStatic())
return true;
}
boolean answer = (tqa != null) && tqa.when == When.ALWAYS;
if (DEBUG) {
System.out.println(answer ? "yes" : "no");
}
return answer;
}
开发者ID:OpenNTF,项目名称:FindBug-for-Domino-Designer,代码行数:26,代码来源:TypeQualifierNullnessAnnotationDatabase.java
示例3: 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;
}
示例4: addObligations
import edu.umd.cs.findbugs.ba.XMethod; //导入方法依赖的package包/类
/**
* @param xmethod
*/
public void addObligations(XMethod xmethod) {
// See what obligation parameters there are
Obligation[] paramObligationTypes = database.getFactory().getParameterObligationTypes(xmethod);
//
// Check for @WillCloseWhenClosed, @WillClose, @WillNotClose, or
// other
// indications of how obligation parameters are handled.
//
boolean methodHasCloseInName = false;
if (INFER_CLOSE_METHODS) {
SplitCamelCaseIdentifier splitter = new SplitCamelCaseIdentifier(xmethod.getName());
methodHasCloseInName = splitter.split().contains("close");
}
for (int i = 0; i < xmethod.getNumParams(); i++)
if (paramObligationTypes[i] != null) {
if (xmethod.getParameterAnnotation(i, willCloseWhenClosed) != null) {
//
// Calling this method deletes a parameter obligation
// and
// creates a new obligation for the object returned by
// the method.
//
handleWillCloseWhenClosed(xmethod, paramObligationTypes[i]);
} else if (xmethod.getParameterAnnotation(i, willClose) != null) {
if (paramObligationTypes[i] == null) {
// Hmm...
if (DEBUG_ANNOTATIONS) {
System.out.println("Method " + xmethod.toString() + " has param " + i + " annotated @WillClose, "
+ "but its type is not an obligation type");
}
} else {
addParameterDeletesObligationDatabaseEntry(xmethod, paramObligationTypes[i],
ObligationPolicyDatabaseEntryType.STRONG);
}
sawAnnotationsInApplicationCode = true;
} else if (xmethod.getParameterAnnotation(i, willNotClose) != null) {
// No database entry needs to be added
sawAnnotationsInApplicationCode = true;
} else if (INFER_CLOSE_METHODS && methodHasCloseInName) {
// Method has "close" in its name.
// Assume that it deletes the obligation.
addParameterDeletesObligationDatabaseEntry(xmethod, paramObligationTypes[i],
ObligationPolicyDatabaseEntryType.STRONG);
} else {
/*
* // Interesting case: we have a parameter which is // an
* Obligation type, but no annotation or other indication //
* what is done by the method with the obligation. // We'll
* create a "weak" database entry deleting the //
* obligation. If strict checking is performed, // weak
* entries are ignored.
*/
if (xmethod.getName().equals("<init>") || xmethod.isStatic()
|| xmethod.getName().toLowerCase().indexOf("close") >= 0
|| xmethod.getSignature().toLowerCase().indexOf("Closeable") >= 0)
addParameterDeletesObligationDatabaseEntry(xmethod, paramObligationTypes[i],
ObligationPolicyDatabaseEntryType.WEAK);
}
}
}
示例5: addObligations
import edu.umd.cs.findbugs.ba.XMethod; //导入方法依赖的package包/类
/**
* @param xmethod
*/
public void addObligations(XMethod xmethod) {
// See what obligation parameters there are
Obligation[] paramObligationTypes = database.getFactory().getParameterObligationTypes(xmethod);
//
// Check for @WillCloseWhenClosed, @WillClose, @WillNotClose, or
// other
// indications of how obligation parameters are handled.
//
boolean methodHasCloseInName = false;
if (INFER_CLOSE_METHODS) {
SplitCamelCaseIdentifier splitter = new SplitCamelCaseIdentifier(xmethod.getName());
methodHasCloseInName = splitter.split().contains("close");
}
for (int i = 0; i < xmethod.getNumParams(); i++) {
Obligation obligationType = paramObligationTypes[i];
if (obligationType != null) {
if (xmethod.getParameterAnnotation(i, willCloseWhenClosed) != null) {
//
// Calling this method deletes a parameter obligation
// and
// creates a new obligation for the object returned by
// the method.
//
handleWillCloseWhenClosed(xmethod, obligationType);
} else if (xmethod.getParameterAnnotation(i, willClose) != null) {
addParameterDeletesObligationDatabaseEntry(xmethod, obligationType,
ObligationPolicyDatabaseEntryType.STRONG);
sawAnnotationsInApplicationCode = true;
} else if (xmethod.getParameterAnnotation(i, willNotClose) != null) {
// No database entry needs to be added
sawAnnotationsInApplicationCode = true;
} else if (INFER_CLOSE_METHODS && methodHasCloseInName) {
// Method has "close" in its name.
// Assume that it deletes the obligation.
addParameterDeletesObligationDatabaseEntry(xmethod, obligationType,
ObligationPolicyDatabaseEntryType.STRONG);
} else {
/*
* // Interesting case: we have a parameter which is // an
* Obligation type, but no annotation or other indication //
* what is done by the method with the obligation. // We'll
* create a "weak" database entry deleting the //
* obligation. If strict checking is performed, // weak
* entries are ignored.
*/
if (xmethod.getName().equals("<init>") || xmethod.isStatic()
|| xmethod.getName().toLowerCase().indexOf("close") >= 0
|| xmethod.getSignature().toLowerCase().indexOf("Closeable") >= 0)
addParameterDeletesObligationDatabaseEntry(xmethod, obligationType,
ObligationPolicyDatabaseEntryType.WEAK);
}
}
}
}
示例6: MatchMethodEntry
import edu.umd.cs.findbugs.ba.XMethod; //导入方法依赖的package包/类
/**
* Constructor. Creates an entry which matches the given XMethod.
*
* @param xmethod
* an XMethod
* @param action
* ActionType (ADD or DEL, depending on whether obligation is
* added or deleted)
* @param entryType
* entry type
* @param obligations
* Obligation to be added or deleted
*/
public MatchMethodEntry(XMethod xmethod, ObligationPolicyDatabaseActionType action,
ObligationPolicyDatabaseEntryType entryType, Obligation... obligations) {
this(new SubtypeTypeMatcher(xmethod.getClassDescriptor()), new ExactStringMatcher(xmethod.getName()),
new ExactStringMatcher(xmethod.getSignature()), xmethod.isStatic(), action, entryType, obligations);
}