You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
must have a normalized path component which can be resolved without any process-specific context such as the current directory (file names must be absolute).
According to these rules, the following URIs, for example, are allowed:
file:BobsApp/Test.java (the file name is relative and depend on the current directory)
jar:lib/vendorA.jar!com/vendora/LibraryClass.class (the first half of the path depends on the current directory, whereas the component after ! is legal)
Test.java (this URI depends on the current directory and does not have a schema)
jar:///C:/Documents%20and%20Settings/UncleBob/BobsApp/../lib/vendorA.jar!com/vendora/LibraryClass.class (the path is not normalized)
The javadoc for JavaCompiler gives an example of implementation for a string-based JavaFileObject:
For example, here is how to define a file object which represent source code stored in a string:
/** * A file object used to represent source coming from a string. */publicclassJavaSourceFromStringextendsSimpleJavaFileObject {
/** * The source code of this "file". */finalStringcode;
/** * Constructs a new JavaSourceFromString. * @param name the name of the compilation unit represented by this file object * @param code the source code for the compilation unit represented by this file object */JavaSourceFromString(Stringname, Stringcode) {
super(URI.create("string:///" + name.replace('.','/') + Kind.SOURCE.extension),
Kind.SOURCE);
this.code = code;
}
@OverridepublicCharSequencegetCharContent(booleanignoreEncodingErrors) {
returncode;
}
}
Note how they prefix the URI with "string:///" (it's otherwise equivalent to what JavaFileObjects.forSourceString does).
AFAICT, this is an issue only for forSourceString (and forSourceLines, which ultimately defer to forSourceString), and forResource when the resource is in a JAR (e.g. not if it's a file).
The text was updated successfully, but these errors were encountered:
JavaFileObjects
violatesStandardJavaFileManager
contract wrttoUri
:— Source: http://docs.oracle.com/javase/7/docs/api/javax/tools/StandardJavaFileManager.html
The javadoc for
JavaCompiler
gives an example of implementation for a string-basedJavaFileObject
:Note how they prefix the URI with
"string:///"
(it's otherwise equivalent to whatJavaFileObjects.forSourceString
does).AFAICT, this is an issue only for
forSourceString
(andforSourceLines
, which ultimately defer toforSourceString
), andforResource
when the resource is in a JAR (e.g. not if it's a file).The text was updated successfully, but these errors were encountered: