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

JavaCompilerTool.setSourcePath(List) will throw IllegalArgumentException when List is empty

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 6
    • tools
    • generic
    • generic

      JavaCompilerTool.setSourcePath(List) will throw IllegalArgumentException when List is empty
      Please see the testcase ..

      Tried in Solaris SunOS 5.10 Generic sun4u sparc SUNW,Ultra-60
      <java-version>
      bash-3.00$ java -version
      java version "1.6.0-beta"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.6.0-beta-b59a)
      Java HotSpot(TM) Client VM (build 1.6.0-beta-b59a, mixed mode)
      </java-version>

      <testcase>
      import java.io.File;
      import java.util.ArrayList;
      import javax.tools.JavaCompilerTool;
      import javax.tools.JavaFileManager;
      import javax.tools.ToolProvider;

      public class Test11 {
          public static void main(String[] args) {
              JavaCompilerTool javac = ToolProvider.defaultJavaCompiler();
              JavaFileManager jfm = javac.getStandardFileManager();
              javac.setSourcePath(new ArrayList<File>());
          }
      }
      </testcase>
      In the above testcase the list size is zero.
      Output of the code when compiled and run...

      <output>
      bash-3.00$ java Test11
      Exception in thread "main" java.lang.IllegalArgumentException: -sourcepath
              at com.sun.tools.javac.api.Tool.setOption1(Tool.java:188)
              at com.sun.tools.javac.api.Tool.setOption(Tool.java:200)
              at com.sun.tools.javac.api.Tool.setSourcePath(Tool.java:160)
              at Test11.main(Test11.java:11)

      </output>

      This behaviour is not mentioned in API docs
      CompilerAPI should ignore setting of sourcepath if the list is empty, rather throwing IllegalArgumentException.

            Unassigned Unassigned
            savadhansunw Seetharama Avadhanam (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: