Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-7057153

Filer.getResource() always throws a FileNotFoundException

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Won't Fix
    • Icon: P4 P4
    • None
    • 7
    • tools
    • x86
    • linux

      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);
          }

            Unassigned Unassigned
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: