本文整理汇总了Java中edu.umd.cs.findbugs.ba.ResourceValueFrame.CLOSED属性的典型用法代码示例。如果您正苦于以下问题:Java ResourceValueFrame.CLOSED属性的具体用法?Java ResourceValueFrame.CLOSED怎么用?Java ResourceValueFrame.CLOSED使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类edu.umd.cs.findbugs.ba.ResourceValueFrame
的用法示例。
在下文中一共展示了ResourceValueFrame.CLOSED属性的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: inspectResult
@Override
public void inspectResult(ClassContext classContext, MethodGen methodGen, CFG cfg,
Dataflow<ResourceValueFrame, ResourceValueAnalysis<Stream>> dataflow, Stream stream) {
if (DEBUG) {
System.out.printf("Result for %s in %s%n", stream, methodGen);
dataflow.dumpDataflow(dataflow.getAnalysis());
}
ResourceValueFrame exitFrame = dataflow.getResultFact(cfg.getExit());
int exitStatus = exitFrame.getStatus();
if (exitStatus == ResourceValueFrame.OPEN || exitStatus == ResourceValueFrame.OPEN_ON_EXCEPTION_PATH) {
// FIXME: Stream object should be queried for the
// priority.
String bugType = stream.getBugType();
int priority = NORMAL_PRIORITY;
if (exitStatus == ResourceValueFrame.OPEN_ON_EXCEPTION_PATH) {
bugType += "_EXCEPTION_PATH";
priority = LOW_PRIORITY;
}
potentialOpenStreamList.add(new PotentialOpenStream(bugType, priority, stream));
} else if (exitStatus == ResourceValueFrame.CLOSED) {
// Remember that this stream was closed on all paths.
// Later, we will mark all of the streams in its equivalence class
// as having been closed.
stream.setClosed();
}
}
示例2: transferInstruction
@Override
public void transferInstruction(InstructionHandle handle, BasicBlock basicBlock) throws DataflowAnalysisException {
final Instruction ins = handle.getInstruction();
final ConstantPoolGen cpg = getCPG();
final ResourceValueFrame frame = getFrame();
int status = -1;
if (DEBUG)
System.out.println("PC : " + handle.getPosition() + " " + ins);
if (DEBUG && ins instanceof InvokeInstruction) {
InvokeInstruction iins = (InvokeInstruction) ins;
System.out.println(" " + ins.toString(cpg.getConstantPool()));
}
if (DEBUG)
System.out.println("resource frame before instruction: " + frame.toString());
// Is a lock acquired or released by this instruction?
Location creationPoint = lock.getLocation();
if (handle == creationPoint.getHandle() && basicBlock == creationPoint.getBasicBlock()) {
status = ResourceValueFrame.OPEN;
if (DEBUG)
System.out.println("OPEN");
} else if (resourceTracker.isResourceClose(basicBlock, handle, cpg, lock, frame)) {
status = ResourceValueFrame.CLOSED;
if (DEBUG)
System.out.println("CLOSE");
}
// Model use of instance values in frame slots
analyzeInstruction(ins);
final int updatedNumSlots = frame.getNumSlots();
// Mark any appearances of the lock value in the ResourceValueFrame.
ValueNumberFrame vnaFrame = vnaDataflow.getFactAfterLocation(new Location(handle, basicBlock));
if (DEBUG) {
System.out.println("vna frame after instruction: " + vnaFrame.toString());
System.out.println("Lock value number: " + lock.getLockValue());
if (lock.getLockValue().hasFlag(ValueNumber.RETURN_VALUE))
System.out.println("is return value");
}
for (int i = 0; i < updatedNumSlots; ++i) {
if (DEBUG) {
System.out.println("Slot " + i);
System.out.println(" Lock value number: " + vnaFrame.getValue(i));
if (vnaFrame.getValue(i).hasFlag(ValueNumber.RETURN_VALUE))
System.out.println(" is return value");
}
if (vnaFrame.fuzzyMatch(lock.getLockValue(), vnaFrame.getValue(i))) {
if (DEBUG)
System.out.println("Saw lock value!");
frame.setValue(i, ResourceValue.instance());
}
}
// If needed, update frame status
if (status != -1) {
frame.setStatus(status);
}
if (DEBUG)
System.out.println("resource frame after instruction: " + frame.toString());
}
示例3: transferInstruction
@Override
public void transferInstruction(InstructionHandle handle, BasicBlock basicBlock) throws DataflowAnalysisException {
// Record what Location we are analyzing
this.location = new Location(handle, basicBlock);
final Instruction ins = handle.getInstruction();
final ResourceValueFrame frame = getFrame();
int status = -1;
boolean created = false;
// Is a resource created, opened, or closed by this instruction?
Location creationPoint = stream.getLocation();
if (handle == creationPoint.getHandle() && basicBlock == creationPoint.getBasicBlock()) {
// Resource creation
if (stream.isOpenOnCreation()) {
status = ResourceValueFrame.OPEN;
stream.setOpenLocation(location);
resourceTracker.addStreamOpenLocation(location, stream);
} else {
status = ResourceValueFrame.CREATED;
}
created = true;
} else if (resourceTracker.isResourceOpen(basicBlock, handle, cpg, stream, frame)) {
// Resource opened
status = ResourceValueFrame.OPEN;
stream.setOpenLocation(location);
resourceTracker.addStreamOpenLocation(location, stream);
} else if (resourceTracker.isResourceClose(basicBlock, handle, cpg, stream, frame)) {
// Resource closed
status = ResourceValueFrame.CLOSED;
}
// Model use of instance values in frame slots
analyzeInstruction(ins);
// If needed, update frame status
if (status != -1) {
frame.setStatus(status);
if (created)
frame.setValue(frame.getNumSlots() - 1, ResourceValue.instance());
}
}