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 class
A codebase discovered during classpath building.(package private) static class
Worklist item. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final LinkedList
<ClassDescriptor> private final IClassFactory
private static final boolean
private final LinkedList
<ClassPathBuilder.DiscoveredCodeBase> private final Map
<String, ClassPathBuilder.DiscoveredCodeBase> private final IErrorLogger
private static final boolean
private final LinkedList
<ClassPathBuilder.WorkListItem> private boolean
private static final boolean
-
Constructor Summary
ConstructorsConstructorDescriptionClassPathBuilder
(IClassFactory classFactory, IErrorLogger errorLogger) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addCodeBase
(ICodeBaseLocator locator, boolean isApplication) Add a project codebase.private void
addToWorkList
(LinkedList<ClassPathBuilder.WorkListItem> workList, ClassPathBuilder.WorkListItem itemToAdd) Add a worklist item to the worklist.private void
addWorkListItemsForClasspath
(LinkedList<ClassPathBuilder.WorkListItem> workList, String path) Add worklist items from given system classpath.private void
addWorkListItemsForExtDir
(LinkedList<ClassPathBuilder.WorkListItem> workList, String extDir) Add worklist items from given extensions directory.void
build
(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 void
dumpCodeBaseList
(Iterator<? extends ICodeBase> i, String desc) Get the list of application classes discovered while scanning the classpath.private static boolean
private void
locateCodebasesRequiredForAnalysis
(IClassPath classPath, IClassPathBuilderProgress progress) Make an effort to find the codebases containing any files required for analysis.private boolean
matchesJarFile
(String entry, String jarFileName) private void
parseClassName
(ICodeBaseEntry entry) Attempt to parse data of given resource in order to divine the real name of the class contained in the resource.private boolean
probeCodeBaseForResource
(ClassPathBuilder.DiscoveredCodeBase discoveredCodeBase, String resourceName) Probe a codebase to see if a given source exists in that code base.private void
processWorkList
(IClassPath classPath, LinkedList<ClassPathBuilder.WorkListItem> workList, IClassPathBuilderProgress progress) Process classpath worklist items.private boolean
private void
scanCodebase
(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 void
scanJarManifestForClassPathEntries
(LinkedList<ClassPathBuilder.WorkListItem> workList, ICodeBase codeBase) Check a codebase for a Jar manifest to examine for Class-Path entries.void
scanNestedArchives
(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:IClassPathBuilder
Add a project codebase.- Specified by:
addCodeBase
in 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:IClassPathBuilder
Set whether or not nested archives should be scanned. This should be called before the build() method is called.- Specified by:
scanNestedArchives
in 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:IClassPathBuilder
Build the classpath.- Specified by:
build
in interfaceIClassPathBuilder
- Parameters:
classPath
- IClassPath object to buildprogress
- IClassPathBuilderProgress callback- Throws:
IOException
InterruptedException
CheckedAnalysisException
-
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:
InterruptedException
IOException
ResourceNotFoundException
-
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:IClassPathBuilder
Get the list of application classes discovered while scanning the classpath.- Specified by:
getAppClassList
in interfaceIClassPathBuilder
- Returns:
- list of application classes
-