Class URLClassPath
java.lang.Object
edu.umd.cs.findbugs.ba.URLClassPath
- All Implemented Interfaces:
Serializable, AutoCloseable
A work-alike class to use instead of BCEL's ClassPath class. The main
difference is that URLClassPath can load classfiles from URLs.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static interfaceInterface describing a single classpath entry.private static classClasspath entry class to load files from a zip/jar file in the local filesystem.private static classClasspath entry class to load files from a directory in the local filesystem.private static classClasspath entry class to load files from a remote archive URL.private static classClasspath entry class to load files from a remote directory URL. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final List<URLClassPath.Entry> private static final long -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAdd given filename/URL to the classpath.voidclose()Close all underlying resources.Return the classpath string.static StringgetFileExtension(String fileName) Get the file extension of given fileName.private InputStreamgetInputStreamForResource(String resourceName) Open a stream to read given resource.static StringgetURLProtocol(String urlString) Get the URL protocol of given URL string.static booleanisArchiveExtension(String fileExtension) Determine if given file extension indicates an archive file.org.apache.bcel.classfile.JavaClasslookupClass(String className) Look up a class from the classpath.
-
Field Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
entryList
-
classesThatCantBeFound
-
-
Constructor Details
-
URLClassPath
public URLClassPath()Constructor. Creates a classpath with no elements.
-
-
Method Details
-
addURL
Add given filename/URL to the classpath. If no URL protocol is given, the filename is assumed to be a local file or directory. Remote directories must be specified with a "/" character at the end of the URL.- Parameters:
fileName- filename or URL of codebase (directory or archive file)- Throws:
IOException- if entry is invalid or does not exist
-
getClassPath
-
getInputStreamForResource
Open a stream to read given resource.- Parameters:
resourceName- name of resource to load, e.g. "java/lang/Object.class"- Returns:
- input stream to read resource, or null if resource could not be found
- Throws:
IOException- if an IO error occurs trying to determine whether or not the resource exists
-
lookupClass
public org.apache.bcel.classfile.JavaClass lookupClass(String className) throws ClassNotFoundException Look up a class from the classpath.- Parameters:
className- name of class to look up- Returns:
- the JavaClass object for the class
- Throws:
ClassNotFoundException- if the class couldn't be found
-
close
-
getURLProtocol
-
getFileExtension
-
isArchiveExtension
Determine if given file extension indicates an archive file.- Parameters:
fileExtension- the file extension (e.g., ".jar")- Returns:
- true if the file extension indicates an archive, false otherwise
-