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

Compiler API will throw java.lang.IllegalArgumentException for -Werror option

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Cannot Reproduce
    • Icon: P3 P3
    • None
    • 6
    • tools
    • generic
    • generic

      Compiler API will throw java.lang.IllegalArgumentException for -Werror option
      ('-Werror' to treat all compiler warnings as errors).

      Tried in windows JDK build 1.6.0-auto-279
      <java-version>
      E:\javatrails\compilerAPI>java -version
      java version "1.6.0-auto"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.6.0-auto-279)
      Java HotSpot(TM) Client VM (build 1.6.0-ea-b55, mixed mode)
      <\java-version>

      Please see the following code:
      <code>
      import javax.tools.*;

      public class Test21 {
         public static void main(String... args) throws Exception {
              JavaCompilerTool compiler = ToolProvider.defaultJavaCompiler();
              try {
                  compiler.setExtendedOption("-Werror");
              } catch(IllegalArgumentException iae) {
                  System.out.println("Yes... setExtendedOption throws IAE");
              }
              try {
                  compiler.setOption("-Werror");
              } catch(IllegalArgumentException iae) {
                  System.out.println("Yes... setOption throws IAE");
              }
         }
      }
      <\code>

      Output of the code when executed
      <output>
      E:\javatrails\compilerAPI>java Test21
      Yes... setExtendedOption throws IAE
      Yes... setOption throws IAE
      <\output>

      When executed normally , it works fine
      <javac>
      E:\javatrails\compilerAPI>javac -Werror Test21.java

      E:\javatrails\compilerAPI>
      <\javac>

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

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: