@Override public IClassPathBuilder createClassPathBuilder(IErrorLogger errorLogger) { return new ClassPathBuilder(this, errorLogger); }
@Override public void addCodeBase(ICodeBaseLocator locator, boolean isApplication) { addToWorkList(projectWorkList, new WorkListItem(locator, isApplication, ICodeBase.Discovered.SPECIFIED)); }
private LinkedList<WorkListItem> buildSystemCodebaseList() { // This method is based on the // org.apache.bcel.util.ClassPath.getClassPath() // method. LinkedList<WorkListItem> workList = new LinkedList<>(); String bootClassPath = SystemProperties.getProperty("sun.boot.class.path"); // Seed worklist with system codebases. // addWorkListItemsForClasspath(workList, // SystemProperties.getProperty("java.class.path")); addWorkListItemsForClasspath(workList, bootClassPath); String extPath = SystemProperties.getProperty("java.ext.dirs"); if (extPath != null) { StringTokenizer st = new StringTokenizer(extPath, File.pathSeparator); while (st.hasMoreTokens()) { String extDir = st.nextToken(); addWorkListItemsForExtDir(workList, extDir); } } if(isJava9orLater()){ Path jrtFsJar = Paths.get(System.getProperty("java.home", ""), "lib/jrt-fs.jar"); if(Files.isRegularFile(jrtFsJar)){ addWorkListItemsForClasspath(workList, jrtFsJar.toString()); } } return workList; }
foundJavaLangObject = probeCodeBaseForResource(discoveredCodeBase, "java/lang/Object.class"); foundFindBugsAnnotations = probeCodeBaseForResource(discoveredCodeBase, "edu/umd/cs/findbugs/annotations/Nonnull.class"); foundJSR305Annotations = probeCodeBaseForResource(discoveredCodeBase, "javax/annotation/meta/TypeQualifier.class"); if (DEBUG) { System.out.println("foundJSR305Annotations: " + foundJSR305Annotations); processWorkList(classPath, buildSystemCodebaseList(), progress); if (runningFindBugsFullJar()) { processWorkList(classPath, buildFindBugsFullJarCodebaseList(), progress); return; processWorkList(classPath, buildFindBugsAnnotationCodebaseList(), progress); processWorkList(classPath, buildJSR305AnnotationsCodebaseList(), progress);
InterruptedException { processWorkList(classPath, projectWorkList, progress); locateCodebasesRequiredForAnalysis(classPath, progress); dumpCodeBaseList(classPath.appCodeBaseIterator(), "Application codebases"); dumpCodeBaseList(classPath.auxCodeBaseIterator(), "Auxiliary codebases");
parseClassName(entry); addToWorkList(workList, new WorkListItem(nestedArchiveLocator, codeBase.isApplicationCodeBase(), ICodeBase.Discovered.NESTED));
/** * Create a worklist that will add the FindBugs lib/jsr305.jar to the * classpath. */ private LinkedList<WorkListItem> buildJSR305AnnotationsCodebaseList() { return createFindBugsLibWorkList("jsr305.jar"); }
private LinkedList<WorkListItem> buildSystemCodebaseList() { // This method is based on the // org.apache.bcel.util.ClassPath.getClassPath() // method. LinkedList<WorkListItem> workList = new LinkedList<WorkListItem>(); String bootClassPath = SystemProperties.getProperty("sun.boot.class.path"); // Seed worklist with system codebases. // addWorkListItemsForClasspath(workList, // SystemProperties.getProperty("java.class.path")); addWorkListItemsForClasspath(workList, bootClassPath); String extPath = SystemProperties.getProperty("java.ext.dirs"); if (extPath != null) { StringTokenizer st = new StringTokenizer(extPath, File.pathSeparator); while (st.hasMoreTokens()) { String extDir = st.nextToken(); addWorkListItemsForExtDir(workList, extDir); } } return workList; }
foundJavaLangObject = probeCodeBaseForResource(discoveredCodeBase, "java/lang/Object.class"); foundFindBugsAnnotations = probeCodeBaseForResource(discoveredCodeBase, "edu/umd/cs/findbugs/annotations/Nonnull.class"); foundJSR305Annotations = probeCodeBaseForResource(discoveredCodeBase, "javax/annotation/meta/TypeQualifier.class"); if (DEBUG) { System.out.println("foundJSR305Annotations: " + foundJSR305Annotations); processWorkList(classPath, buildSystemCodebaseList(), progress); if (runningFindBugsFullJar()) { processWorkList(classPath, buildFindBugsFullJarCodebaseList(), progress); return; processWorkList(classPath, buildFindBugsAnnotationCodebaseList(), progress); processWorkList(classPath, buildJSR305AnnotationsCodebaseList(), progress);
InterruptedException { processWorkList(classPath, projectWorkList, progress); locateCodebasesRequiredForAnalysis(classPath, progress); dumpCodeBaseList(classPath.appCodeBaseIterator(), "Application codebases"); dumpCodeBaseList(classPath.auxCodeBaseIterator(), "Auxiliary codebases");
parseClassName(entry); addToWorkList(workList, new WorkListItem(nestedArchiveLocator, codeBase.isApplicationCodeBase(), ICodeBase.Discovered.NESTED));
/** * Create a worklist that will add the FindBugs lib/annotations.jar to the * classpath. */ private LinkedList<WorkListItem> buildFindBugsAnnotationCodebaseList() { return createFindBugsLibWorkList("annotations.jar"); }
/** * Add worklist items from given system classpath. * * @param workList * the worklist * @param path * a system classpath */ private void addWorkListItemsForClasspath(LinkedList<WorkListItem> workList, String path) { if (path == null) { return; } StringTokenizer st = new StringTokenizer(path, File.pathSeparator); while (st.hasMoreTokens()) { String entry = st.nextToken(); if (DEBUG) { System.out.println("System classpath entry: " + entry); } addToWorkList(workList, new WorkListItem(classFactory.createFilesystemCodeBaseLocator(entry), false, ICodeBase.Discovered.IN_SYSTEM_CLASSPATH)); } }
/** * Create a worklist that will add the FindBugs lib/annotations.jar to the * classpath. */ private LinkedList<WorkListItem> buildFindBugsAnnotationCodebaseList() { return createFindBugsLibWorkList("annotations.jar"); }
@Override public IClassPathBuilder createClassPathBuilder(IErrorLogger errorLogger) { return new ClassPathBuilder(this, errorLogger); }
/** * Add worklist items from given extensions directory. * * @param workList * the worklist * @param extDir * an extensions directory */ private void addWorkListItemsForExtDir(LinkedList<WorkListItem> workList, String extDir) { File dir = new File(extDir); File[] fileList = dir.listFiles((FileFilter) pathname -> { String path = pathname.getPath(); boolean isArchive = Archive.isArchiveFileName(path); return isArchive; }); if (fileList == null) { return; } for (File archive : fileList) { addToWorkList(workList, new WorkListItem(classFactory.createFilesystemCodeBaseLocator(archive.getPath()), false, ICodeBase.Discovered.IN_SYSTEM_CLASSPATH)); } }
/** * Create a worklist that will add the FindBugs lib/jsr305.jar to the * classpath. */ private LinkedList<WorkListItem> buildJSR305AnnotationsCodebaseList() { return createFindBugsLibWorkList("jsr305.jar"); }
addToWorkList(workList, new WorkListItem(relativeCodeBaseLocator, false, ICodeBase.Discovered.IN_JAR_MANIFEST));
@Override public void addCodeBase(ICodeBaseLocator locator, boolean isApplication) { addToWorkList(projectWorkList, new WorkListItem(locator, isApplication, ICodeBase.Discovered.SPECIFIED)); }
/** * Add worklist items from given system classpath. * * @param workList * the worklist * @param path * a system classpath */ private void addWorkListItemsForClasspath(LinkedList<WorkListItem> workList, String path) { if (path == null) { return; } StringTokenizer st = new StringTokenizer(path, File.pathSeparator); while (st.hasMoreTokens()) { String entry = st.nextToken(); if (DEBUG) { System.out.println("System classpath entry: " + entry); } addToWorkList(workList, new WorkListItem(classFactory.createFilesystemCodeBaseLocator(entry), false, ICodeBase.Discovered.IN_SYSTEM_CLASSPATH)); } }