本文整理汇总了Java中edu.umd.cs.findbugs.ba.LockSet.getNumLockedObjects方法的典型用法代码示例。如果您正苦于以下问题:Java LockSet.getNumLockedObjects方法的具体用法?Java LockSet.getNumLockedObjects怎么用?Java LockSet.getNumLockedObjects使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类edu.umd.cs.findbugs.ba.LockSet
的用法示例。
在下文中一共展示了LockSet.getNumLockedObjects方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: isLocked
import edu.umd.cs.findbugs.ba.LockSet; //导入方法依赖的package包/类
/**
* @param isLocked
* @return
*/
private boolean isLocked() {
try {
if (currentMethod != null && currentLockDataFlow != null && currentCFG != null) {
Collection<Location> tLocations = currentCFG.getLocationsContainingInstructionWithOffset(getPC());
for (Location tLoc : tLocations) {
LockSet lockSet = currentLockDataFlow.getFactAtLocation(tLoc);
if (lockSet.getNumLockedObjects() > 0) {
// within a synchronized block
return true;
}
}
}
} catch (DataflowAnalysisException e) {
reporter.logError("Synchronization check in Static Calendar Detector caught an error.", e);
}
return false;
}
示例2: isLocked
import edu.umd.cs.findbugs.ba.LockSet; //导入方法依赖的package包/类
/**
* @return
*/
private boolean isLocked() {
try {
if (currentMethod != null && currentLockDataFlow != null && currentCFG != null) {
Collection<Location> tLocations = currentCFG.getLocationsContainingInstructionWithOffset(getPC());
for (Location tLoc : tLocations) {
LockSet lockSet = currentLockDataFlow.getFactAtLocation(tLoc);
if (lockSet.getNumLockedObjects() > 0) {
// within a synchronized block
return true;
}
}
}
} catch (DataflowAnalysisException e) {
reporter.logError("Synchronization check in Static Calendar Detector caught an error.", e);
}
return false;
}
示例3: analyzeMethod
import edu.umd.cs.findbugs.ba.LockSet; //导入方法依赖的package包/类
private void analyzeMethod(ClassContext classContext, Method method) throws CFGBuilderException, DataflowAnalysisException {
// System.out.println("Checking " + method);
CFG cfg = classContext.getCFG(method);
LockDataflow lockDataflow = classContext.getLockDataflow(method);
for (Iterator<Location> i = cfg.locationIterator(); i.hasNext();) {
Location location = i.next();
Instruction ins = location.getHandle().getInstruction();
if (!(ins instanceof INVOKESTATIC))
continue;
if (!isSleep((INVOKESTATIC) ins, classContext.getConstantPoolGen()))
continue;
// System.out.println("Found sleep at " + location.getHandle());
LockSet lockSet = lockDataflow.getFactAtLocation(location);
if (lockSet.getNumLockedObjects() > 0) {
bugAccumulator.accumulateBug(
new BugInstance(this, "SWL_SLEEP_WITH_LOCK_HELD", NORMAL_PRIORITY).addClassAndMethod(
classContext.getJavaClass(), method), classContext, method, location);
}
}
bugAccumulator.reportAccumulatedBugs();
}