本文整理汇总了Java中edu.umd.cs.findbugs.ba.ResourceValueFrame类的典型用法代码示例。如果您正苦于以下问题:Java ResourceValueFrame类的具体用法?Java ResourceValueFrame怎么用?Java ResourceValueFrame使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ResourceValueFrame类属于edu.umd.cs.findbugs.ba包,在下文中一共展示了ResourceValueFrame类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: isStreamOpen
import edu.umd.cs.findbugs.ba.ResourceValueFrame; //导入依赖的package包/类
public boolean isStreamOpen(BasicBlock basicBlock, InstructionHandle handle, ConstantPoolGen cpg, ResourceValueFrame frame) {
if (isOpenOnCreation)
return false;
Instruction ins = handle.getInstruction();
if (!(ins instanceof INVOKESPECIAL))
return false;
// Does this instruction open the stream?
INVOKESPECIAL inv = (INVOKESPECIAL) ins;
return frame.isValid() && getInstanceValue(frame, inv, cpg).isInstance()
&& matchMethod(inv, cpg, this.getResourceClass(), "<init>");
}
示例2: isStreamClose
import edu.umd.cs.findbugs.ba.ResourceValueFrame; //导入依赖的package包/类
public boolean isStreamClose(BasicBlock basicBlock, InstructionHandle handle, ConstantPoolGen cpg, ResourceValueFrame frame,
RepositoryLookupFailureCallback lookupFailureCallback) {
if (!mightCloseStream(basicBlock, handle, cpg))
return false;
Instruction ins = handle.getInstruction();
if ((ins instanceof INVOKEVIRTUAL) || (ins instanceof INVOKEINTERFACE)) {
// Does this instruction close the stream?
InvokeInstruction inv = (InvokeInstruction) ins;
if (!frame.isValid() || !getInstanceValue(frame, inv, cpg).isInstance())
return false;
// It's a close if the invoked class is any subtype of the stream
// base class.
// (Basically, we may not see the exact original stream class,
// even though it's the same instance.)
try {
String classClosed = inv.getClassName(cpg);
return Hierarchy.isSubtype(classClosed, streamBase) || Hierarchy.isSubtype(streamBase, classClosed) ;
} catch (ClassNotFoundException e) {
lookupFailureCallback.reportMissingClass(e);
return false;
}
}
return false;
}
示例3: isResourceClose
import edu.umd.cs.findbugs.ba.ResourceValueFrame; //导入依赖的package包/类
public boolean isResourceClose(BasicBlock basicBlock, InstructionHandle handle, ConstantPoolGen cpg, Lock resource,
ResourceValueFrame frame) throws DataflowAnalysisException {
if (!mightCloseResource(basicBlock, handle, cpg))
return false;
ResourceValue topValue = frame.getTopValue();
return topValue.isInstance();
}
示例4: inspectResult
import edu.umd.cs.findbugs.ba.ResourceValueFrame; //导入依赖的package包/类
@Override
public void inspectResult(ClassContext classContext, MethodGen methodGen, CFG cfg,
Dataflow<ResourceValueFrame, ResourceValueAnalysis<Lock>> dataflow, Lock resource) {
JavaClass javaClass = classContext.getJavaClass();
ResourceValueFrame exitFrame = dataflow.getResultFact(cfg.getExit());
if (DEBUG) {
System.out.println("Resource value at exit: " + exitFrame);
}
int exitStatus = exitFrame.getStatus();
if (exitStatus == ResourceValueFrame.OPEN || exitStatus == ResourceValueFrame.OPEN_ON_EXCEPTION_PATH) {
String bugType;
int priority;
if (exitStatus == ResourceValueFrame.OPEN) {
bugType = "UL_UNRELEASED_LOCK";
priority = HIGH_PRIORITY;
} else {
bugType = "UL_UNRELEASED_LOCK_EXCEPTION_PATH";
priority = NORMAL_PRIORITY;
}
String sourceFile = javaClass.getSourceFileName();
Location location = resource.getLocation();
InstructionHandle handle = location.getHandle();
InstructionHandle nextInstruction = handle.getNext();
if (nextInstruction.getInstruction() instanceof RETURN)
return; // don't report as error; intentional
bugAccumulator.accumulateBug(new BugInstance(this, bugType, priority).addClassAndMethod(methodGen, sourceFile),
SourceLineAnnotation.fromVisitedInstruction(classContext, methodGen, sourceFile, handle));
}
}
示例5: inspectResult
import edu.umd.cs.findbugs.ba.ResourceValueFrame; //导入依赖的package包/类
@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();
}
}
示例6: analyzeMethod
import edu.umd.cs.findbugs.ba.ResourceValueFrame; //导入依赖的package包/类
public void analyzeMethod(ClassContext classContext, Method method, ResourceTrackerType resourceTracker,
ResourceCollection<Resource> resourceCollection) throws CFGBuilderException, DataflowAnalysisException {
MethodGen methodGen = classContext.getMethodGen(method);
if (methodGen == null)
return;
try {
CFG cfg = classContext.getCFG(method);
DepthFirstSearch dfs = classContext.getDepthFirstSearch(method);
if (DEBUG)
System.out.println(SignatureConverter.convertMethodSignature(methodGen));
for (Iterator<Resource> i = resourceCollection.resourceIterator(); i.hasNext();) {
Resource resource = i.next();
ResourceValueAnalysis<Resource> analysis = new ResourceValueAnalysis<Resource>(methodGen, cfg, dfs,
resourceTracker, resource);
Dataflow<ResourceValueFrame, ResourceValueAnalysis<Resource>> dataflow = new Dataflow<ResourceValueFrame, ResourceValueAnalysis<Resource>>(
cfg, analysis);
Profiler profiler = Global.getAnalysisCache().getProfiler();
profiler.start(resourceTracker.getClass());
try {
dataflow.execute();
} finally {
profiler.end(resourceTracker.getClass());
}
inspectResult(classContext, methodGen, cfg, dataflow, resource);
}
} catch (RuntimeException e) {
AnalysisContext.logError("Exception while analyzing " + methodGen.getClassName() + "." + methodGen.getName() + ":"
+ methodGen.getSignature(), e);
}
}
示例7: getInstanceValue
import edu.umd.cs.findbugs.ba.ResourceValueFrame; //导入依赖的package包/类
private ResourceValue getInstanceValue(ResourceValueFrame frame, InvokeInstruction inv, ConstantPoolGen cpg) {
int numConsumed = inv.consumeStack(cpg);
if (numConsumed == Constants.UNPREDICTABLE)
throw new IllegalStateException();
return frame.getValue(frame.getNumSlots() - numConsumed);
}
示例8: transferInstruction
import edu.umd.cs.findbugs.ba.ResourceValueFrame; //导入依赖的package包/类
@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());
}
示例9: isResourceOpen
import edu.umd.cs.findbugs.ba.ResourceValueFrame; //导入依赖的package包/类
public boolean isResourceOpen(BasicBlock basicBlock, InstructionHandle handle, ConstantPoolGen cpg, Stream resource,
ResourceValueFrame frame) {
return resource.isStreamOpen(basicBlock, handle, cpg, frame);
}
示例10: isResourceClose
import edu.umd.cs.findbugs.ba.ResourceValueFrame; //导入依赖的package包/类
public boolean isResourceClose(BasicBlock basicBlock, InstructionHandle handle, ConstantPoolGen cpg, Stream resource,
ResourceValueFrame frame) {
return resource.isStreamClose(basicBlock, handle, cpg, frame, lookupFailureCallback);
}
示例11: transferInstruction
import edu.umd.cs.findbugs.ba.ResourceValueFrame; //导入依赖的package包/类
@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());
}
}
示例12: inspectResult
import edu.umd.cs.findbugs.ba.ResourceValueFrame; //导入依赖的package包/类
public abstract void inspectResult(ClassContext classContext, MethodGen methodGen, CFG cfg,
Dataflow<ResourceValueFrame, ResourceValueAnalysis<Resource>> dataflow, Resource resource);