@Override public boolean prescreen(ClassContext classContext, Method method, boolean mightClose) { if (!mightClose) { return false; } BitSet bytecodeSet = classContext.getBytecodeSet(method); if (bytecodeSet == null) { return false; } MethodGen methodGen = classContext.getMethodGen(method); return methodGen != null && methodGen.getName().toLowerCase().indexOf("lock") == -1 && (bytecodeSet.get(Const.INVOKEVIRTUAL) || bytecodeSet.get(Const.INVOKEINTERFACE)); }
private static String getFullMethodName(MethodGen methodGen) { String methodNameWithSignature = methodGen.getName() + methodGen.getSignature(); String slashedClassName = methodGen.getClassName().replace('.', '/'); return slashedClassName + "." + methodNameWithSignature; }
/** * Constructor. * * @param rdfs * the reverse depth-first-search (for the block order) * @param cfg * the CFG for the method * @param methodGen * the MethodGen for the method * @param vnaDataflow * @param assertionMethods * AssertionMethods for the analyzed class */ public UnconditionalValueDerefAnalysis(ReverseDepthFirstSearch rdfs, DepthFirstSearch dfs, CFG cfg, Method method, MethodGen methodGen, ValueNumberDataflow vnaDataflow, AssertionMethods assertionMethods) { super(rdfs, dfs); this.cfg = cfg; this.methodGen = methodGen; this.method = method; this.vnaDataflow = vnaDataflow; this.assertionMethods = assertionMethods; if (DEBUG) { System.out.println("UnconditionalValueDerefAnalysis analysis " + methodGen.getClassName() + "." + methodGen.getName() + " : " + methodGen.getSignature()); } }
private void lockOp(LockSet fact, int lockNumber, int delta) { int value = fact.getLockCount(lockNumber); if (value < 0) { return; } value += delta; if (value < 0) { value = LockSet.BOTTOM; } if (DEBUG) { System.out.println("Setting " + lockNumber + " to " + value + " in " + methodGen.getClassName() + "." + methodGen.getName()); } fact.setLockCount(lockNumber, value); }
/** * Convenience method for generating a method signature in human readable * form. * * @param methodGen * the method to produce a method signature for */ public static String convertMethodSignature(MethodGen methodGen) { return convertMethodSignature(methodGen.getClassName(), methodGen.getName(), methodGen.getSignature()); }
public LockAnalysis(MethodGen methodGen, ValueNumberDataflow vnaDataflow, DepthFirstSearch dfs) { super(dfs); this.methodGen = methodGen; this.vnaDataflow = vnaDataflow; this.vna = vnaDataflow.getAnalysis(); this.isSynchronized = methodGen.isSynchronized(); this.isStatic = methodGen.isStatic(); if (DEBUG) { System.out.println("Analyzing Locks in " + methodGen.getClassName() + "." + methodGen.getName()); } }
public static XMethod createXMethod(MethodGen methodGen) { String className = methodGen.getClassName(); String methodName = methodGen.getName(); String methodSig = methodGen.getSignature(); int accessFlags = methodGen.getAccessFlags(); return createXMethod(className, methodName, methodSig, accessFlags); }
/** * Look up the Method represented by given MethodGen. * * @param methodGen * a MethodGen * @return the Method represented by the MethodGen */ public Method getMethod(MethodGen methodGen) { Method[] methodList = jclass.getMethods(); for (Method method : methodList) { if (method.getName().equals(methodGen.getName()) && method.getSignature().equals(methodGen.getSignature()) && method.getAccessFlags() == methodGen.getAccessFlags()) { return method; } } return null; }
/** * Constructor. * * @param method * TODO * @param methodGen * the MethodGen whose CFG we'll be analyzing * @param cfg * the control flow graph * @param dfs * DepthFirstSearch of the method * @param typeMerger * object to merge types * @param lookupFailureCallback * lookup failure callback * @param exceptionSetFactory * factory for creating ExceptionSet objects */ public TypeAnalysis(Method method, MethodGen methodGen, CFG cfg, DepthFirstSearch dfs, TypeMerger typeMerger, RepositoryLookupFailureCallback lookupFailureCallback, ExceptionSetFactory exceptionSetFactory) { this(method, methodGen, cfg, dfs, typeMerger, new TypeFrameModelingVisitor(methodGen.getConstantPool(), typeMerger), lookupFailureCallback, exceptionSetFactory); if (TypeFrameModelingVisitor.DEBUG) { System.out.println(methodGen.getClassName() + "." + methodGen.getName() + " " + methodGen.getSignature()); } }
public ValueNumberAnalysis(MethodGen methodGen, DepthFirstSearch dfs, LoadedFieldSet loadedFieldSet, RepositoryLookupFailureCallback lookupFailureCallback) { super(dfs); this.methodGen = methodGen; this.factory = new ValueNumberFactory(); ValueNumberCache cache = new ValueNumberCache(); this.visitor = new ValueNumberFrameModelingVisitor(methodGen, factory, cache, loadedFieldSet, lookupFailureCallback); int numLocals = methodGen.getMaxLocals(); this.entryLocalValueList = new ValueNumber[numLocals]; for (int i = 0; i < numLocals; ++i) { this.entryLocalValueList[i] = factory.createFreshValue(); } this.exceptionHandlerValueNumberMap = new IdentityHashMap<>(); // For non-static methods, keep track of which value represents the // "this" reference if (!methodGen.isStatic()) { this.thisValue = entryLocalValueList[0]; } this.factAtLocationMap = new HashMap<>(); this.factAfterLocationMap = new HashMap<>(); if (DEBUG) { System.out.println("VNA Analysis " + methodGen.getClassName() + "." + methodGen.getName() + " : " + methodGen.getSignature()); } }
public IsNullValueAnalysis(MethodDescriptor descriptor, MethodGen methodGen, CFG cfg, ValueNumberDataflow vnaDataflow, TypeDataflow typeDataflow, DepthFirstSearch dfs, AssertionMethods assertionMethods) { super(dfs); this.trackValueNumbers = AnalysisContext.currentAnalysisContext().getBoolProperty( AnalysisFeatures.TRACK_VALUE_NUMBERS_IN_NULL_POINTER_ANALYSIS); this.methodGen = methodGen; this.visitor = new IsNullValueFrameModelingVisitor(methodGen.getConstantPool(), assertionMethods, vnaDataflow, typeDataflow, trackValueNumbers); this.vnaDataflow = vnaDataflow; this.cfg = cfg; this.locationWhereValueBecomesNullSet = new HashSet<>(); this.pointerEqualityCheck = getForPointerEqualityCheck(cfg, vnaDataflow); if (DEBUG) { System.out.println("IsNullValueAnalysis for " + methodGen.getClassName() + "." + methodGen.getName() + " : " + methodGen.getSignature()); } }
/** * Add a method annotation. If this is the first method annotation added, it * becomes the primary method annotation. If the method has source line * information, then a SourceLineAnnotation is added to the method. * * @param methodGen * the MethodGen object for the method * @param sourceFile * source file method is defined in * @return this object */ @Nonnull public BugInstance addMethod(MethodGen methodGen, String sourceFile) { String className = methodGen.getClassName(); MethodAnnotation methodAnnotation = new MethodAnnotation(className, methodGen.getName(), methodGen.getSignature(), methodGen.isStatic()); addMethod(methodAnnotation); addSourceLinesForMethod(methodAnnotation, SourceLineAnnotation.fromVisitedMethod(methodGen, sourceFile)); return this; }
System.out.println("Method: " + methodGen.getName() + " - " + methodGen.getSignature() + "in class " + methodGen.getClassName());
AnalysisContext.logError("Exception while analyzing " + methodGen.getClassName() + "." + methodGen.getName() + ":" + methodGen.getSignature(), e);
String invoking = iins.getName(cpg); if ( comparatorMethod(invoking) || booleanComparisonMethod(invoking) ) { if (methodGen.getName().toLowerCase().indexOf("test") >= 0) { break;
throw new IllegalArgumentException("Invalid frame in " + methodGen.getClassName() + "." + methodGen.getName() + " : " + methodGen.getSignature());
System.out.println(this.getClass().getName() + " iteration: " + numIterations + ", timestamp: " + timestamp); MethodGen mg = cfg.getMethodGen(); System.out.println(mg.getClassName() + "." + mg.getName() + mg.getSignature()); System.out.println("----------------------------------------------------------------------"); System.out.println(this.getClass().getName() + " iteration: " + numIterations + ", timestamp: " + timestamp); MethodGen mg = cfg.getMethodGen(); System.out.println(mg.getClassName() + "." + mg.getName() + mg.getSignature()); new RuntimeException("Quiescence achieved----------------------------------------------------------------") .printStackTrace(System.out);
return; String fullMethodName = methodGen.getClassName() + "." + methodGen.getName();
String methodId = methodGen.getClassName() + "." + methodGen.getName() + ":" + methodGen.getSignature(); System.out.println("CC: getting refined CFG for " + methodId); String methodId = methodGen.getClassName() + "." + methodGen.getName() + ":" + methodGen.getSignature(); System.out.println("ClassContext: request to prune " + methodId);
XMethod xm = XFactory.createXMethod(methodGen.getClassName(), methodGen.getName(), methodGen.getSignature(), methodGen.isStatic()); INullnessAnnotationDatabase db = AnalysisContext.currentAnalysisContext().getNullnessAnnotationDatabase();