public class MyJavaFileManager extends Object implements JavaFileManager
JavaFileManager.Location| Constructor and Description |
|---|
MyJavaFileManager(StandardJavaFileManager fileManager)
Create a file manager that delegates to the provided instance while
keeping compiled class bytes in memory.
|
| Modifier and Type | Method and Description |
|---|---|
void |
clearBuffers()
Remove all compiled class data from memory.
|
void |
close() |
void |
flush() |
@NotNull Map<String,byte[]> |
getAllBuffers()
Collect all compiled class buffers, blocking until previous compilation
runs finish.
|
ClassLoader |
getClassLoader(JavaFileManager.Location location) |
FileObject |
getFileForInput(JavaFileManager.Location location,
String packageName,
String relativeName) |
FileObject |
getFileForOutput(JavaFileManager.Location location,
String packageName,
String relativeName,
FileObject sibling) |
JavaFileObject |
getJavaFileForInput(JavaFileManager.Location location,
String className,
JavaFileObject.Kind kind)
Return a JavaFileObject backed by the in-memory buffer when the caller
requests a class that has just been compiled to
StandardLocation.CLASS_OUTPUT. |
@NotNull JavaFileObject |
getJavaFileForOutput(JavaFileManager.Location location,
String className,
JavaFileObject.Kind kind,
FileObject sibling)
Store compiled class bytes in the internal buffer and return a sink
that writes into it.
|
boolean |
handleOption(String current,
Iterator<String> remaining) |
boolean |
hasLocation(JavaFileManager.Location location) |
String |
inferBinaryName(JavaFileManager.Location location,
JavaFileObject file) |
String |
inferModuleName(JavaFileManager.Location location)
Reflectively call
inferModuleName if present on the delegate. |
boolean |
isSameFile(FileObject a,
FileObject b) |
int |
isSupportedOption(String option) |
Iterable<JavaFileObject> |
list(JavaFileManager.Location location,
String packageName,
Set<JavaFileObject.Kind> kinds,
boolean recurse) |
Iterable<Set<JavaFileManager.Location>> |
listLocationsForModules(JavaFileManager.Location location)
Invoke
listLocationsForModules reflectively if available. |
public MyJavaFileManager(StandardJavaFileManager fileManager)
fileManager - the underlying file manager to delegate topublic Iterable<Set<JavaFileManager.Location>> listLocationsForModules(JavaFileManager.Location location)
listLocationsForModules reflectively if available.
This method synchronises on the current instance as some JDK
implementations are not thread-safe.location - the location whose modules are requestedpublic String inferModuleName(JavaFileManager.Location location)
inferModuleName if present on the delegate.
As above, the call is synchronised for safety on older JDKs.location - the location to inspectnullpublic ClassLoader getClassLoader(JavaFileManager.Location location)
getClassLoader in interface JavaFileManagerpublic Iterable<JavaFileObject> list(JavaFileManager.Location location, String packageName, Set<JavaFileObject.Kind> kinds, boolean recurse) throws IOException
list in interface JavaFileManagerIOExceptionpublic String inferBinaryName(JavaFileManager.Location location, JavaFileObject file)
inferBinaryName in interface JavaFileManagerpublic boolean isSameFile(FileObject a, FileObject b)
isSameFile in interface JavaFileManagerpublic boolean handleOption(String current, Iterator<String> remaining)
handleOption in interface JavaFileManagerpublic boolean hasLocation(JavaFileManager.Location location)
hasLocation in interface JavaFileManagerpublic JavaFileObject getJavaFileForInput(JavaFileManager.Location location, String className, JavaFileObject.Kind kind) throws IOException
StandardLocation.CLASS_OUTPUT.getJavaFileForInput in interface JavaFileManagerIOException@NotNull public @NotNull JavaFileObject getJavaFileForOutput(JavaFileManager.Location location, String className, JavaFileObject.Kind kind, FileObject sibling)
getJavaFileForOutput in interface JavaFileManagerpublic FileObject getFileForInput(JavaFileManager.Location location, String packageName, String relativeName) throws IOException
getFileForInput in interface JavaFileManagerIOExceptionpublic FileObject getFileForOutput(JavaFileManager.Location location, String packageName, String relativeName, FileObject sibling) throws IOException
getFileForOutput in interface JavaFileManagerIOExceptionpublic void flush()
flush in interface Flushableflush in interface JavaFileManagerpublic void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableclose in interface JavaFileManagerIOExceptionpublic int isSupportedOption(String option)
isSupportedOption in interface OptionCheckerpublic void clearBuffers()
Copyright © 2025. All rights reserved.