equal
deleted
inserted
replaced
1 /* |
1 /* |
2 * Copyright (c) 2006, 2009, 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. |
37 import static javax.tools.JavaFileObject.Kind.CLASS; |
37 import static javax.tools.JavaFileObject.Kind.CLASS; |
38 |
38 |
39 public class Sibling { |
39 public class Sibling { |
40 public static void main(String... args) throws IOException { |
40 public static void main(String... args) throws IOException { |
41 JavaCompiler compiler = ToolProvider.getSystemJavaCompiler(); |
41 JavaCompiler compiler = ToolProvider.getSystemJavaCompiler(); |
42 StandardJavaFileManager fm = compiler.getStandardFileManager(null, null, null); |
42 try (StandardJavaFileManager fm = compiler.getStandardFileManager(null, null, null)) { |
43 JavaFileObject sibling = |
43 JavaFileObject sibling = |
44 fm.getJavaFileObjectsFromFiles(Arrays.asList(new File("Test.java"))) |
44 fm.getJavaFileObjectsFromFiles(Arrays.asList(new File("Test.java"))) |
45 .iterator().next(); |
45 .iterator().next(); |
46 JavaFileObject classFile = fm.getJavaFileForOutput(CLASS_OUTPUT, |
46 JavaFileObject classFile = fm.getJavaFileForOutput(CLASS_OUTPUT, |
47 "foo.bar.baz.Test", |
47 "foo.bar.baz.Test", |
48 CLASS, |
48 CLASS, |
49 sibling); |
49 sibling); |
50 File file = new File("Test.class").getAbsoluteFile(); |
50 File file = new File("Test.class").getAbsoluteFile(); |
51 if (!classFile.toUri().equals(file.toURI())) |
51 if (!classFile.toUri().equals(file.toURI())) |
52 throw new AssertionError("Expected " + file.toURI() + ", got " + |
52 throw new AssertionError("Expected " + file.toURI() + ", got " + |
53 classFile.toUri()); |
53 classFile.toUri()); |
|
54 } |
54 } |
55 } |
55 } |
56 } |