@Override public void logError(String message, Throwable e) { Global.getAnalysisCache().getErrorLogger().logError(message, e); }
@Override public void reportMissingClass(ClassNotFoundException ex) { Global.getAnalysisCache().getErrorLogger().reportMissingClass(ex); }
@Override public void logError(String message) { Global.getAnalysisCache().getErrorLogger().logError(message); }
@Override public void reportMissingClass(ClassDescriptor classDescriptor) { Global.getAnalysisCache().getErrorLogger().reportMissingClass(classDescriptor); }
@Override public void reportSkippedAnalysis(MethodDescriptor method) { Global.getAnalysisCache().getErrorLogger().reportSkippedAnalysis(method); }
private void initialize() { initialized = true; IAnalysisCache analysisCache = Global.getAnalysisCache(); Class<? extends Dataflow<Fact,AnalysisType>> cls = null; // First, try loading the dataflow class from the general findBugs code. try { Class<?> c = getClass().getClassLoader().loadClass(dataflowClassName); cls = asDataflowClass(c); } catch (ClassNotFoundException e) { assert true; } if (cls == null) { // Find the dataflow class from the plugin in which it was loaded DetectorFactoryCollection detectorFactoryCollection = analysisCache.getDatabase(DetectorFactoryCollection.class); for (Iterator<Plugin> i = detectorFactoryCollection.pluginIterator(); i.hasNext();) { Plugin plugin = i.next(); try { cls = asDataflowClass(plugin.getClassLoader().loadClass(dataflowClassName)); break; } catch (ClassNotFoundException e) { assert true; } } } if (cls == null) { analysisCache.getErrorLogger().logError("TestDataflowAnalysis: could not load class " + dataflowClassName); return; } dataflowClass = cls; }
@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; } }
/** * Look up an Obligation by type. This returns the first Obligation that is * a supertype of the type given (meaning that the given type could be an * instance of the returned Obligation). * * @param classDescriptor * a ClassDescriptor naming a class type * @return an Obligation that is a supertype of the given type, or null if * there is no such Obligation */ public @CheckForNull Obligation getObligationByType(ClassDescriptor classDescriptor) { try { return getObligationByType(BCELUtil.getObjectTypeInstance(classDescriptor.toDottedClassName())); } catch (ClassNotFoundException e) { Global.getAnalysisCache().getErrorLogger().reportMissingClass(e); return null; } }
method = analysisCache.getMethodAnalysis(Method.class, descriptor); } catch (CheckedAnalysisException e1) { analysisCache.getErrorLogger().logError("Unable to get method for " + descriptor, e1); return null;
/** * Determine whether class named by given ClassDescriptor is an Obligation * type. * * @param classDescriptor * a class * @return true if the class is an Obligation type, false otherwise */ public boolean isObligationType(ClassDescriptor classDescriptor) { try { return getObligationByType(BCELUtil.getObjectTypeInstance(classDescriptor.toDottedClassName())) != null; } catch (ClassNotFoundException e) { Global.getAnalysisCache().getErrorLogger().reportMissingClass(e); return false; } }
/** * Get array of Obligation types corresponding to the parameters of the * given method. * * @param xmethod * a method * @return array of Obligation types for each of the method's parameters; a * null element means the corresponding parameter is not an * Obligation type */ public Obligation[] getParameterObligationTypes(XMethod xmethod) { Type[] paramTypes = Type.getArgumentTypes(xmethod.getSignature()); Obligation[] result = new Obligation[paramTypes.length]; for (int i = 0; i < paramTypes.length; i++) { if (!(paramTypes[i] instanceof ObjectType)) { continue; } try { result[i] = getObligationByType((ObjectType) paramTypes[i]); } catch (ClassNotFoundException e) { Global.getAnalysisCache().getErrorLogger().reportMissingClass(e); } } return result; }
analysisCache.getErrorLogger()); ObligationDataflow dataflow = new ObligationDataflow(cfg, analysis);
logRecoverableException(classDescriptor, detector, e); } catch (MissingClassException e) { Global.getAnalysisCache().getErrorLogger().reportMissingClass(e.getClassDescriptor()); } catch (CheckedAnalysisException e) { logRecoverableException(classDescriptor, detector, e);
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; }
@Override public void logError(String message) { Global.getAnalysisCache().getErrorLogger().logError(message); }
@Override public void reportSkippedAnalysis(MethodDescriptor method) { Global.getAnalysisCache().getErrorLogger().reportSkippedAnalysis(method); }
@Override public void reportMissingClass(ClassNotFoundException ex) { Global.getAnalysisCache().getErrorLogger().reportMissingClass(ex); }
@Override public void reportMissingClass(ClassDescriptor classDescriptor) { Global.getAnalysisCache().getErrorLogger().reportMissingClass(classDescriptor); }
@Override public void logError(String message, Throwable e) { Global.getAnalysisCache().getErrorLogger().logError(message, e); }
@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; } }