Package io.github.classgraph
Class ModuleReaderProxy
java.lang.Object
io.github.classgraph.ModuleReaderProxy
- All Implemented Interfaces:
Closeable,AutoCloseable
A ModuleReader proxy, written using reflection to preserve backwards compatibility with JDK 7 and 8.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static Class<?> ClasscollectorClass = Class.forName("java.util.stream.Collector"); private static ObjectCollectorinvalid input: '<'Object, ?, Listprivate final AutoCloseableThe module reader.private ReflectionUtils -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Calls ModuleReader#close().Use the proxied ModuleReader to find the named resource as a URI.list()Get the list of resources accessible to a ModuleReader.Use the proxied ModuleReader to open the named resource as an InputStream.Use the proxied ModuleReader to open the named resource as a ByteBuffer.voidrelease(ByteBuffer byteBuffer) Release aByteBufferallocated by callingread(String).
-
Field Details
-
moduleReader
The module reader. -
collectorClass
ClasscollectorClass = Class.forName("java.util.stream.Collector"); -
collectorsToList
Collectorinvalid input: '<'Object, ?, List -
reflectionUtils
-
-
Constructor Details
-
ModuleReaderProxy
ModuleReaderProxy(ModuleRef moduleRef) throws IOException Constructor.- Parameters:
moduleRef- the module ref- Throws:
IOException- If an I/O exception occurs.
-
-
Method Details
-
close
public void close()Calls ModuleReader#close().- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-
list
Get the list of resources accessible to a ModuleReader. From the documentation for ModuleReader#list(): "Whether the stream of elements includes names corresponding to directories in the module is module reader specific. In lazy implementations then an IOException may be thrown when using the stream to list the module contents. If this occurs then the IOException will be wrapped in an java.io.UncheckedIOException and thrown from the method that caused the access to be attempted. SecurityException may also be thrown when using the stream to list the module contents and access is denied by the security manager."- Returns:
- A list of the paths of resources in the module.
- Throws:
SecurityException- If the module cannot be accessed.
-
open
Use the proxied ModuleReader to open the named resource as an InputStream.- Parameters:
path- The path to the resource to open.- Returns:
- An
InputStreamfor the content of the resource. - Throws:
SecurityException- If the module cannot be accessed.IllegalArgumentException- If the module cannot be accessed.
-
read
Use the proxied ModuleReader to open the named resource as a ByteBuffer. Callrelease(ByteBuffer)when you have finished with the ByteBuffer.- Parameters:
path- The path to the resource to open.- Returns:
- A
ByteBufferfor the content of the resource. - Throws:
SecurityException- If the module cannot be accessed.OutOfMemoryError- if the resource is larger than 2GB, the maximum capacity of a byte buffer.
-
release
Release aByteBufferallocated by callingread(String).- Parameters:
byteBuffer- TheByteBufferto release.
-
find
Use the proxied ModuleReader to find the named resource as a URI.- Parameters:
path- The path to the resource to open.- Returns:
- A
URIfor the resource. - Throws:
SecurityException- If the module cannot be accessed.
-