本文整理汇总了Java中edu.umd.cs.findbugs.ba.XMethod.getSignature方法的典型用法代码示例。如果您正苦于以下问题:Java XMethod.getSignature方法的具体用法?Java XMethod.getSignature怎么用?Java XMethod.getSignature使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类edu.umd.cs.findbugs.ba.XMethod
的用法示例。
在下文中一共展示了XMethod.getSignature方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: checkNonNullParams
import edu.umd.cs.findbugs.ba.XMethod; //导入方法依赖的package包/类
public static Set<ValueNumber> checkNonNullParams(Location location, ValueNumberFrame vnaFrame, ConstantPoolGen constantPool,
@CheckForNull Method method, @CheckForNull IsNullValueFrame invFrame) throws DataflowAnalysisException {
if (invFrame != null && !invFrame.isValid())
return Collections.emptySet();
INullnessAnnotationDatabase database = AnalysisContext.currentAnalysisContext().getNullnessAnnotationDatabase();
InvokeInstruction inv = (InvokeInstruction) location.getHandle().getInstruction();
XMethod called = XFactory.createXMethod(inv, constantPool);
SignatureParser sigParser = new SignatureParser(called.getSignature());
int numParams = sigParser.getNumParameters();
Set<ValueNumber> result = new HashSet<ValueNumber>();
Iterator<String> parameterIterator = sigParser.parameterSignatureIterator();
for (int i = 0; i < numParams; i++) {
String parameterSignature = parameterIterator.next();
char firstChar = parameterSignature.charAt(0);
if (firstChar != 'L' && firstChar != '[')
continue;
int offset = sigParser.getSlotsFromTopOfStackForParameter(i);
if (invFrame != null) {
int slot = invFrame.getStackLocation(offset);
if (!reportDereference(invFrame, slot))
continue;
}
if (database.parameterMustBeNonNull(called, i)) {
int catchSizeNPE = Util.getSizeOfSurroundingTryBlock(method, "java/lang/NullPointerException", location
.getHandle().getPosition());
int catchSizeNFE = Util.getSizeOfSurroundingTryBlock(method, "java/lang/NumberFormatException", location
.getHandle().getPosition());
if (catchSizeNPE == Integer.MAX_VALUE
&& (!called.getClassName().equals("java.lang.Integer") || catchSizeNFE == Integer.MAX_VALUE)) {
// Get the corresponding value number
ValueNumber vn = vnaFrame.getArgument(inv, constantPool, i, sigParser);
result.add(vn);
}
}
}
return result;
}
示例4: checkNonNullParams
import edu.umd.cs.findbugs.ba.XMethod; //导入方法依赖的package包/类
public static Set<ValueNumber> checkNonNullParams(Location location, ValueNumberFrame vnaFrame, ConstantPoolGen constantPool,
@CheckForNull Method method, @CheckForNull IsNullValueFrame invFrame) throws DataflowAnalysisException {
if (invFrame != null && !invFrame.isValid())
return Collections.emptySet();
INullnessAnnotationDatabase database = AnalysisContext.currentAnalysisContext().getNullnessAnnotationDatabase();
if (database == null) {
return Collections.emptySet();
}
InvokeInstruction inv = (InvokeInstruction) location.getHandle().getInstruction();
XMethod called = XFactory.createXMethod(inv, constantPool);
SignatureParser sigParser = new SignatureParser(called.getSignature());
int numParams = sigParser.getNumParameters();
Set<ValueNumber> result = new HashSet<ValueNumber>();
Iterator<String> parameterIterator = sigParser.parameterSignatureIterator();
for (int i = 0; i < numParams; i++) {
String parameterSignature = parameterIterator.next();
char firstChar = parameterSignature.charAt(0);
if (firstChar != 'L' && firstChar != '[')
continue;
int offset = sigParser.getSlotsFromTopOfStackForParameter(i);
if (invFrame != null) {
int slot = invFrame.getStackLocation(offset);
if (!reportDereference(invFrame, slot))
continue;
}
if (database.parameterMustBeNonNull(called, i)) {
int catchSizeNPE = Util.getSizeOfSurroundingTryBlock(method, "java/lang/NullPointerException", location
.getHandle().getPosition());
int catchSizeNFE = Util.getSizeOfSurroundingTryBlock(method, "java/lang/NumberFormatException", location
.getHandle().getPosition());
if (catchSizeNPE == Integer.MAX_VALUE
&& (!called.getClassName().equals("java.lang.Integer") || catchSizeNFE == Integer.MAX_VALUE)) {
// Get the corresponding value number
ValueNumber vn = vnaFrame.getArgument(inv, constantPool, i, sigParser);
result.add(vn);
}
}
}
return result;
}
示例5: modelArguments
import edu.umd.cs.findbugs.ba.XMethod; //导入方法依赖的package包/类
private void modelArguments(Location location) throws DataflowAnalysisException {
// Model arguments to called method
InvokeInstruction inv = (InvokeInstruction) location.getHandle().getInstruction();
XMethod calledMethod = XFactory.createXMethod(inv, cpg);
SignatureParser sigParser = new SignatureParser(calledMethod.getSignature());
if (sigParser.getNumParameters() == 0)
return;
ValueNumberFrame vnaFrame = vnaDataflow.getFactAtLocation(location);
if (!vnaFrame.isValid()) {
// AnalysisContext.logError("bad vna frame in " + xmethod +
// " at location " + location.getHandle().getPosition() +
// " calling " + calledMethod);
return;
}
if (TypeQualifierDataflowAnalysis.isIdentifyFunctionForTypeQualifiers(calledMethod))
return;
for (int param = 0; param < calledMethod.getNumParams(); param++) {
TypeQualifierAnnotation tqa = TypeQualifierApplications.getEffectiveTypeQualifierAnnotation(calledMethod, param,
typeQualifierValue);
boolean interproc = false;
if (TypeQualifierDatabase.USE_DATABASE && tqa == null) {
// See if there's an entry for this parameter
// in the interprocedural type qualifier database.
TypeQualifierDatabase tqdb = Global.getAnalysisCache().getDatabase(TypeQualifierDatabase.class);
tqa = tqdb.getParameter(calledMethod.getMethodDescriptor(), param, typeQualifierValue);
if (tqa != null) {
interproc = true;
}
}
When when = (tqa != null) ? tqa.when : When.UNKNOWN;
ValueNumber vn = vnaFrame.getArgument(inv, cpg, param, sigParser);
SourceSinkInfo info = new SourceSinkInfo(SourceSinkType.ARGUMENT_TO_CALLED_METHOD, location, vn, when);
info.setParameter(param);
info.setInterproc(interproc);
registerSourceSink(info);
}
}
示例6: modelArguments
import edu.umd.cs.findbugs.ba.XMethod; //导入方法依赖的package包/类
private void modelArguments(Location location) throws DataflowAnalysisException {
// Model arguments to called method
InvokeInstruction inv = (InvokeInstruction) location.getHandle().getInstruction();
XMethod calledMethod = XFactory.createXMethod(inv, cpg);
SignatureParser sigParser = new SignatureParser(calledMethod.getSignature());
if (sigParser.getNumParameters() == 0)
return;
ValueNumberFrame vnaFrame = vnaDataflow.getFactAtLocation(location);
if (!vnaFrame.isValid()) {
// AnalysisContext.logError("bad vna frame in " + xmethod +
// " at location " + location.getHandle().getPosition() +
// " calling " + calledMethod);
return;
}
if (TypeQualifierDataflowAnalysis.isIdentifyFunctionForTypeQualifiers(calledMethod))
return;
for (int param = 0; param < calledMethod.getNumParams(); param++) {
TypeQualifierAnnotation tqa = TypeQualifierApplications.getEffectiveTypeQualifierAnnotation(calledMethod, param,
typeQualifierValue);
boolean interproc = false;
if (TypeQualifierDatabase.USE_DATABASE && tqa == null) {
// See if there's an entry for this parameter
// in the interprocedural type qualifier database.
TypeQualifierDatabase tqdb = Global.getAnalysisCache().getDatabase(TypeQualifierDatabase.class);
tqa = tqdb.getParameter(calledMethod.getMethodDescriptor(), param, typeQualifierValue);
if (tqa != null) {
interproc = true;
}
}
When when = (tqa != null) ? tqa.when : When.UNKNOWN;
ValueNumber vn = vnaFrame.getArgument(inv, cpg, param, sigParser);
SourceSinkInfo info = new SourceSinkInfo(SourceSinkType.ARGUMENT_TO_CALLED_METHOD, location, vn, when);
info.setParameter(param);
info.setInterproc(interproc);
registerSourceSink(info);
}
}
开发者ID:OpenNTF,项目名称:FindBug-for-Domino-Designer,代码行数:48,代码来源:BackwardTypeQualifierDataflowAnalysis.java
示例7: 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);
}