10
|
1 |
/*
|
5520
|
2 |
* Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
|
10
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
4 |
*
|
|
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
|
|
7 |
* published by the Free Software Foundation.
|
|
8 |
*
|
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT
|
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that
|
|
13 |
* accompanied this code).
|
|
14 |
*
|
|
15 |
* You should have received a copy of the GNU General Public License version
|
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation,
|
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
18 |
*
|
5520
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
|
20 |
* or visit www.oracle.com if you need additional information or have any
|
|
21 |
* questions.
|
10
|
22 |
*/
|
|
23 |
|
|
24 |
/*
|
|
25 |
* @test
|
|
26 |
* @bug 6411333 6400208 6400225 6400267
|
|
27 |
* @summary Ensure 6400208, 6400225, and 6400267 are tested
|
|
28 |
* @author Peter von der Ah\u00e9
|
|
29 |
* @library ../lib
|
|
30 |
* @compile T6411333.java
|
|
31 |
* @run main T6411333
|
|
32 |
*/
|
|
33 |
|
|
34 |
import java.io.IOException;
|
|
35 |
import javax.tools.*;
|
|
36 |
import static javax.tools.StandardLocation.*;
|
|
37 |
import static javax.tools.JavaFileObject.Kind.*;
|
|
38 |
|
|
39 |
// Note: 6400225 (getEffectiveLocation) was dropped eventually.
|
|
40 |
|
|
41 |
public class T6411333 extends ToolTester {
|
|
42 |
|
|
43 |
// 6400208: JSR 199: failure mode for inferBinaryName
|
|
44 |
void testInferBinaryName(String binaryName, boolean fail) {
|
|
45 |
try {
|
|
46 |
JavaFileObject file = fm.getJavaFileForInput(PLATFORM_CLASS_PATH,
|
|
47 |
binaryName,
|
|
48 |
CLASS);
|
|
49 |
String inferred = fm.inferBinaryName(fail ? CLASS_PATH : PLATFORM_CLASS_PATH,
|
|
50 |
file);
|
|
51 |
if (inferred == null && fail)
|
|
52 |
return;
|
|
53 |
if (!inferred.equals(binaryName))
|
|
54 |
throw new AssertionError(String.format("binaryName (%s) != inferred (%s)",
|
|
55 |
binaryName,
|
|
56 |
inferred));
|
|
57 |
} catch (IOException ex) {
|
|
58 |
throw new AssertionError(ex);
|
|
59 |
}
|
|
60 |
}
|
|
61 |
|
|
62 |
// 6400267: JSR 199: specify the exact requirements for relative URIs
|
|
63 |
void testRelativeUri(String name, boolean fail) {
|
|
64 |
try {
|
|
65 |
fm.getFileForInput(SOURCE_OUTPUT, "java.lang", name);
|
|
66 |
} catch (IllegalArgumentException ex) {
|
|
67 |
if (fail)
|
|
68 |
return;
|
|
69 |
} catch (IOException ex) {
|
|
70 |
throw new AssertionError(ex);
|
|
71 |
}
|
|
72 |
if (fail)
|
|
73 |
throw new AssertionError("Expected failure on " + name);
|
|
74 |
}
|
|
75 |
|
|
76 |
void test(String... args) {
|
|
77 |
testInferBinaryName("java.lang.Object", false);
|
|
78 |
testInferBinaryName("java.lang.Object", true);
|
|
79 |
|
|
80 |
testRelativeUri("../util/List.java", true);
|
|
81 |
testRelativeUri("util/List.java", false);
|
|
82 |
testRelativeUri("/util/List.java", true);
|
|
83 |
}
|
|
84 |
public static void main(String... args) {
|
|
85 |
new T6411333().test(args);
|
|
86 |
}
|
|
87 |
}
|