public class JavacFiler extends Object implements Filer, Closeable
createSourceFile("foo.Bar") ... createSourceFile("foo.Bar")is disallowed as is opening a text file that happens to have the same name as a source file:
createSourceFile("foo.Bar") ... createTextFile(SOURCE_TREE, "foo", new File("Bar"), null)
Additionally, creating a source file that corresponds to an already created class file (or vice versa) also results in an IOException since each type can only be created once. However, if the Filer is used to create a text file named *.java that happens to correspond to an existing class file, a warning is *not* generated. Similarly, a warning is not generated for a binary file named *.class and an existing source file.
The reason for this difference is that source files and class files are registered with the tool and can get passed on as declarations to the next round of processing. Files that are just named *.java and *.class are not processed in that manner; although having extra source files and class files on the source path and class path can alter the behavior of the tool and any final compile.
This is NOT part of any supported API. If you write code that depends on this, you do so at your own risk. This code and its internal interfaces are subject to change or deletion without notice.
Modifier and Type | Method and Description |
---|---|
void |
close() |
JavaFileObject |
createClassFile(CharSequence name,
Element... originatingElements) |
FileObject |
createResource(JavaFileManager.Location location,
CharSequence pkg,
CharSequence relativeName,
Element... originatingElements) |
JavaFileObject |
createSourceFile(CharSequence name,
Element... originatingElements) |
void |
displayState()
Debugging function to display internal state.
|
Map<String,JavaFileObject> |
getGeneratedClasses() |
Set<JavaFileObject> |
getGeneratedSourceFileObjects() |
Set<String> |
getGeneratedSourceNames() |
FileObject |
getResource(JavaFileManager.Location location,
CharSequence pkg,
CharSequence relativeName) |
boolean |
newFiles() |
void |
newRound(Context context)
Update internal state for a new round.
|
String |
toString() |
void |
warnIfUnclosedFiles() |
public JavaFileObject createSourceFile(CharSequence name, Element... originatingElements) throws IOException
createSourceFile
in interface Filer
IOException
public JavaFileObject createClassFile(CharSequence name, Element... originatingElements) throws IOException
createClassFile
in interface Filer
IOException
public FileObject createResource(JavaFileManager.Location location, CharSequence pkg, CharSequence relativeName, Element... originatingElements) throws IOException
createResource
in interface Filer
IOException
public FileObject getResource(JavaFileManager.Location location, CharSequence pkg, CharSequence relativeName) throws IOException
getResource
in interface Filer
IOException
public boolean newFiles()
public Set<JavaFileObject> getGeneratedSourceFileObjects()
public Map<String,JavaFileObject> getGeneratedClasses()
public void warnIfUnclosedFiles()
public void newRound(Context context)
public void close()
close
in interface Closeable
close
in interface AutoCloseable
public void displayState()
Copyright © 2017 earcam. All rights reserved.