private boolean prescreen(ClassContext classContext, Method method) { BitSet bytecodeSet = classContext.getBytecodeSet(method); if (bytecodeSet == null) { return false; } // method must acquire a lock if (!bytecodeSet.get(Const.MONITORENTER) && !method.isSynchronized()) { return false; } // and contain a static method invocation if (!bytecodeSet.get(Const.INVOKESTATIC)) { return false; } return true; }
@Override public boolean prescreen(Method method, ClassContext classContext) { if (Const.STATIC_INITIALIZER_NAME.equals(method.getName())) { return false; } Code code = method.getCode(); if (code.getCode().length > 5000) { return false; } BitSet bytecodeSet = classContext.getBytecodeSet(method); if (bytecodeSet == null) { return false; } // The pattern requires a get/put pair accessing the same field. boolean hasGetStatic = bytecodeSet.get(Const.GETSTATIC); boolean hasPutStatic = bytecodeSet.get(Const.PUTSTATIC); if (!hasGetStatic || !hasPutStatic) { return false; } // If the method is synchronized, then we'll assume that // things are properly synchronized if (method.isSynchronized()) { return false; } reported.clear(); return true; }
@Override public void visit(Code obj) { count_aload_1 = 0; previousOpcode = -1; previousPreviousOpcode = -1; data.nullTested.clear(); seenInvokeStatic = false; seenMonitorEnter = getMethod().isSynchronized(); data.staticFieldsReadInThisMethod.clear(); super.visit(obj); if (Const.CONSTRUCTOR_NAME.equals(getMethodName()) && count_aload_1 > 1 && (getClassName().indexOf('$') >= 0 || getClassName().indexOf('+') >= 0)) { data.needsOuterObjectInConstructor.add(getDottedClassName()); // System.out.println(betterClassName + // " needs outer object in constructor"); } bugAccumulator.reportAccumulatedBugs(); }
if (method.isSynchronized()) { lockedMethodSet.add(method);
CFG cfg = classContext.getCFG(method); if (method.isSynchronized()) { hasSynchronization = true;
/** * 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 } }
/** * Get LockSet at given Location. * * @param location * the Location * @return the LockSet at that Location * @throws DataflowAnalysisException */ public LockSet getFactAtLocation(Location location) throws DataflowAnalysisException { if (lockDataflow != null) { return lockDataflow.getFactAtLocation(location); } else { LockSet lockSet = cache.get(location); if (lockSet == null) { lockSet = new LockSet(); lockSet.setDefaultLockCount(0); if (method.isSynchronized() && !method.isStatic()) { // LockSet contains just the "this" reference ValueNumber instance = vnaDataflow.getAnalysis().getThisValue(); lockSet.setLockCount(instance.getNumber(), 1); } else { // LockSet is completely empty - nothing to do } cache.put(location, lockSet); } return lockSet; } } }
private boolean prescreen(ClassContext classContext, Method method) { BitSet bytecodeSet = classContext.getBytecodeSet(method); if (bytecodeSet == null) { return false; } // method must acquire a lock if (!bytecodeSet.get(Constants.MONITORENTER) && !method.isSynchronized()) { return false; } // and contain a static method invocation if (!bytecodeSet.get(Constants.INVOKESTATIC)) { return false; } return true; }
/** * implement the visitor to reset the sync count, the stack, and gather some information * * @param obj * the context object for the currently parsed method */ @Override public void visitCode(Code obj) { Method m = getMethod(); if (prescreen(m)) { if (m.isSynchronized()) { syncPC = 0; } else { syncPC = -1; } isStatic = m.isStatic(); unsafeAliases.clear(); unsafeAliases.set(0); branchInfo.clear(); unsafeCallOccurred = false; stack.resetForMethodEntry(this); } }
@Override public void visit(Code obj) { count_aload_1 = 0; previousOpcode = -1; previousPreviousOpcode = -1; data.nullTested.clear(); seenInvokeStatic = false; seenMonitorEnter = getMethod().isSynchronized(); data.staticFieldsReadInThisMethod.clear(); super.visit(obj); if ("<init>".equals(getMethodName()) && count_aload_1 > 1 && (getClassName().indexOf('$') >= 0 || getClassName().indexOf('+') >= 0)) { data.needsOuterObjectInConstructor.add(getDottedClassName()); // System.out.println(betterClassName + // " needs outer object in constructor"); } bugAccumulator.reportAccumulatedBugs(); }
@Override public boolean prescreen(Method method, ClassContext classContext) { if ("<clinit>".equals(method.getName())) { return false; } Code code = method.getCode(); if (code.getCode().length > 5000) { return false; } BitSet bytecodeSet = classContext.getBytecodeSet(method); if (bytecodeSet == null) { return false; } // The pattern requires a get/put pair accessing the same field. boolean hasGetStatic = bytecodeSet.get(Constants.GETSTATIC); boolean hasPutStatic = bytecodeSet.get(Constants.PUTSTATIC); if (!hasGetStatic || !hasPutStatic) { return false; } // If the method is synchronized, then we'll assume that // things are properly synchronized if (method.isSynchronized()) { return false; } reported.clear(); return true; }
/** * implement the visitor to reset the sync count, the stack, and gather some information * * @param obj * the context object for the currently parsed method */ @Override public void visitCode(Code obj) { Method m = getMethod(); if (prescreen(m)) { if (m.isSynchronized()) { syncPC = 0; } else { syncPC = -1; } isStatic = m.isStatic(); unsafeAliases.clear(); unsafeAliases.set(0); branchInfo.clear(); unsafeCallOccurred = false; stack.resetForMethodEntry(this); } }
if (m.isStatic() || m.isSynchronized()) { return true;
if (m.isStatic() || m.isSynchronized()) { return true;
if (method.isSynchronized()) { lockedMethodSet.add(method);
CFG cfg = classContext.getCFG(method); if (method.isSynchronized()) { hasSynchronization = true;
/** * 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 } }
/** * Get LockSet at given Location. * * @param location * the Location * @return the LockSet at that Location * @throws DataflowAnalysisException */ public LockSet getFactAtLocation(Location location) throws DataflowAnalysisException { if (lockDataflow != null) { return lockDataflow.getFactAtLocation(location); } else { LockSet lockSet = cache.get(location); if (lockSet == null) { lockSet = new LockSet(); lockSet.setDefaultLockCount(0); if (method.isSynchronized() && !method.isStatic()) { // LockSet contains just the "this" reference ValueNumber instance = vnaDataflow.getAnalysis().getThisValue(); lockSet.setLockCount(instance.getNumber(), 1); } else { // LockSet is completely empty - nothing to do } cache.put(location, lockSet); } return lockSet; } } }
public boolean isLoader(ClassGen cg) { return cg.getMethods().length == 3 && cg.getMethods()[1].isStatic() && cg.getMethods()[1].isFinal() && cg.getMethods()[1].isPublic() && cg.getMethods()[1].isSynchronized() && cg.getMethods()[1].getReturnType().toString().equals("java.lang.String"); }
if (obj.isStatic()) throw new ClassConstraintException("Abstract method '"+tostring(obj)+"' must not have the ACC_STATIC modifier set."); if (obj.isStrictfp()) throw new ClassConstraintException("Abstract method '"+tostring(obj)+"' must not have the ACC_STRICT modifier set."); if (obj.isSynchronized()) throw new ClassConstraintException("Abstract method '"+tostring(obj)+"' must not have the ACC_SYNCHRONIZED modifier set."); obj.isStatic() || obj.isFinal() || obj.isSynchronized() || obj.isNative() || obj.isStrictfp() ){ obj.isSynchronized() || obj.isNative() || obj.isAbstract() ){