Class ClassPathBuilder

    • Field Detail

      • VERBOSE

        private static final boolean VERBOSE
      • DEBUG

        private static final boolean DEBUG
      • NO_PARSE_CLASS_NAMES

        private static final boolean NO_PARSE_CLASS_NAMES
      • appClassList

        private final java.util.LinkedList<ClassDescriptor> appClassList
      • scanNestedArchives

        private boolean scanNestedArchives
    • Constructor Detail

      • ClassPathBuilder

        ClassPathBuilder​(IClassFactory classFactory,
                         IErrorLogger errorLogger)
        Constructor.
        Parameters:
        classFactory - the class factory
        errorLogger - the error logger
    • Method Detail

      • addCodeBase

        public void addCodeBase​(ICodeBaseLocator locator,
                                boolean isApplication)
        Description copied from interface: IClassPathBuilder
        Add a project codebase.
        Specified by:
        addCodeBase in interface IClassPathBuilder
        Parameters:
        locator - locator for project codebase
        isApplication - 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 interface IClassPathBuilder
        Parameters:
        scanNestedArchives - true if nested archives should be scanned, false otherwise
      • runningFindBugsFullJar

        private boolean runningFindBugsFullJar()
      • probeCodeBaseForResource

        private boolean probeCodeBaseForResource​(ClassPathBuilder.DiscoveredCodeBase discoveredCodeBase,
                                                 java.lang.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​(java.util.Iterator<? extends ICodeBase> i,
                                      java.lang.String desc)
                               throws java.lang.InterruptedException
        Throws:
        java.lang.InterruptedException
      • isJava9orLater

        private static boolean isJava9orLater()
      • buildFindBugsAnnotationCodebaseList

        private java.util.LinkedList<ClassPathBuilder.WorkListItem> buildFindBugsAnnotationCodebaseList()
        Create a worklist that will add the FindBugs lib/annotations.jar to the classpath.
      • buildJSR305AnnotationsCodebaseList

        private java.util.LinkedList<ClassPathBuilder.WorkListItem> buildJSR305AnnotationsCodebaseList()
        Create a worklist that will add the FindBugs lib/jsr305.jar to the classpath.
      • createFindBugsLibWorkList

        private java.util.LinkedList<ClassPathBuilder.WorkListItem> createFindBugsLibWorkList​(java.lang.String jarFileName)
      • matchesJarFile

        private boolean matchesJarFile​(java.lang.String entry,
                                       java.lang.String jarFileName)
      • addWorkListItemsForClasspath

        private void addWorkListItemsForClasspath​(java.util.LinkedList<ClassPathBuilder.WorkListItem> workList,
                                                  java.lang.String path)
        Add worklist items from given system classpath.
        Parameters:
        workList - the worklist
        path - a system classpath
      • addWorkListItemsForExtDir

        private void addWorkListItemsForExtDir​(java.util.LinkedList<ClassPathBuilder.WorkListItem> workList,
                                               java.lang.String extDir)
        Add worklist items from given extensions directory.
        Parameters:
        workList - the worklist
        extDir - an extensions directory
      • processWorkList

        private void processWorkList​(IClassPath classPath,
                                     java.util.LinkedList<ClassPathBuilder.WorkListItem> workList,
                                     IClassPathBuilderProgress progress)
                              throws java.lang.InterruptedException,
                                     java.io.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 process
        progress - IClassPathBuilderProgress callback
        Throws:
        java.lang.InterruptedException
        java.io.IOException
        ResourceNotFoundException
      • scanCodebase

        private void scanCodebase​(IClassPath classPath,
                                  java.util.LinkedList<ClassPathBuilder.WorkListItem> workList,
                                  ClassPathBuilder.DiscoveredCodeBase discoveredCodeBase)
                           throws java.lang.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 worklist
        discoveredCodeBase - the codebase to scan
        Throws:
        java.lang.InterruptedException
      • parseClassName

        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.
        Parameters:
        entry - the resource
      • scanJarManifestForClassPathEntries

        private void scanJarManifestForClassPathEntries​(java.util.LinkedList<ClassPathBuilder.WorkListItem> workList,
                                                        ICodeBase codeBase)
                                                 throws java.io.IOException
        Check a codebase for a Jar manifest to examine for Class-Path entries.
        Parameters:
        workList - the worklist
        codeBase - the codebase for examine for a Jar manifest
        Throws:
        java.io.IOException
      • addToWorkList

        private void addToWorkList​(java.util.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 worklist
        itemToAdd - the worklist item to add