/** * Determine if given Instruction is a monitor wait. * * @param ins * the Instruction * @param cpg * the ConstantPoolGen for the Instruction * * @return true if the instruction is a monitor wait, false if not */ public static boolean isMonitorWait(Instruction ins, ConstantPoolGen cpg) { if (!(ins instanceof InvokeInstruction)) { return false; } if (ins.getOpcode() == Const.INVOKESTATIC) { return false; } InvokeInstruction inv = (InvokeInstruction) ins; String methodName = inv.getMethodName(cpg); String methodSig = inv.getSignature(cpg); return isMonitorWait(methodName, methodSig); }
public void visitLocation(ClassContext classContext, Location location, MethodGen methodGen, LockDataflow dataflow) throws DataflowAnalysisException { ConstantPoolGen cpg = methodGen.getConstantPool(); if (Hierarchy.isMonitorWait(location.getHandle().getInstruction(), cpg)) { int count = dataflow.getFactAtLocation(location).getNumLockedObjects(); if (count > 1) { // A wait with multiple locks held? String sourceFile = javaClass.getSourceFileName(); possibleWaitBugs.add(new BugInstance(this, "TLW_TWO_LOCK_WAIT", HIGH_PRIORITY).addClassAndMethod(methodGen, sourceFile).addSourceLine(classContext, methodGen, sourceFile, location.getHandle())); } } if (Hierarchy.isMonitorNotify(location.getHandle().getInstruction(), cpg)) { int count = dataflow.getFactAtLocation(location).getNumLockedObjects(); if (count > 1) { // A notify with multiple locks held? String sourceFile = javaClass.getSourceFileName(); possibleNotifyLocations.add(SourceLineAnnotation.fromVisitedInstruction(classContext, methodGen, sourceFile, location.getHandle())); } } }
String methodSig = inv.getSignature(cpg); if (Hierarchy.isMonitorWait(methodName, methodSig) || Hierarchy.isMonitorNotify(methodName, methodSig)) { int numConsumed = inv.consumeStack(cpg); if (numConsumed == Const.UNPREDICTABLE) {
/** * Determine if given Instruction is a monitor wait. * * @param ins * the Instruction * @param cpg * the ConstantPoolGen for the Instruction * * @return true if the instruction is a monitor wait, false if not */ public static boolean isMonitorWait(Instruction ins, ConstantPoolGen cpg) { if (!(ins instanceof InvokeInstruction)) { return false; } if (ins.getOpcode() == Constants.INVOKESTATIC) { return false; } InvokeInstruction inv = (InvokeInstruction) ins; String methodName = inv.getMethodName(cpg); String methodSig = inv.getSignature(cpg); return isMonitorWait(methodName, methodSig); }
public void visitLocation(ClassContext classContext, Location location, MethodGen methodGen, LockDataflow dataflow) throws DataflowAnalysisException { ConstantPoolGen cpg = methodGen.getConstantPool(); if (Hierarchy.isMonitorWait(location.getHandle().getInstruction(), cpg)) { int count = dataflow.getFactAtLocation(location).getNumLockedObjects(); if (count > 1) { // A wait with multiple locks held? String sourceFile = javaClass.getSourceFileName(); possibleWaitBugs.add(new BugInstance(this, "TLW_TWO_LOCK_WAIT", HIGH_PRIORITY).addClassAndMethod(methodGen, sourceFile).addSourceLine(classContext, methodGen, sourceFile, location.getHandle())); } } if (Hierarchy.isMonitorNotify(location.getHandle().getInstruction(), cpg)) { int count = dataflow.getFactAtLocation(location).getNumLockedObjects(); if (count > 1) { // A notify with multiple locks held? String sourceFile = javaClass.getSourceFileName(); possibleNotifyLocations.add(SourceLineAnnotation.fromVisitedInstruction(classContext, methodGen, sourceFile, location.getHandle())); } } }
String methodSig = inv.getSignature(cpg); if (Hierarchy.isMonitorWait(methodName, methodSig) || Hierarchy.isMonitorNotify(methodName, methodSig)) { int numConsumed = inv.consumeStack(cpg); if (numConsumed == Constants.UNPREDICTABLE) {