@Override public ICodeBaseLocator createFilesystemCodeBaseLocator(String pathName) { // Attempt to canonicalize the pathname. // It's not fatal if we can't. try { pathName = new File(pathName).getCanonicalPath(); } catch (IOException e) { // Ignore } return new FilesystemCodeBaseLocator(pathName); }
@Override public ICodeBaseLocator createRelativeCodeBaseLocator(String relativePath) { File path = new File(pathName); if (!path.isDirectory()) { path = path.getParentFile(); } File relativeFile = new File(path, relativePath); return new FilesystemCodeBaseLocator(relativeFile.getPath()); }
private FilesystemCodeBaseLocator buildLocator(File file) throws Exception { return new FilesystemCodeBaseLocator(file.getCanonicalPath()); }
private LinkedList<WorkListItem> buildFindBugsFullJarCodebaseList() { String findbugsFullJar = ClassPathUtil.findCodeBaseInClassPath("findbugs-full.jar", SystemProperties.getProperty("java.class.path")); LinkedList<WorkListItem> workList = new LinkedList<>(); if (findbugsFullJar != null) { // // Found findbugs-full.jar: add it to the aux classpath. // (This is a bit weird, since we only want to resolve a subset // of its classes.) // ICodeBaseLocator loc = new FilesystemCodeBaseLocator(findbugsFullJar); workList.addLast(new WorkListItem(loc, false, ICodeBase.Discovered.IN_SYSTEM_CLASSPATH)); } return workList; }
@Override public ICodeBaseLocator createFilesystemCodeBaseLocator(String pathName) { // Attempt to canonicalize the pathname. // It's not fatal if we can't. try { pathName = new File(pathName).getCanonicalPath(); } catch (IOException e) { // Ignore } return new FilesystemCodeBaseLocator(pathName); }
public Iterable<ICodeBaseLocator> get(Iterable<String> auxilliaryCodeBasePaths) throws IOException { List<ICodeBaseLocator> auxilliaryCodeBaseLocators = new ArrayList<ICodeBaseLocator>(); for (String codeBasePath : auxilliaryCodeBasePaths) { auxilliaryCodeBaseLocators.add(new FilesystemCodeBaseLocator(codeBasePath)); } return unmodifiableList(auxilliaryCodeBaseLocators); }
@Override public ICodeBaseLocator createRelativeCodeBaseLocator(String relativePath) { File path = new File(pathName); if (!path.isDirectory()) { path = path.getParentFile(); } File relativeFile = new File(path, relativePath); return new FilesystemCodeBaseLocator(relativeFile.getPath()); }
private LinkedList<WorkListItem> buildFindBugsFullJarCodebaseList() { String findbugsFullJar = ClassPathUtil.findCodeBaseInClassPath("findbugs-full.jar", SystemProperties.getProperty("java.class.path")); LinkedList<WorkListItem> workList = new LinkedList<WorkListItem>(); if (findbugsFullJar != null) { // // Found findbugs-full.jar: add it to the aux classpath. // (This is a bit weird, since we only want to resolve a subset // of its classes.) // ICodeBaseLocator loc = new FilesystemCodeBaseLocator(findbugsFullJar); workList.addLast(new WorkListItem(loc, false, ICodeBase.Discovered.IN_SYSTEM_CLASSPATH)); } return workList; }
private static void setUpStaticDependenciesWithinFindBugs(BugReporter bugReporter) throws Exception { bugReporter.setPriorityThreshold(Priorities.LOW_PRIORITY); ClassPathImpl classPath = new ClassPathImpl(); IAnalysisCache analysisCache = ClassFactory.instance().createAnalysisCache(classPath, bugReporter); new ClassContextClassAnalysisEngine().registerWith(analysisCache); new edu.umd.cs.findbugs.classfile.engine.asm.EngineRegistrar().registerAnalysisEngines(analysisCache); new edu.umd.cs.findbugs.classfile.engine.bcel.EngineRegistrar().registerAnalysisEngines(analysisCache); new edu.umd.cs.findbugs.classfile.engine.EngineRegistrar().registerAnalysisEngines(analysisCache); registerUserDefined(analysisCache); Global.setAnalysisCacheForCurrentThread(analysisCache); ICodeBaseLocator codeBaseLocator = new FilesystemCodeBaseLocator("."); ICodeBase codeBase = new DirectoryCodeBase(codeBaseLocator, new File(CODEBASE_DIRECTORY)); codeBase.setApplicationCodeBase(true); classPath.addCodeBase(codeBase); addAuxCodeBasesFromClassPath(classPath); IClassFactory classFactory = ClassFactory.instance(); IClassPathBuilder builder = classFactory.createClassPathBuilder(bugReporter); builder.addCodeBase(codeBaseLocator, true); builder.scanNestedArchives(true); IClassPathBuilderProgress progress = new NoOpFindBugsProgress(); builder.build(classPath, progress); List<ClassDescriptor> appClassList = builder.getAppClassList(); AnalysisCacheToAnalysisContextAdapter analysisContext = new AnalysisCacheToAnalysisContextAdapter(); AnalysisContext.setCurrentAnalysisContext(analysisContext); analysisContext.setAppClassList(appClassList); analysisContext.setFieldSummary(new FieldSummary()); }