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

JSR 199: javax.tools.JavaFileManager.getJavaFileForOutput doesn't throw expected exception

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Cannot Reproduce
    • Icon: P2 P2
    • 6
    • 6
    • tools
    • generic
    • generic

      javax.tools.JavaFileManager.getJavaFileForOutput(ANNOTATION_PROCESSOR_PATH, "file", HTML ) doesn't throw expected exception UnsupportedOperationException.

      As far as I understand only SOURCE and CLASS kinds are suitable for use in getJavaFileFor{Input/Output}
      If I'm wrong - the spec should be clarified.

      see a test
      -----------
      import javax.tools.*;
      import java.io.*;
      import java.util.Collections;

      public class test11 {

          public static void main(String[] argv){
              JavaCompilerTool compiler = ToolProvider.getSystemJavaCompilerTool();
              StandardJavaFileManager mgr = compiler.getStandardFileManager( new DiagnosticCollector<JavaFileObject>() );
              System.out.println( new File( new File(".").toURI() ).getAbsolutePath() );
              JavaFileManager.Location loc = StandardLocation.ANNOTATION_PROCESSOR_PATH;
              mgr.setLocation(loc, Collections.singleton(new File( new File(".").toURI())));

              try {
                  JavaFileObject f = mgr.getJavaFileForOutput( loc, "file", JavaFileObject.Kind.HTML, null );
                  System.out.println( "result " + f.toUri() );
                  System.out.println( "getJavaFileForOutput should throw UnsupportedOperationException - if the specified kind (HTML) is not supported" );
              } catch( Exception x ){
                  x.printStackTrace(System.out);
              }
          }
      }
      -----------
      result:
      -----------
      Z:\tests>z:/lnks/jdk6/bin/java.exe -cp . test11
      Z:\tests\.
      result file:/Z:/tests/./file.html
      getJavaFileForOutput should throw UnsupportedOperationException - if the specified kind (HTML) is not supported
      -----------
      tests failed:
      api/javax_tools/FileManager/index.html#All[getJavaFileForInput0003]
      api/javax_tools/FileManager/index.html#All[getJavaFileForOutput0003]

            ahe Peter Ahe
            itseytin Igor Tseytin (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: