Details
Description
FULL PRODUCT VERSION :
A DESCRIPTION OF THE PROBLEM :
The specification of JavaCompiler.getTask() states that IllegalArgumentException is thrown when:
IllegalArgumentException - if any of the given compilation units are of other kind than source
See: http://java.sun.com/javase/6/docs/api/javax/tools/JavaCompiler.html#getTask(java.io.Writer,%20javax.tools.JavaFileManager,%20javax.tools.DiagnosticListener,%20java.lang.Iterable,%20java.lang.Iterable,%20java.lang.Iterable)
However, the following program illustrates that the method may also throw IllegalArgumentException if the options aren't recognized by the compiler:
1 import javax.tools.*;
2 import static java.util.Arrays.asList;
3
4 public class Bug {
5 public static void main(String... args) {
6 JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
7 compiler.getTask(null, // out
8 null, // fileManager
9 null, // diagnosticListner
10 asList("-illegalOption"),
11 null, // classes
12 null); // compilationUnits
13 }
14 }
$ java Bug
Exception in thread "main" java.lang.IllegalArgumentException: invalid flag: -illegalOption
at com.sun.tools.javac.api.JavacTool.processOptions(JavacTool.java:249)
at com.sun.tools.javac.api.JavacTool.getTask(JavacTool.java:220)
at com.sun.tools.javac.api.JavacTool.getTask(JavacTool.java:67)
at Bug.main(Bug.java:7)
REPRODUCIBILITY :
This bug can be reproduced always.
A DESCRIPTION OF THE PROBLEM :
The specification of JavaCompiler.getTask() states that IllegalArgumentException is thrown when:
IllegalArgumentException - if any of the given compilation units are of other kind than source
See: http://java.sun.com/javase/6/docs/api/javax/tools/JavaCompiler.html#getTask(java.io.Writer,%20javax.tools.JavaFileManager,%20javax.tools.DiagnosticListener,%20java.lang.Iterable,%20java.lang.Iterable,%20java.lang.Iterable)
However, the following program illustrates that the method may also throw IllegalArgumentException if the options aren't recognized by the compiler:
1 import javax.tools.*;
2 import static java.util.Arrays.asList;
3
4 public class Bug {
5 public static void main(String... args) {
6 JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
7 compiler.getTask(null, // out
8 null, // fileManager
9 null, // diagnosticListner
10 asList("-illegalOption"),
11 null, // classes
12 null); // compilationUnits
13 }
14 }
$ java Bug
Exception in thread "main" java.lang.IllegalArgumentException: invalid flag: -illegalOption
at com.sun.tools.javac.api.JavacTool.processOptions(JavacTool.java:249)
at com.sun.tools.javac.api.JavacTool.getTask(JavacTool.java:220)
at com.sun.tools.javac.api.JavacTool.getTask(JavacTool.java:67)
at Bug.main(Bug.java:7)
REPRODUCIBILITY :
This bug can be reproduced always.