Class ClassFinder

java.lang.Object
org.codehaus.groovy.vmplugin.v9.ClassFinder

public class ClassFinder extends Object
Find classes under the specified package via some classpath entry Usage:

   // find classes under `me.sunlan` package via classpath entry(directory) `D:/_APPS/git_apps/java8-labs/out/production/classes/`
   ClassFinder.find(URI.create("file:/D:/_APPS/git_apps/java8-labs/out/production/classes/"), "me/sunlan")

   // find classes under `groovy.lang` package via classpath entry(jar file) `D:/_DEV/Groovy/groovy-3.0.1/lib/groovy-3.0.1.jar`
   ClassFinder.find(URI.create("file:/D:/_DEV/Groovy/groovy-3.0.1/lib/groovy-3.0.1.jar"), "groovy/lang")

   // find classes under `java.lang` package via classpath entry(jrt)
   ClassFinder.find(URI.create("jrt:/modules/java.base/"), "java/lang")

   // find classes under the sub-packages too, e.g. we can get GroovydocHolder via the following code
   ClassFinder.find(URI.create("file:/D:/_DEV/Groovy/groovy-3.0.1/lib/groovy-3.0.1.jar"), "groovy/lang", true)
 
Since:
3.0.2
  • Method Details

    • find

      public static Map<String,Set<String>> find(URI classpathEntryURI, String packageName)
      Returns the found classes
      Parameters:
      classpathEntryURI - the classpath entry
      packageName - the package under which we find classes
      Returns:
      the found classes
      Since:
      3.0.2
    • find

      public static Map<String,Set<String>> find(URI classpathEntryURI, String packageName, boolean recursive)
      Returns the found classes
      Parameters:
      classpathEntryURI - the classpath entry
      packageName - the package under which we find classes
      recursive - whether to find sub-packages
      Returns:
      the found classes
      Since:
      3.0.2
    • find

      public static Map<String,Set<String>> find(URI classpathEntryURI, String packageName, boolean recursive, boolean innerClasses)
      Returns the found classes
      Parameters:
      classpathEntryURI - the classpath entry
      packageName - the package under which we find classes
      recursive - whether to find sub-packages
      innerClasses - whether to find inner classes (class names containing a "$")
      Returns:
      the found classes
      Since:
      5.0.0