本文整理汇总了Java中edu.umd.cs.findbugs.ba.npe.IsNullValue.isDefinitelyNotNull方法的典型用法代码示例。如果您正苦于以下问题:Java IsNullValue.isDefinitelyNotNull方法的具体用法?Java IsNullValue.isDefinitelyNotNull怎么用?Java IsNullValue.isDefinitelyNotNull使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类edu.umd.cs.findbugs.ba.npe.IsNullValue
的用法示例。
在下文中一共展示了IsNullValue.isDefinitelyNotNull方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: findValueKnownNonnullOnBranch
import edu.umd.cs.findbugs.ba.npe.IsNullValue; //导入方法依赖的package包/类
/**
* Clear deref sets of values if this edge is the non-null branch of an if
* comparison.
*
* @param fact
* a datflow fact
* @param edge
* edge to check
* @return possibly-modified dataflow fact
*/
private @CheckForNull
ValueNumber findValueKnownNonnullOnBranch(UnconditionalValueDerefSet fact, Edge edge) {
IsNullValueFrame invFrame = invDataflow.getResultFact(edge.getSource());
if (!invFrame.isValid()) {
return null;
}
IsNullConditionDecision decision = invFrame.getDecision();
if (decision == null) {
return null;
}
IsNullValue inv = decision.getDecision(edge.getType());
if (inv == null || !inv.isDefinitelyNotNull()) {
return null;
}
ValueNumber value = decision.getValue();
if (DEBUG) {
System.out.println("Value number " + value + " is known nonnull on " + edge);
}
return value;
}
示例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;
}
示例4: ignoreExceptionEdge
import edu.umd.cs.findbugs.ba.npe.IsNullValue; //导入方法依赖的package包/类
public boolean ignoreExceptionEdge(Edge edge, Lock resource, ConstantPoolGen cpg) {
try {
Location location = cfg.getExceptionThrowerLocation(edge);
if (DEBUG) {
System.out.println("Exception thrower location: " + location);
}
Instruction ins = location.getHandle().getInstruction();
if (ins instanceof GETFIELD) {
GETFIELD insGetfield = (GETFIELD) ins;
String fieldName = insGetfield.getFieldName(cpg);
if (DEBUG) {
System.out.println("Inspecting GETFIELD of " + fieldName + " at " + location);
}
// Ignore exceptions from getfield instructions where the
// object reference is known not to be null
if (fieldName.equals("lock"))
return true;
IsNullValueFrame frame = isNullDataflow.getFactAtLocation(location);
if (!frame.isValid())
return false;
IsNullValue receiver = frame.getInstance(ins, cpg);
boolean notNull = receiver.isDefinitelyNotNull();
if (DEBUG && notNull) {
System.out.println("Ignoring exception from non-null GETFIELD");
}
return notNull;
} else if (ins instanceof InvokeInstruction) {
InvokeInstruction iins = (InvokeInstruction) ins;
String methodName = iins.getMethodName(cpg);
// System.out.println("Method " + methodName);
if (methodName.startsWith("access$"))
return true;
if (methodName.equals("readLock") || methodName.equals("writeLock"))
return true;
if (methodName.equals("lock") || methodName.equals("unlock"))
return true;
}
if (DEBUG) {
System.out.println("FOUND Exception thrower at: " + location);
}
} catch (DataflowAnalysisException e) {
AnalysisContext.logError("Error while looking for exception edge", e);
}
return false;
}