42 public static void main(String... args) throws Exception { |
42 public static void main(String... args) throws Exception { |
43 new ReleaseOptionClashes().run(); |
43 new ReleaseOptionClashes().run(); |
44 } |
44 } |
45 |
45 |
46 void run() throws Exception { |
46 void run() throws Exception { |
47 doRunTest("-bootclasspath", "any"); |
47 doRunTest("7", "-bootclasspath", "any"); |
48 doRunTest("-Xbootclasspath:any"); |
48 doRunTest("7", "-Xbootclasspath:any"); |
49 doRunTest("-Xbootclasspath/a:any"); |
49 doRunTest("7", "-Xbootclasspath/a:any"); |
50 doRunTest("-Xbootclasspath/p:any"); |
50 doRunTest("7", "-Xbootclasspath/p:any"); |
51 doRunTest("-endorseddirs", "any"); |
51 doRunTest("7", "-endorseddirs", "any"); |
52 doRunTest("-extdirs", "any"); |
52 doRunTest("7", "-extdirs", "any"); |
53 doRunTest("-source", "8"); |
53 doRunTest("7", "-source", "8"); |
54 doRunTest("-target", "8"); |
54 doRunTest("7", "-target", "8"); |
|
55 doRunTest("9", "--system", "none"); |
|
56 doRunTest("9", "--upgrade-module-path", "any"); |
55 } |
57 } |
56 |
58 |
57 void doRunTest(String... args) throws Exception { |
59 void doRunTest(String release, String... args) throws Exception { |
58 System.out.println("Testing clashes for arguments: " + Arrays.asList(args)); |
60 System.out.println("Testing clashes for arguments: " + Arrays.asList(args)); |
59 Class<?> log = Class.forName("com.sun.tools.javac.util.Log", true, cl); |
61 Class<?> log = Class.forName("com.sun.tools.javac.util.Log", true, cl); |
60 Field useRawMessages = log.getDeclaredField("useRawMessages"); |
62 Field useRawMessages = log.getDeclaredField("useRawMessages"); |
61 useRawMessages.setAccessible(true); |
63 useRawMessages.setAccessible(true); |
62 useRawMessages.setBoolean(null, true); |
64 useRawMessages.setBoolean(null, true); |
63 ByteArrayOutputStream out = new ByteArrayOutputStream(); |
65 ByteArrayOutputStream out = new ByteArrayOutputStream(); |
64 List<String> options = new ArrayList<>(); |
66 List<String> options = new ArrayList<>(); |
65 options.addAll(Arrays.asList("--release", "7")); |
67 options.addAll(Arrays.asList("--release", release)); |
66 options.addAll(Arrays.asList(args)); |
68 options.addAll(Arrays.asList(args)); |
67 options.add(System.getProperty("test.src") + File.separator + "ReleaseOptionClashes.java"); |
69 options.add(System.getProperty("test.src") + File.separator + "ReleaseOptionClashes.java"); |
68 compiler.run(null, null, out, options.toArray(new String[0])); |
70 compiler.run(null, null, out, options.toArray(new String[0])); |
69 useRawMessages.setBoolean(null, false); |
71 useRawMessages.setBoolean(null, false); |
70 if (!out.toString().equals(String.format("%s%n%s%n", |
72 if (!out.toString().equals(String.format("%s%n%s%n", |