Class JRTUtil
java.lang.Object
org.aspectj.org.eclipse.jdt.internal.compiler.util.JRTUtil
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
static interface
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic ClassFileReader
getClassfile
(File jrt, String fileName, String module) static ClassFileReader
static byte[]
getClassfileContent
(File jrt, String fileName, String module) static InputStream
getContentFromJrt
(File jrt, String fileName, String module) static CtSym
static FileSystem
getJarFileSystem
(Path path) Convenient method to get access to the given archive as aFileSystem
.static String
getJdkRelease
(File image) static org.aspectj.org.eclipse.jdt.internal.compiler.util.JrtFileSystem
getJrtSystem
(File image) Deprecated.static org.aspectj.org.eclipse.jdt.internal.compiler.util.JrtFileSystem
getJrtSystem
(File image, String release) getModulesDeclaringPackage
(File jrt, String qName, String moduleName) static boolean
hasCompilationUnit
(File jrt, String qualifiedPackageName, String moduleName) static void
reset()
TEST ONLY (use when changing the "modules.to.load" property).static byte[]
safeReadBytes
(Path path) Tries to read all bytes of the file denoted by path, returns null if the file could not be found or if the read was interrupted.static String
sanitizedFileName
(Path path) static void
walkModuleImage
(File image, String release, JRTUtil.JrtFileVisitor<Path> visitor, int notify) static void
walkModuleImage
(File image, JRTUtil.JrtFileVisitor<Path> visitor, int notify) Given the path of a modular image file, this method walks the archive content and notifies the supplied visitor about packages and files visited.
-
Field Details
-
DISABLE_CACHE
public static final boolean DISABLE_CACHE -
PROPAGATE_IO_ERRORS
public static final boolean PROPAGATE_IO_ERRORS -
JAVA_BASE
-
JAVA_BASE_CHAR
public static final char[] JAVA_BASE_CHAR -
JRT_FS_JAR
- See Also:
-
NOTIFY_FILES
public static final int NOTIFY_FILES- See Also:
-
NOTIFY_PACKAGES
public static final int NOTIFY_PACKAGES- See Also:
-
NOTIFY_MODULES
public static final int NOTIFY_MODULES- See Also:
-
NOTIFY_ALL
public static final int NOTIFY_ALL- See Also:
-
-
Constructor Details
-
JRTUtil
public JRTUtil()
-
-
Method Details
-
getJrtSystem
public static org.aspectj.org.eclipse.jdt.internal.compiler.util.JrtFileSystem getJrtSystem(File image) Deprecated.usegetJrtSystem(File, String)
instead- Parameters:
image
- the path to the root of the JRE whose libraries we are interested in.- Returns:
- may return
null
-
getJrtSystem
public static org.aspectj.org.eclipse.jdt.internal.compiler.util.JrtFileSystem getJrtSystem(File image, String release) throws IOException - Parameters:
image
- the path to the root of the JRE whose libraries we are interested in.release
---release
version- Throws:
IOException
-
getJarFileSystem
Convenient method to get access to the given archive as aFileSystem
.Note: if the file system for given archive was already created before, the method will reuse existing file system, otherwise a new
FileSystem
object will be created.The caller should not close returned
FileSystem
as it might be shared with others.- Parameters:
path
- absolute file path to a jar archive- Returns:
- never null
- Throws:
IOException
-
getCtSym
- Throws:
IOException
-
reset
public static void reset()TEST ONLY (use when changing the "modules.to.load" property). -
walkModuleImage
public static void walkModuleImage(File image, JRTUtil.JrtFileVisitor<Path> visitor, int notify) throws IOException Given the path of a modular image file, this method walks the archive content and notifies the supplied visitor about packages and files visited. The file system contains the following top level directories: /modules/$MODULE/$PATH /packages/$PACKAGE/$MODULE The latter provides quick look up of the module that contains a particular package. However, this method only notifies its clients of the entries within the modules (former) sub-directory. Clients can decide which notifications they want to receive. SeeNOTIFY_ALL
,NOTIFY_FILES
,NOTIFY_PACKAGES
andNOTIFY_MODULES
.- Parameters:
image
- a java.io.File handle to the JRT image.visitor
- an instance of JrtFileVisitor to be notified of the entries in the JRT image.notify
- flag indicating the notifications the client is interested in.- Throws:
IOException
-
walkModuleImage
public static void walkModuleImage(File image, String release, JRTUtil.JrtFileVisitor<Path> visitor, int notify) throws IOException - Throws:
IOException
-
getContentFromJrt
public static InputStream getContentFromJrt(File jrt, String fileName, String module) throws IOException - Throws:
IOException
-
getClassfileContent
public static byte[] getClassfileContent(File jrt, String fileName, String module) throws IOException - Throws:
IOException
-
getClassfile
public static ClassFileReader getClassfile(File jrt, String fileName, String module) throws IOException, ClassFormatException - Throws:
IOException
ClassFormatException
-
getClassfile
public static ClassFileReader getClassfile(File jrt, String fileName, String module, Predicate<String> moduleNameFilter) throws IOException, ClassFormatException - Throws:
IOException
ClassFormatException
-
getModulesDeclaringPackage
-
hasCompilationUnit
-
sanitizedFileName
-
safeReadBytes
Tries to read all bytes of the file denoted by path, returns null if the file could not be found or if the read was interrupted.- Returns:
- bytes or null
- Throws:
IOException
- any IO exception other than NoSuchFileException
-
getJdkRelease
- Parameters:
image
- jrt file path- Returns:
- JDK release corresponding to given jrt file, read from "release" file, if available. May return null.
- Throws:
IOException
-
getJrtSystem(File, String)
instead