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>
('-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>