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

JSR 199: JavaFileObject.isNameCompatible throws unspecified exception (IllegalArgumentException)

XMLWordPrintable

    • 6
    • b85
    • generic
    • generic
    • Verified

      javax.tools.JavaFileObject.isNameCompatible throws unspecified exception (IllegalArgumentException).
      (I think it's small mistake in program)

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

      public class test6 {

          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() );
              mgr.setLocation(StandardJavaFileManager.StandardLocation.SOURCE_PATH,
                                  Collections.singleton(new File( new File(".").toURI())));

              try {
                  JavaFileObject f = mgr.getJavaFileForInput(
                              StandardJavaFileManager.StandardLocation.SOURCE_PATH, "test6",
                              JavaFileObject.Kind.SOURCE );
                  if( !f.isNameCompatible("test6", JavaFileObject.Kind.SOURCE) )
                      System.out.println( "isNameCompatible(SOURCE) fails on " + f.toUri() );
                  if( f.isNameCompatible("test6", JavaFileObject.Kind.OTHER) )
                      System.out.println( "isNameCompatible(OTHER) fails on " + f.toUri() );
              } catch( IOException x ){
                  x.printStackTrace(System.out);
              }
              System.out.println( "The test completed successfully if there are no error messages in the output." );
          }
      }
      --------------------
      output:
      --------------------
      Z:\tests>z:/lnks/jdk6/bin/java.exe -cp . test6
      Z:\tests\.
      Exception in thread "main" java.lang.IllegalArgumentException
              at com.sun.tools.javac.util.DefaultFileManager.getExtension(DefaultFileManager.java:187)
              at com.sun.tools.javac.util.DefaultFileManager$RegularFileObject.isNameCompatible(DefaultFileManager.java:1074)
              at test6.main(test6.java:20)
      --------------------
      tests failed
      api/javax_tools/JavaFileObject/index.html#All[isNameCompatible0001]

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

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: