/** * Set the CodeExceptionGen object. Marks this basic block as the entry * point of an exception handler. * * @param exceptionGen * the CodeExceptionGen object for the block */ public void setExceptionGen(@Nullable TypeMerger m, CodeExceptionGen exceptionGen) { if (this.exceptionGen != null) { AnalysisContext.logError("Multiple exception handlers"); } this.exceptionGen = exceptionGen; }
public void setFieldSummary(@Nonnull FieldSummary fieldSummary) { if (this.fieldSummary != null) { AnalysisContext.logError("Field Summary already set", new IllegalStateException()); } this.fieldSummary = fieldSummary; }
public static void generateRelativeSource(File relativeSourceBase, Project project) { try { SourceLineAnnotation.relativeSourceBase.set(relativeSourceBase.getCanonicalPath()); myProject.set(project); } catch (IOException e) { AnalysisContext.logError("Error resolving relative source base " + relativeSourceBase, e); } }
private static Date parseDate(String releaseDate) { if (releaseDate == null || releaseDate.length() == 0) { return null; } try { SimpleDateFormat releaseDateFormat = new SimpleDateFormat("MM/dd/yyyy hh:mm aa z", Locale.ENGLISH); Date result = releaseDateFormat.parse(releaseDate); return result; } catch (ParseException e) { AnalysisContext.logError("unable to parse date " + releaseDate, e); return null; } }
@Override public void close() { delegateCodeBase.close(); if (!tempFile.delete()) { AnalysisContext.logError("Could not delete " + tempFile); } } }
public Profile getProfile(Class<?> c) { Profile result = profile.get(c); if (result == null) { AnalysisContext.logError("Unexpected null profile for " + c.getName(), new NullPointerException()); result = new Profile(c.getName()); Profile tmp = profile.putIfAbsent(c, result); if (tmp != null) { return tmp; } } return result; }
public FieldSummary getFieldSummary() { if (fieldSummary == null) { AnalysisContext.logError("Field Summary not set", new IllegalStateException()); fieldSummary = new FieldSummary(); } return fieldSummary; }
public void replace(int stackOffset, Item value) { if (stackOffset < 0 || stackOffset >= stack.size()) { AnalysisContext.logError("Can't get replace stack offset " + stackOffset + " from " + stack.toString() + " @ " + v.getPC() + " in " + v.getFullyQualifiedMethodName(), new IllegalArgumentException(stackOffset + " is not a value stack offset")); } int tos = stack.size() - 1; int pos = tos - stackOffset; stack.set(pos, value); }
private static void loadInitialPlugin(URL u, boolean initial, boolean optional) { try { getPluginLoader(u, PluginLoader.class.getClassLoader(), initial, optional); } catch (DuplicatePluginIdException ignored) { assert true; }catch (PluginException e) { AnalysisContext.logError("Unable to load plugin from " + u, e); if (DEBUG) { e.printStackTrace(); } } }
public boolean sourceIsTopOfLoop(@Nonnull Set<Integer> positions) { if (positions == null) { AnalysisContext.logError("Null positions", new NullPointerException("positions can't be null")); return false; } BasicBlock source = getSource(); InstructionHandle sourceInstruction = source.getLastInstruction(); if (sourceInstruction == null) { return false; } return positions.contains(sourceInstruction.getPosition()); }
public static ArrayList<String> getAnalysisOptionProperties(boolean ignoreComments, boolean ignoreBlankLines) { ArrayList<String> resultList = new ArrayList<>(); URL u = DetectorFactoryCollection.getCoreResource("analysisOptions.properties"); if (u != null) { try (BufferedReader reader = UTF8.bufferedReader(u.openStream())) { addCommandLineOptions(resultList, reader, ignoreComments, ignoreBlankLines); } catch (IOException e) { AnalysisContext.logError("unable to load analysisOptions.properties", e); } } return resultList; }
private static void loadPropertiesFromConfigFile() { URL systemProperties = DetectorFactoryCollection.getCoreResource("systemProperties.properties"); loadPropertiesFromURL(systemProperties); String u = System.getProperty("findbugs.loadPropertiesFrom"); if (u != null) { try { URL configURL = new URL(u); loadPropertiesFromURL(configURL); } catch (MalformedURLException e) { AnalysisContext.logError("Unable to load properties from " + u, e); } } }
public String getAbridgedMessage() { BugPattern bugPattern = getBugPattern(); String pattern = getLongDescription().replaceAll(" in \\{1\\}", ""); String shortPattern = bugPattern.getShortDescription(); try { FindBugsMessageFormat format = new FindBugsMessageFormat(pattern); return format.format(annotationList.toArray(new BugAnnotation[annotationList.size()]), getPrimaryClass(), true); } catch (RuntimeException e) { AnalysisContext.logError("Error generating bug msg ", e); return shortPattern + " [Error3 generating customized description]"; } }
@Override public void visitCHECKCAST(CHECKCAST obj) { try { ResourceValueFrame frame = getFrame(); ResourceValue topValue; topValue = frame.getTopValue(); if (topValue.equals(ResourceValue.instance())) { frame.setStatus(ResourceValueFrame.ESCAPED); } } catch (DataflowAnalysisException e) { AnalysisContext.logError("Analysis error", e); } }
@Override public void visitClassContext(ClassContext classContext) { JavaClass javaClass = classContext.getJavaClass(); Method[] methodList = javaClass.getMethods(); for (Method m : methodList) { try { analyzeMethod(m, classContext); } catch (CFGBuilderException | DataflowAnalysisException e) { AnalysisContext.logError("Cannot analyze method", e); } } }
@Override public void finishPass() { HashSet<BugPattern> claimedReported = new HashSet<>(); for (DetectorFactory d : DetectorFactoryCollection.instance().getFactories()) { claimedReported.addAll(d.getReportedBugPatterns()); } for (BugPattern b : DetectorFactoryCollection.instance().getBugPatterns()) { String category = b.getCategory(); if (!b.isDeprecated() && !"EXPERIMENTAL".equals(category) && !claimedReported.contains(b)) { AnalysisContext.logError("No detector claims " + b.getType()); } } }
private void foundInAutogeneratedMethod() { if (annotationList.size() != 2) { return; } priority+=2; setProperty("FOUND_IN_SYNTHETIC_METHOD", "true"); if (SystemProperties.ASSERTIONS_ENABLED && AnalysisContext.analyzingApplicationClass() && priority <= 3) { AnalysisContext.logError("Adding error " + getBugPattern().getType() + " to synthetic method " + getPrimaryMethod()); } }
public void dumpSimpleDataflowInformation(Method method) { try { dumpDataflowInformation(method, getCFG(method), getValueNumberDataflow(method), getIsNullValueDataflow(method), null, null); } catch (DataflowAnalysisException e) { AnalysisContext.logError( "Could not dump data information for " + getJavaClass().getClassName() + "." + method.getName(), e); } catch (CFGBuilderException e) { AnalysisContext.logError( "Could not dump data information for " + getJavaClass().getClassName() + "." + method.getName(), e); } }
private void killLoadsOfObjectsPassed(INVOKEDYNAMIC ins) { try { int passed = getNumWordsConsumed(ins); ValueNumber[] arguments = allocateValueNumberArray(passed); getFrame().getTopStackWords(arguments); for (ValueNumber v : arguments) { getFrame().killAllLoadsOf(v); } } catch (DataflowAnalysisException e) { AnalysisContext.logError("Error in killLoadsOfObjectsPassed", e); } }
public void dumpDataflowInformation(Method method) { try { dumpDataflowInformation(method, getCFG(method), getValueNumberDataflow(method), getIsNullValueDataflow(method), getUnconditionalValueDerefDataflow(method), getTypeDataflow(method)); } catch (DataflowAnalysisException e) { AnalysisContext.logError( "Could not dump data information for " + getJavaClass().getClassName() + "." + method.getName(), e); } catch (CFGBuilderException e) { AnalysisContext.logError( "Could not dump data information for " + getJavaClass().getClassName() + "." + method.getName(), e); } }