本文整理汇总了Java中edu.umd.cs.findbugs.ba.npe.IsNullValue.isDefinitelyNull方法的典型用法代码示例。如果您正苦于以下问题:Java IsNullValue.isDefinitelyNull方法的具体用法?Java IsNullValue.isDefinitelyNull怎么用?Java IsNullValue.isDefinitelyNull使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类edu.umd.cs.findbugs.ba.npe.IsNullValue
的用法示例。
在下文中一共展示了IsNullValue.isDefinitelyNull方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: examineReturnInstruction
import edu.umd.cs.findbugs.ba.npe.IsNullValue; //导入方法依赖的package包/类
private void examineReturnInstruction(Location location) throws DataflowAnalysisException, CFGBuilderException {
if (DEBUG_NULLRETURN) {
System.out.println("Checking null return at " + location);
}
IsNullValueDataflow invDataflow = classContext.getIsNullValueDataflow(method);
IsNullValueFrame frame = invDataflow.getFactAtLocation(location);
ValueNumberFrame vnaFrame = classContext.getValueNumberDataflow(method).getFactAtLocation(location);
if (!vnaFrame.isValid())
return;
ValueNumber valueNumber = vnaFrame.getTopValue();
if (!frame.isValid())
return;
IsNullValue tos = frame.getTopValue();
if (tos.isDefinitelyNull()) {
BugAnnotation variable = ValueNumberSourceInfo.findAnnotationFromValueNumber(method, location, valueNumber, vnaFrame,
"VALUE_OF");
String bugPattern = "NP_NONNULL_RETURN_VIOLATION";
int priority = NORMAL_PRIORITY;
if (tos.isDefinitelyNull() && !tos.isException())
priority = HIGH_PRIORITY;
String methodName = method.getName();
if (methodName.equals("clone")) {
bugPattern = "NP_CLONE_COULD_RETURN_NULL";
priority = NORMAL_PRIORITY;
} else if (methodName.equals("toString")) {
bugPattern = "NP_TOSTRING_COULD_RETURN_NULL";
priority = NORMAL_PRIORITY;
}
BugInstance warning = new BugInstance(this, bugPattern, priority).addClassAndMethod(classContext.getJavaClass(),
method).addOptionalAnnotation(variable);
bugAccumulator.accumulateBug(warning, SourceLineAnnotation.fromVisitedInstruction(classContext, method, location));
}
}
示例2: reportPotentialDereference
import edu.umd.cs.findbugs.ba.npe.IsNullValue; //导入方法依赖的package包/类
public static boolean reportPotentialDereference(Location location, IsNullValueFrame invFrame)
throws DataflowAnalysisException {
if (!invFrame.isValid())
return false;
IsNullValue value = invFrame.getTopValue();
if (value.isDefinitelyNotNull())
return false;
if (value.isDefinitelyNull())
return false;
return true;
}
示例3: reportDereference
import edu.umd.cs.findbugs.ba.npe.IsNullValue; //导入方法依赖的package包/类
private static boolean reportDereference(IsNullValue value) {
if (value.isDefinitelyNotNull())
return false;
if (value.isDefinitelyNull())
return false;
if (IGNORE_DEREF_OF_NCP && value.isNullOnComplicatedPath())
return false;
return true;
}