1 /* |
1 /* |
2 * Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. |
7 * published by the Free Software Foundation. |
31 import java.io.*; |
31 import java.io.*; |
32 import java.util.Arrays; |
32 import java.util.Arrays; |
33 import javax.tools.*; |
33 import javax.tools.*; |
34 |
34 |
35 public class T6258271 { |
35 public class T6258271 { |
36 public static void main(String... args) { |
36 public static void main(String... args) throws IOException { |
37 JavaCompiler javac = ToolProvider.getSystemJavaCompiler(); |
37 JavaCompiler javac = ToolProvider.getSystemJavaCompiler(); |
38 DiagnosticListener<JavaFileObject> dl = new DiagnosticListener<JavaFileObject>() { |
38 DiagnosticListener<JavaFileObject> dl = new DiagnosticListener<JavaFileObject>() { |
39 public void report(Diagnostic<? extends JavaFileObject> message) { |
39 public void report(Diagnostic<? extends JavaFileObject> message) { |
40 JavaFileObject fo = message.getSource(); |
40 JavaFileObject fo = message.getSource(); |
41 if ("__input".equals(fo.toUri().getPath())) |
41 if ("__input".equals(fo.toUri().getPath())) |
42 throw new AssertionError(fo); |
42 throw new AssertionError(fo); |
43 System.out.println(message); |
43 System.out.println(message); |
44 } |
44 } |
45 }; |
45 }; |
46 StandardJavaFileManager fm = javac.getStandardFileManager(dl, null, null); |
46 try (StandardJavaFileManager fm = javac.getStandardFileManager(dl, null, null)) { |
47 Iterable<? extends JavaFileObject> files = |
47 Iterable<? extends JavaFileObject> files = |
48 fm.getJavaFileObjectsFromStrings(Arrays.asList("nofile.java")); |
48 fm.getJavaFileObjectsFromStrings(Arrays.asList("nofile.java")); |
49 javac.getTask(null, fm, dl, null, null, files).call(); |
49 javac.getTask(null, fm, dl, null, null, files).call(); |
|
50 } |
50 } |
51 } |
51 } |
52 } |