Class ClassPathBuilder
java.lang.Object
edu.umd.cs.findbugs.classfile.impl.ClassPathBuilder
- All Implemented Interfaces:
IClassPathBuilder
Implementation of IClassPathBuilder.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static classA codebase discovered during classpath building.(package private) static classWorklist item. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final LinkedList<ClassDescriptor> private final IClassFactoryprivate static final booleanprivate final LinkedList<ClassPathBuilder.DiscoveredCodeBase> private final Map<String, ClassPathBuilder.DiscoveredCodeBase> private final IErrorLoggerprivate static final booleanprivate final LinkedList<ClassPathBuilder.WorkListItem> private booleanprivate static final boolean -
Constructor Summary
ConstructorsConstructorDescriptionClassPathBuilder(IClassFactory classFactory, IErrorLogger errorLogger) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddCodeBase(ICodeBaseLocator locator, boolean isApplication) Add a project codebase.private voidaddToWorkList(LinkedList<ClassPathBuilder.WorkListItem> workList, ClassPathBuilder.WorkListItem itemToAdd) Add a worklist item to the worklist.private voidaddWorkListItemsForClasspath(LinkedList<ClassPathBuilder.WorkListItem> workList, String path) Add worklist items from given system classpath.private voidaddWorkListItemsForExtDir(LinkedList<ClassPathBuilder.WorkListItem> workList, String extDir) Add worklist items from given extensions directory.voidbuild(IClassPath classPath, IClassPathBuilderProgress progress) Build the classpath.private LinkedList<ClassPathBuilder.WorkListItem> Create a worklist that will add the FindBugs lib/annotations.jar to the classpath.private LinkedList<ClassPathBuilder.WorkListItem> private LinkedList<ClassPathBuilder.WorkListItem> Create a worklist that will add the FindBugs lib/jsr305.jar to the classpath.private LinkedList<ClassPathBuilder.WorkListItem> private LinkedList<ClassPathBuilder.WorkListItem> createFindBugsLibWorkList(String jarFileName) private voiddumpCodeBaseList(Iterator<? extends ICodeBase> i, String desc) Get the list of application classes discovered while scanning the classpath.private static booleanprivate voidlocateCodebasesRequiredForAnalysis(IClassPath classPath, IClassPathBuilderProgress progress) Make an effort to find the codebases containing any files required for analysis.private booleanmatchesJarFile(String entry, String jarFileName) private voidparseClassName(ICodeBaseEntry entry) Attempt to parse data of given resource in order to divine the real name of the class contained in the resource.private booleanprobeCodeBaseForResource(ClassPathBuilder.DiscoveredCodeBase discoveredCodeBase, String resourceName) Probe a codebase to see if a given source exists in that code base.private voidprocessWorkList(IClassPath classPath, LinkedList<ClassPathBuilder.WorkListItem> workList, IClassPathBuilderProgress progress) Process classpath worklist items.private booleanprivate voidscanCodebase(IClassPath classPath, LinkedList<ClassPathBuilder.WorkListItem> workList, ClassPathBuilder.DiscoveredCodeBase discoveredCodeBase) Scan given codebase in order to check the codebase for nested archives (adding any found to the worklist) build a list of class resources found in the codebaseprivate voidscanJarManifestForClassPathEntries(LinkedList<ClassPathBuilder.WorkListItem> workList, ICodeBase codeBase) Check a codebase for a Jar manifest to examine for Class-Path entries.voidscanNestedArchives(boolean scanNestedArchives) Set whether or not nested archives should be scanned.
-
Field Details
-
VERBOSE
private static final boolean VERBOSE -
DEBUG
private static final boolean DEBUG -
NO_PARSE_CLASS_NAMES
private static final boolean NO_PARSE_CLASS_NAMES -
classFactory
-
errorLogger
-
projectWorkList
-
discoveredCodeBaseList
-
discoveredCodeBaseMap
-
appClassList
-
scanNestedArchives
private boolean scanNestedArchives
-
-
Constructor Details
-
ClassPathBuilder
ClassPathBuilder(IClassFactory classFactory, IErrorLogger errorLogger) Constructor.- Parameters:
classFactory- the class factoryerrorLogger- the error logger
-
-
Method Details
-
addCodeBase
Description copied from interface:IClassPathBuilderAdd a project codebase.- Specified by:
addCodeBasein interfaceIClassPathBuilder- Parameters:
locator- locator for project codebaseisApplication- true if the codebase is an application codebase, false otherwise
-
scanNestedArchives
public void scanNestedArchives(boolean scanNestedArchives) Description copied from interface:IClassPathBuilderSet whether or not nested archives should be scanned. This should be called before the build() method is called.- Specified by:
scanNestedArchivesin interfaceIClassPathBuilder- Parameters:
scanNestedArchives- true if nested archives should be scanned, false otherwise
-
build
public void build(IClassPath classPath, IClassPathBuilderProgress progress) throws CheckedAnalysisException, IOException, InterruptedException Description copied from interface:IClassPathBuilderBuild the classpath.- Specified by:
buildin interfaceIClassPathBuilder- Parameters:
classPath- IClassPath object to buildprogress- IClassPathBuilderProgress callback- Throws:
IOExceptionInterruptedExceptionCheckedAnalysisException
-
locateCodebasesRequiredForAnalysis
private void locateCodebasesRequiredForAnalysis(IClassPath classPath, IClassPathBuilderProgress progress) throws InterruptedException, IOException, ResourceNotFoundException Make an effort to find the codebases containing any files required for analysis. -
runningFindBugsFullJar
private boolean runningFindBugsFullJar() -
buildFindBugsFullJarCodebaseList
-
probeCodeBaseForResource
private boolean probeCodeBaseForResource(ClassPathBuilder.DiscoveredCodeBase discoveredCodeBase, String resourceName) Probe a codebase to see if a given source exists in that code base.- Parameters:
resourceName- name of a resource- Returns:
- true if the resource exists in the codebase, false if not
-
dumpCodeBaseList
private void dumpCodeBaseList(Iterator<? extends ICodeBase> i, String desc) throws InterruptedException - Throws:
InterruptedException
-
buildSystemCodebaseList
-
isJava9orLater
private static boolean isJava9orLater() -
buildFindBugsAnnotationCodebaseList
Create a worklist that will add the FindBugs lib/annotations.jar to the classpath. -
buildJSR305AnnotationsCodebaseList
Create a worklist that will add the FindBugs lib/jsr305.jar to the classpath. -
createFindBugsLibWorkList
-
matchesJarFile
-
addWorkListItemsForClasspath
private void addWorkListItemsForClasspath(LinkedList<ClassPathBuilder.WorkListItem> workList, String path) Add worklist items from given system classpath.- Parameters:
workList- the worklistpath- a system classpath
-
addWorkListItemsForExtDir
private void addWorkListItemsForExtDir(LinkedList<ClassPathBuilder.WorkListItem> workList, String extDir) Add worklist items from given extensions directory.- Parameters:
workList- the worklistextDir- an extensions directory
-
processWorkList
private void processWorkList(IClassPath classPath, LinkedList<ClassPathBuilder.WorkListItem> workList, IClassPathBuilderProgress progress) throws InterruptedException, IOException, ResourceNotFoundException Process classpath worklist items. We will attempt to find all nested archives and Class-Path entries specified in Jar manifests. This should give us as good an idea as possible of all of the classes available (and which are part of the application).- Parameters:
workList- the worklist to processprogress- IClassPathBuilderProgress callback- Throws:
InterruptedExceptionIOExceptionResourceNotFoundException
-
scanCodebase
private void scanCodebase(IClassPath classPath, LinkedList<ClassPathBuilder.WorkListItem> workList, ClassPathBuilder.DiscoveredCodeBase discoveredCodeBase) throws InterruptedException Scan given codebase in order to- check the codebase for nested archives (adding any found to the worklist)
- build a list of class resources found in the codebase
- Parameters:
workList- the worklistdiscoveredCodeBase- the codebase to scan- Throws:
InterruptedException
-
parseClassName
Attempt to parse data of given resource in order to divine the real name of the class contained in the resource.- Parameters:
entry- the resource
-
scanJarManifestForClassPathEntries
private void scanJarManifestForClassPathEntries(LinkedList<ClassPathBuilder.WorkListItem> workList, ICodeBase codeBase) throws IOException Check a codebase for a Jar manifest to examine for Class-Path entries.- Parameters:
workList- the worklistcodeBase- the codebase for examine for a Jar manifest- Throws:
IOException
-
addToWorkList
private void addToWorkList(LinkedList<ClassPathBuilder.WorkListItem> workList, ClassPathBuilder.WorkListItem itemToAdd) Add a worklist item to the worklist. This method maintains the invariant that all of the worklist items representing application codebases appear before all of the worklist items representing auxiliary codebases.- Parameters:
workList- the worklistitemToAdd- the worklist item to add
-
getAppClassList
Description copied from interface:IClassPathBuilderGet the list of application classes discovered while scanning the classpath.- Specified by:
getAppClassListin interfaceIClassPathBuilder- Returns:
- list of application classes
-