FULL PRODUCT VERSION :
A DESCRIPTION OF THE PROBLEM :
When using a javax.annotation.processing.Filer.getResource() com.sun.tools.javac.processing.JavacFiler.getResource() always throws a FileNotFoundException due to using the javax.tools.JavaFileManager.getFileForInput() instead of getFileForOutput().
Here is a link to the change log where the it happened http://hg.openjdk.java.net/jdk7/jdk7/langtools/diff/f3323b1c65ee/src/share/classes/com/sun/tools/javac/processing/JavacFiler.java.
REGRESSION. Last worked in version 7
REPRODUCIBILITY :
This bug can be reproduced always.
CUSTOMER SUBMITTED WORKAROUND :
Compile OpenJDK with the following change to com.sun.tools.javac.processing.JavacFiler.
public FileObject getResource(JavaFileManager.Location location,
CharSequence pkg,
CharSequence relativeName) throws IOException {
String strPkg = pkg.toString();
if (strPkg.length() > 0)
checkName(strPkg);
// TODO: Only support reading resources in selected output
// locations? Only allow reading of non-source, non-class
// files from the supported input locations?
//FileObject fileObject = fileManager.getFileForInput(location,
// pkg.toString(),
// relativeName.toString());
FileObject fileObject = fileManager.getFileForOutput(location, pkg.toString(), relativeName.toString(), null);
if (fileObject == null) {
String name = (pkg.length() == 0)
? relativeName.toString() : (pkg + "/" + relativeName);
throw new FileNotFoundException(name);
}
// If the path was already opened for writing, throw an exception.
checkFileReopening(fileObject, false);
return new FilerInputFileObject(fileObject);
}
A DESCRIPTION OF THE PROBLEM :
When using a javax.annotation.processing.Filer.getResource() com.sun.tools.javac.processing.JavacFiler.getResource() always throws a FileNotFoundException due to using the javax.tools.JavaFileManager.getFileForInput() instead of getFileForOutput().
Here is a link to the change log where the it happened http://hg.openjdk.java.net/jdk7/jdk7/langtools/diff/f3323b1c65ee/src/share/classes/com/sun/tools/javac/processing/JavacFiler.java.
REGRESSION. Last worked in version 7
REPRODUCIBILITY :
This bug can be reproduced always.
CUSTOMER SUBMITTED WORKAROUND :
Compile OpenJDK with the following change to com.sun.tools.javac.processing.JavacFiler.
public FileObject getResource(JavaFileManager.Location location,
CharSequence pkg,
CharSequence relativeName) throws IOException {
String strPkg = pkg.toString();
if (strPkg.length() > 0)
checkName(strPkg);
// TODO: Only support reading resources in selected output
// locations? Only allow reading of non-source, non-class
// files from the supported input locations?
//FileObject fileObject = fileManager.getFileForInput(location,
// pkg.toString(),
// relativeName.toString());
FileObject fileObject = fileManager.getFileForOutput(location, pkg.toString(), relativeName.toString(), null);
if (fileObject == null) {
String name = (pkg.length() == 0)
? relativeName.toString() : (pkg + "/" + relativeName);
throw new FileNotFoundException(name);
}
// If the path was already opened for writing, throw an exception.
checkFileReopening(fileObject, false);
return new FilerInputFileObject(fileObject);
}
- relates to
-
JDK-6929404 Filer.getResource(SOURCE_PATH, ...) does not work when -sourcepath contains >1 entry
-
- Closed
-