Package com.atlassian.confluence.util
Class ClasspathUtils
java.lang.Object
com.atlassian.confluence.util.ClasspathUtils
Classpath discovery utilities
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetClassesFromJar
(URL jarUrl) Get a list of class files in the JAR specified by a URL.static ClasspathClasses
Gets a list of JARs from the thread context classloader, and returns a ClasspathClasses object with the class file names and the JARs which they appear in.getClassLoaderClasspath
(ClassLoader classloader) Get the classpath searched for by a particular classloader (only supportsURLClassLoader
s presently)static ClasspathClasses
Gets a list of JARs from the thread context classloader, and returns a ClasspathClasses object with the class file names and the JARs which they appear in.getJarFileFromClass
(Class clazz) If the provided class has been loaded from a jar file, will find the absolute path to that jar file.static URL[]
Deprecated.since 7.0.1static List<ClassLoader>
Get a list of classloaders in the thread context classloader hierarchystatic URL[]
This method will return an array of URLs used by the thread context classloader and its parent classloaders.
-
Constructor Details
-
ClasspathUtils
public ClasspathUtils()
-
-
Method Details
-
getSystemClasspath
Deprecated.since 7.0.1This method will return an array of URLs used by the system classloader.- Returns:
- Array of URLs in classpath lookup order
-
getThreadContextClasspath
This method will return an array of URLs used by the thread context classloader and its parent classloaders.- Returns:
- Array of URLs loaded in the classpath.
-
getThreadContentClassLoaderHierarchy
Get a list of classloaders in the thread context classloader hierarchy- Returns:
- list of classloaders in order of delegation
-
getClassLoaderClasspath
Get the classpath searched for by a particular classloader (only supportsURLClassLoader
s presently)- Parameters:
classloader
- to examine- Returns:
- List of paths searched on by the classloader, or null if the classloader does not support path discovery
-
getClassesFromJar
Get a list of class files in the JAR specified by a URL.- Parameters:
jarUrl
- the URL of a JAR on the classpath, such as one of the items in the list returned bygetClassLoaderClasspath(ClassLoader)
- Returns:
- a List of Strings which are the class files in the JAR, an empty list if the JAR contains no class files or null if the JAR cannot be opened.
-
getClassesInClasspathJars
Gets a list of JARs from the thread context classloader, and returns a ClasspathClasses object with the class file names and the JARs which they appear in. Useful for finding duplicate classes in the classpath.- Returns:
- a ClasspathClasses object contains classes found in JARs on the classpath. If the thread context classloader is not a URLClassLoader, returns null.
- See Also:
-
getFilesInClasspathJars
Gets a list of JARs from the thread context classloader, and returns a ClasspathClasses object with the class file names and the JARs which they appear in. Useful for finding duplicate classes in the classpath.- Returns:
- a ClasspathClasses object contains classes found in JARs on the classpath. If the thread context classloader is not a URLClassLoader, returns null.
- See Also:
-
getJarFileFromClass
If the provided class has been loaded from a jar file, will find the absolute path to that jar file.- Parameters:
clazz
- The jar file that contained the class file that represents this class will be found.
-