protected AssertionMethods getAssertionMethods(IAnalysisCache analysisCache, ClassDescriptor classDescriptor) throws CheckedAnalysisException { return analysisCache.getClassAnalysis(AssertionMethods.class, classDescriptor); }
/** * Get the Subtypes2 inheritance hierarchy database. */ public Subtypes2 getSubtypes2() { return Global.getAnalysisCache().getDatabase(Subtypes2.class); }
protected LoadedFieldSet getLoadedFieldSet(IAnalysisCache analysisCache, MethodDescriptor methodDescriptor) throws CheckedAnalysisException { return analysisCache.getMethodAnalysis(LoadedFieldSet.class, methodDescriptor); } }
@Override public boolean matches(Type t) { if (!(t instanceof ReferenceType)) { return false; } IAnalysisCache analysisCache = Global.getAnalysisCache(); Subtypes2 subtypes2 = analysisCache.getDatabase(Subtypes2.class); try { return subtypes2.isSubtype((ReferenceType) t, supertype); } catch (ClassNotFoundException e) { analysisCache.getErrorLogger().reportMissingClass(e); return false; } }
@Override public ObligationDataflow analyze(IAnalysisCache analysisCache, MethodDescriptor methodDescriptor) throws CheckedAnalysisException { CFG cfg = analysisCache.getMethodAnalysis(CFG.class, methodDescriptor); DepthFirstSearch dfs = analysisCache.getMethodAnalysis(DepthFirstSearch.class, methodDescriptor); XMethod xmethod = XFactory.createXMethod(methodDescriptor); ConstantPoolGen cpg = analysisCache.getClassAnalysis(ConstantPoolGen.class, methodDescriptor.getClassDescriptor()); ObligationPolicyDatabase database = analysisCache.getDatabase(ObligationPolicyDatabase.class); TypeDataflow typeDataflow = analysisCache.getMethodAnalysis(TypeDataflow.class, methodDescriptor); IsNullValueDataflow invDataflow = analysisCache.getMethodAnalysis(IsNullValueDataflow.class, methodDescriptor); analysisCache.getErrorLogger()); ObligationDataflow dataflow = new ObligationDataflow(cfg, analysis); Profiler profiler = analysisCache.getProfiler(); profiler.start(analysis.getClass()); try {
@Override public CFG analyze(IAnalysisCache analysisCache, MethodDescriptor descriptor) throws CheckedAnalysisException { MethodGen methodGen = analysisCache.getMethodAnalysis(MethodGen.class, descriptor); if (methodGen == null) { JavaClass jclass = analysisCache.getClassAnalysis(JavaClass.class, descriptor.getClassDescriptor()); Method method = analysisCache.getMethodAnalysis(Method.class, descriptor); JavaClassAndMethod javaClassAndMethod = new JavaClassAndMethod(jclass, method); AnalysisContext.currentAnalysisContext().getLookupFailureCallback().reportSkippedAnalysis(descriptor); analysisCache.eagerlyPutMethodAnalysis(CFG.class, descriptor, cfg); TypeDataflow typeDataflow = analysisCache.getMethodAnalysis(TypeDataflow.class, descriptor); JavaClass jclass = analysisCache.getClassAnalysis(JavaClass.class, descriptor.getClassDescriptor()); Method method = analysisCache.getMethodAnalysis(Method.class, descriptor); ConstantPoolGen cpg = analysisCache.getClassAnalysis(ConstantPoolGen.class, descriptor.getClassDescriptor()); TypeDataflow typeDataflow = analysisCache.getMethodAnalysis(TypeDataflow.class, descriptor); Global.getAnalysisCache().purgeMethodAnalyses(descriptor);
private DataflowResult<DataflowType> compute(TypeQualifierValue<?> typeQualifierValue) { DataflowResult<DataflowType> result = new DataflowResult<>(); try { IAnalysisCache analysisCache = Global.getAnalysisCache(); DepthFirstSearch dfs = analysisCache.getMethodAnalysis(DepthFirstSearch.class, methodDescriptor); XMethod xmethod = XFactory.createXMethod(methodDescriptor); CFG cfg = analysisCache.getMethodAnalysis(CFG.class, methodDescriptor); ValueNumberDataflow vnaDataflow = analysisCache.getMethodAnalysis(ValueNumberDataflow.class, methodDescriptor); ConstantPoolGen cpg = analysisCache.getClassAnalysis(ConstantPoolGen.class, methodDescriptor.getClassDescriptor()); DataflowType dataflow = getDataflow(dfs, xmethod, cfg, vnaDataflow, cpg, analysisCache, methodDescriptor, typeQualifierValue); result.dataflow = dataflow; if (TypeQualifierDatabase.USE_DATABASE) { try { populateDatabase(dataflow, vnaDataflow, xmethod, typeQualifierValue); } catch (DataflowAnalysisException e) { analysisCache.getErrorLogger().logError("Error populating type qualifier database", e); } } } catch (CheckedAnalysisException e) { result.checkedException = e; } catch (RuntimeException e) { result.runtimeException = e; } return result; }
for (ClassDescriptor desc : referencedClassSet) { try { XClass info = Global.getAnalysisCache().getClassAnalysis(XClass.class, desc); factory.intern(info); } catch (CheckedAnalysisException e) { OutEdges<ClassDescriptor> outEdges = e -> { try { XClass classNameAndInfo = Global.getAnalysisCache().getClassAnalysis(XClass.class, e); return classNameAndInfo.getCalledClassDescriptors(); } catch (CheckedAnalysisException e2) { Global.getAnalysisCache().purgeAllMethodAnalysis(); Global.getAnalysisCache().purgeClassAnalysis(FBClassReader.class); for (ClassDescriptor classDescriptor : classCollection) { long classStartNanoTime = 0; logRecoverableException(classDescriptor, detector, e); } catch (MissingClassException e) { Global.getAnalysisCache().getErrorLogger().reportMissingClass(e.getClassDescriptor()); } catch (CheckedAnalysisException e) { logRecoverableException(classDescriptor, detector, e);
@Override public void registerWith(IAnalysisCache analysisCache) { analysisCache.registerMethodAnalysisEngine(CFG.class, this); } }
public static SourceLineAnnotation fromVisitedInstruction(MethodDescriptor methodDescriptor, int position) { try { IAnalysisCache analysisCache = Global.getAnalysisCache(); JavaClass jclass = analysisCache.getClassAnalysis(JavaClass.class, methodDescriptor.getClassDescriptor()); Method method = analysisCache.getMethodAnalysis(Method.class, methodDescriptor); return fromVisitedInstruction(jclass, method, position); } catch (CheckedAnalysisException e) { return createReallyUnknown(methodDescriptor.getClassDescriptor().toDottedClassName()); } }
@Override public ClassNode analyze(IAnalysisCache analysisCache, ClassDescriptor descriptor) throws CheckedAnalysisException { ClassReader classReader = analysisCache.getClassAnalysis(ClassReader.class, descriptor); ICodeBaseEntry entry = analysisCache.getClassPath().lookupResource(descriptor.toResourceName()); // One of the less-than-ideal features of ASM is that // invalid classfile format is indicated by a // random runtime exception rather than something // indicative of the real problem. try { ClassNode cn = new ClassNode(); classReader.accept(cn, 0); return cn; } catch (RuntimeException e) { throw new InvalidClassFileFormatException(descriptor, entry, e); } }
@Override public Method analyze(IAnalysisCache analysisCache, MethodDescriptor descriptor) throws CheckedAnalysisException { JavaClass jclass = analysisCache.getClassAnalysis(JavaClass.class, descriptor.getClassDescriptor()); Method[] methodList = jclass.getMethods(); Method result = null; // As a side-effect, cache all of the Methods for this JavaClass for (Method method : methodList) { MethodDescriptor methodDescriptor = DescriptorFactory.instance().getMethodDescriptor( descriptor.getSlashedClassName(), method.getName(), method.getSignature(), method.isStatic()); // Put in cache eagerly analysisCache.eagerlyPutMethodAnalysis(Method.class, methodDescriptor, method); if (methodDescriptor.equals(descriptor)) { result = method; } } return result; }
return m; XClass xClass = Global.getAnalysisCache().getClassAnalysis(XClass.class, desc.getClassDescriptor()); if (xClass == null) { break; ObligationPolicyDatabase database = Global.getAnalysisCache().getOptionalDatabase(ObligationPolicyDatabase.class);
@Override public void report() { if (!Analysis.FIND_EFFECTIVE_RELEVANT_QUALIFIERS) { return; } Global.getAnalysisCache().eagerlyPutDatabase(InterproceduralCallGraph.class, callGraph); } }
method = analysisCache.getMethodAnalysis(Method.class, descriptor); } catch (CheckedAnalysisException e1) { analysisCache.getErrorLogger().logError("Unable to get method for " + descriptor, e1); return null;
@Override public void reportSkippedAnalysis(MethodDescriptor method) { Global.getAnalysisCache().getErrorLogger().reportSkippedAnalysis(method); }
@SuppressWarnings("unchecked") protected Map<AnalysisLocal<T>, T> getMap() { Map<?, ?> m = Global.getAnalysisCache().getAnalysisLocals(); return (Map<AnalysisLocal<T>, T>) m; }
private void killLoadsOfObjectsPassed(InvokeInstruction ins) { try { XMethod called = Hierarchy2.findExactMethod(ins, methodGen.getConstantPool(), Hierarchy.ANY_METHOD); if (called != null ) { NoSideEffectMethodsDatabase nse = Global.getAnalysisCache().getOptionalDatabase(NoSideEffectMethodsDatabase.class); if(nse != null && !nse.is(called.getMethodDescriptor(), MethodSideEffectStatus.SE, MethodSideEffectStatus.OBJ)) { return; } } FieldSummary fieldSummary = AnalysisContext.currentAnalysisContext().getFieldSummary(); Set<XField> touched = fieldSummary.getFieldsWritten(called); if (!touched.isEmpty()) { getFrame().killLoadsOf(touched); } int passed = getNumWordsConsumed(ins); ValueNumber[] arguments = allocateValueNumberArray(passed); getFrame().killLoadsWithSimilarName(ins.getClassName(cpg), ins.getMethodName(cpg)); getFrame().getTopStackWords(arguments); for (ValueNumber v : arguments) { getFrame().killAllLoadsOf(v); } // Too many false-positives for primitives without transitive FieldSummary analysis, // so currently we simply kill any writable primitive on any method call // TODO: implement transitive FieldSummary getFrame().killAllLoads(true); } catch (DataflowAnalysisException e) { AnalysisContext.logError("Error in killLoadsOfObjectsPassed", e); } }
codeBaseEntry = analysisCache.getClassPath().lookupResource(resourceName); } catch (ResourceNotFoundException e) {
@Override public CFG analyze(IAnalysisCache analysisCache, MethodDescriptor descriptor) throws CheckedAnalysisException { MethodGen methodGen = analysisCache.getMethodAnalysis(MethodGen.class, descriptor); if (methodGen == null) { JavaClass jclass = analysisCache.getClassAnalysis(JavaClass.class, descriptor.getClassDescriptor()); Method method = analysisCache.getMethodAnalysis(Method.class, descriptor); JavaClassAndMethod javaClassAndMethod = new JavaClassAndMethod(jclass, method); AnalysisContext.currentAnalysisContext().getLookupFailureCallback().reportSkippedAnalysis(descriptor); analysisCache.eagerlyPutMethodAnalysis(CFG.class, descriptor, cfg); TypeDataflow typeDataflow = analysisCache.getMethodAnalysis(TypeDataflow.class, descriptor); JavaClass jclass = analysisCache.getClassAnalysis(JavaClass.class, descriptor.getClassDescriptor()); Method method = analysisCache.getMethodAnalysis(Method.class, descriptor); ConstantPoolGen cpg = analysisCache.getClassAnalysis(ConstantPoolGen.class, descriptor.getClassDescriptor()); TypeDataflow typeDataflow = analysisCache.getMethodAnalysis(TypeDataflow.class, descriptor); Global.getAnalysisCache().purgeMethodAnalyses(descriptor);