private void analyzeMethod(ClassContext classContext, Method method) throws CFGBuilderException, DataflowAnalysisException { MethodGen methodGen = classContext.getMethodGen(method); CFG cfg = classContext.getCFG(method); LockDataflow dataflow = classContext.getLockDataflow(method); for (Iterator<Location> j = cfg.locationIterator(); j.hasNext();) { Location location = j.next(); visitLocation(classContext, location, methodGen, dataflow); } }
/** * Execute dataflow analyses (only if required). * * @throws CheckedAnalysisException */ public void execute() throws CheckedAnalysisException { method = Global.getAnalysisCache().getMethodAnalysis(Method.class, methodDescriptor); ClassContext classContext = Global.getAnalysisCache().getClassAnalysis(ClassContext.class, methodDescriptor.getClassDescriptor()); BitSet bytecodeSet = classContext.getBytecodeSet(method); if (bytecodeSet == null) { return; } if (bytecodeSet.get(Const.MONITORENTER) || bytecodeSet.get(Const.MONITOREXIT)) { this.lockDataflow = classContext.getLockDataflow(method); } else if (method.isSynchronized()) { this.vnaDataflow = classContext.getValueNumberDataflow(method); // will // need // this // later } }
@Override public void visitMethod(Method obj) { if (sawDateClass) { try { super.visitMethod(obj); currentMethod = obj; currentLockDataFlow = getClassContext().getLockDataflow(currentMethod); currentCFG = getClassContext().getCFG(currentMethod); } catch (CFGBuilderException e) { reporter.logError("Synchronization check in Static Calendar Detector caught an error.", e); } catch (DataflowAnalysisException e) { reporter.logError("Synchronization check in Static Calendar Detector caught an error.", e); } } }
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(); }
LockDataflow lockDataflow = classContext.getLockDataflow(method); LockSet lockSet = null; boolean sawNEW = false, sawINVOKE = false;
CFG cfg = classContext.getCFG(method); ValueNumberDataflow vnaDataflow = classContext.getValueNumberDataflow(method); LockDataflow dataflow = classContext.getLockDataflow(method);
private void analyzeMethod(ClassContext classContext, Method method) throws CFGBuilderException, DataflowAnalysisException { MethodGen methodGen = classContext.getMethodGen(method); CFG cfg = classContext.getCFG(method); LockDataflow dataflow = classContext.getLockDataflow(method); for (Iterator<Location> j = cfg.locationIterator(); j.hasNext();) { Location location = j.next(); visitLocation(classContext, location, methodGen, dataflow); } }
/** * Execute dataflow analyses (only if required). * * @throws CheckedAnalysisException */ public void execute() throws CheckedAnalysisException { method = Global.getAnalysisCache().getMethodAnalysis(Method.class, methodDescriptor); ClassContext classContext = Global.getAnalysisCache().getClassAnalysis(ClassContext.class, methodDescriptor.getClassDescriptor()); BitSet bytecodeSet = classContext.getBytecodeSet(method); if (bytecodeSet == null) { return; } if (bytecodeSet.get(Constants.MONITORENTER) || bytecodeSet.get(Constants.MONITOREXIT)) { this.lockDataflow = classContext.getLockDataflow(method); } else if (method.isSynchronized()) { this.vnaDataflow = classContext.getValueNumberDataflow(method); // will // need // this // later } }
@Override public void visitMethod(Method obj) { if (sawDateClass) { try { super.visitMethod(obj); currentMethod = obj; currentLockDataFlow = getClassContext().getLockDataflow(currentMethod); currentCFG = getClassContext().getCFG(currentMethod); } catch (CFGBuilderException e) { reporter.logError("Synchronization check in Static Calendar Detector caught an error.", e); } catch (DataflowAnalysisException e) { reporter.logError("Synchronization check in Static Calendar Detector caught an error.", e); } } }
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(); }
LockDataflow lockDataflow = classContext.getLockDataflow(method); LockSet lockSet = null; boolean sawNEW = false, sawINVOKE = false;
CFG cfg = classContext.getCFG(method); ValueNumberDataflow vnaDataflow = classContext.getValueNumberDataflow(method); LockDataflow dataflow = classContext.getLockDataflow(method);