1 /* |
1 /* |
2 * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2006, 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. |
34 import static javax.tools.JavaFileObject.Kind.*; |
34 import static javax.tools.JavaFileObject.Kind.*; |
35 |
35 |
36 public class T6358955 { |
36 public class T6358955 { |
37 public static void main(String[] args) throws Exception { |
37 public static void main(String[] args) throws Exception { |
38 JavaCompiler compiler = ToolProvider.getSystemJavaCompiler(); |
38 JavaCompiler compiler = ToolProvider.getSystemJavaCompiler(); |
39 StandardJavaFileManager jfm = compiler.getStandardFileManager(null, null, null); |
39 try (StandardJavaFileManager jfm = compiler.getStandardFileManager(null, null, null)) { |
40 |
40 |
41 File dir = new File("temp" + args.hashCode()); |
41 File dir = new File("temp" + args.hashCode()); |
42 if (!dir.exists()) |
42 if (!dir.exists()) |
43 dir.mkdir(); |
43 dir.mkdir(); |
44 if (!dir.isDirectory()) |
44 if (!dir.isDirectory()) |
45 throw new AssertionError("Not a directory " + dir); |
45 throw new AssertionError("Not a directory " + dir); |
46 |
46 |
47 try { |
|
48 jfm.setLocation(StandardLocation.CLASS_OUTPUT, |
|
49 Arrays.asList(dir.getCanonicalFile().getParentFile())); |
|
50 try { |
47 try { |
51 jfm.getFileForInput(StandardLocation.CLASS_OUTPUT, "", dir.getPath()); |
48 jfm.setLocation(StandardLocation.CLASS_OUTPUT, |
52 throw new AssertionError("IllegalArgumentException not thrown"); |
49 Arrays.asList(dir.getCanonicalFile().getParentFile())); |
53 } catch (IllegalArgumentException e) { |
50 try { |
54 System.out.println("OK: " + e.getLocalizedMessage()); |
51 jfm.getFileForInput(StandardLocation.CLASS_OUTPUT, "", dir.getPath()); |
55 } |
52 throw new AssertionError("IllegalArgumentException not thrown"); |
56 try { |
53 } catch (IllegalArgumentException e) { |
57 jfm.getJavaFileObjectsFromFiles(Arrays.asList(dir)); |
54 System.out.println("OK: " + e.getLocalizedMessage()); |
58 throw new AssertionError("IllegalArgumentException not thrown"); |
55 } |
59 } catch (IllegalArgumentException e) { |
56 try { |
60 System.out.println("OK: " + e.getLocalizedMessage()); |
57 jfm.getJavaFileObjectsFromFiles(Arrays.asList(dir)); |
61 } |
58 throw new AssertionError("IllegalArgumentException not thrown"); |
62 } finally { |
59 } catch (IllegalArgumentException e) { |
63 try { |
60 System.out.println("OK: " + e.getLocalizedMessage()); |
64 dir.delete(); // cleanup |
61 } |
65 } catch (Throwable t) { |
62 } finally { |
66 t.printStackTrace(); |
63 try { |
|
64 dir.delete(); // cleanup |
|
65 } catch (Throwable t) { |
|
66 t.printStackTrace(); |
|
67 } |
67 } |
68 } |
68 } |
69 } |
69 } |
70 } |
70 } |
71 } |