author | jjg |
Tue, 06 Jan 2015 14:51:10 -0800 | |
changeset 28332 | cd3ea1087d2b |
child 30730 | d3ce7619db2c |
permissions | -rw-r--r-- |
28332
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
diff
changeset
|
1 |
/* |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
diff
changeset
|
2 |
* Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
diff
changeset
|
4 |
* |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
diff
changeset
|
8 |
* |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
diff
changeset
|
13 |
* accompanied this code). |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
diff
changeset
|
14 |
* |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
diff
changeset
|
18 |
* |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
diff
changeset
|
21 |
* questions. |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
diff
changeset
|
22 |
*/ |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
diff
changeset
|
23 |
|
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
diff
changeset
|
24 |
/* |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
diff
changeset
|
25 |
* @test |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
diff
changeset
|
26 |
* @bug 8059977 |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
diff
changeset
|
27 |
* @summary StandardJavaFileManager should support java.nio.file.Path. |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
diff
changeset
|
28 |
* Test get/setLocation methods. |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
diff
changeset
|
29 |
* @build SJFM_TestBase |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
diff
changeset
|
30 |
* @run main SJFM_Locations |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
diff
changeset
|
31 |
*/ |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
diff
changeset
|
32 |
|
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
diff
changeset
|
33 |
import java.io.File; |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
diff
changeset
|
34 |
import java.io.IOException; |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
diff
changeset
|
35 |
import java.nio.file.Path; |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
diff
changeset
|
36 |
import java.nio.file.Paths; |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
diff
changeset
|
37 |
import java.util.ArrayList; |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
diff
changeset
|
38 |
import java.util.List; |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
diff
changeset
|
39 |
import java.util.stream.Collectors; |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
diff
changeset
|
40 |
import java.util.stream.Stream; |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
diff
changeset
|
41 |
import javax.tools.JavaFileManager; |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
diff
changeset
|
42 |
import javax.tools.StandardJavaFileManager; |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
diff
changeset
|
43 |
|
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
diff
changeset
|
44 |
/** |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
diff
changeset
|
45 |
* For those paths which are supported by a file manager, verify |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
diff
changeset
|
46 |
* that setLocation can accept such paths, and that getLocation |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
diff
changeset
|
47 |
* can subsequently return the same paths. |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
diff
changeset
|
48 |
* |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
diff
changeset
|
49 |
* In addition, for files in the default file system, verify |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
diff
changeset
|
50 |
* the combinations of setting a location using files or paths |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
diff
changeset
|
51 |
* and then subsequently getting the location as files or paths. |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
diff
changeset
|
52 |
*/ |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
diff
changeset
|
53 |
public class SJFM_Locations extends SJFM_TestBase { |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
diff
changeset
|
54 |
public static void main(String... args) throws Exception { |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
diff
changeset
|
55 |
new SJFM_Locations().run(); |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
diff
changeset
|
56 |
} |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
diff
changeset
|
57 |
|
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
diff
changeset
|
58 |
@Test |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
diff
changeset
|
59 |
void test_locations(StandardJavaFileManager fm) throws IOException { |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
diff
changeset
|
60 |
test_setFiles_getFiles(fm, getTestFileDirs()); |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
diff
changeset
|
61 |
test_setFiles_getPaths(fm, getTestFileDirs()); |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
diff
changeset
|
62 |
test_setPaths_getFiles(fm, getTestFilePathDirs()); |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
diff
changeset
|
63 |
test_setPaths_getPaths(fm, getTestFilePathDirs()); |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
diff
changeset
|
64 |
// test_setPaths_getPaths(fm, getTestZipPathDirs()); |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
diff
changeset
|
65 |
} |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
diff
changeset
|
66 |
|
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
diff
changeset
|
67 |
void test_setFiles_getFiles(StandardJavaFileManager fm, List<File> inFiles) throws IOException { |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
diff
changeset
|
68 |
System.err.println("test_setFiles_getFiles"); |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
diff
changeset
|
69 |
JavaFileManager.Location l = newLocation(); |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
diff
changeset
|
70 |
fm.setLocation(l, inFiles); |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
diff
changeset
|
71 |
Iterable<? extends File> outFiles = fm.getLocation(l); |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
diff
changeset
|
72 |
compare(inFiles, outFiles); |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
diff
changeset
|
73 |
} |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
diff
changeset
|
74 |
|
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
diff
changeset
|
75 |
void test_setFiles_getPaths(StandardJavaFileManager fm, List<File> inFiles) throws IOException { |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
diff
changeset
|
76 |
System.err.println("test_setFiles_getPaths"); |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
diff
changeset
|
77 |
JavaFileManager.Location l = newLocation(); |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
diff
changeset
|
78 |
fm.setLocation(l, inFiles); |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
diff
changeset
|
79 |
Iterable<? extends Path> outPaths = fm.getLocationAsPaths(l); |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
diff
changeset
|
80 |
compare(inFiles, outPaths); |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
diff
changeset
|
81 |
} |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
diff
changeset
|
82 |
|
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
diff
changeset
|
83 |
void test_setPaths_getFiles(StandardJavaFileManager fm, List<Path> inPaths) throws IOException { |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
diff
changeset
|
84 |
System.err.println("test_setPaths_getFiles"); |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
diff
changeset
|
85 |
JavaFileManager.Location l = newLocation(); |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
diff
changeset
|
86 |
fm.setLocationFromPaths(l, inPaths); |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
diff
changeset
|
87 |
Iterable<? extends File> outFiles = fm.getLocation(l); |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
diff
changeset
|
88 |
compare(inPaths, outFiles); |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
diff
changeset
|
89 |
} |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
diff
changeset
|
90 |
|
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
diff
changeset
|
91 |
void test_setPaths_getPaths(StandardJavaFileManager fm, List<Path> inPaths) throws IOException { |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
diff
changeset
|
92 |
System.err.println("test_setPaths_getPaths"); |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
diff
changeset
|
93 |
JavaFileManager.Location l = newLocation(); |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
diff
changeset
|
94 |
fm.setLocationFromPaths(l, inPaths); |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
diff
changeset
|
95 |
Iterable<? extends Path> outPaths = fm.getLocationAsPaths(l); |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
diff
changeset
|
96 |
compare(inPaths, outPaths); |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
diff
changeset
|
97 |
} |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
diff
changeset
|
98 |
|
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
diff
changeset
|
99 |
//---------------------------------------------------------------------------------------------- |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
diff
changeset
|
100 |
|
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
diff
changeset
|
101 |
/** |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
diff
changeset
|
102 |
* Gets a representative series of directories in the default file system, |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
diff
changeset
|
103 |
* derived from the test.src directory and test.classes path. |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
diff
changeset
|
104 |
* |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
diff
changeset
|
105 |
* @return a list of directories, represented with {@code File} |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
diff
changeset
|
106 |
* @throws IOException |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
diff
changeset
|
107 |
*/ |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
diff
changeset
|
108 |
List<File> getTestFileDirs() throws IOException { |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
diff
changeset
|
109 |
return Stream.of("test.src", "test.classes") |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
diff
changeset
|
110 |
.map(s -> System.getProperty(s)) |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
diff
changeset
|
111 |
.flatMap(s -> Stream.of(s.split(File.pathSeparator, 0))) |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
diff
changeset
|
112 |
.filter(s -> !s.isEmpty()) |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
diff
changeset
|
113 |
.map(s -> new File(s)) |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
diff
changeset
|
114 |
.collect(Collectors.toList()); |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
diff
changeset
|
115 |
} |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
diff
changeset
|
116 |
|
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
diff
changeset
|
117 |
/** |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
diff
changeset
|
118 |
* Gets a representative series of directories in the default file system, |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
diff
changeset
|
119 |
* derived from the test.src directory and test.classes path. |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
diff
changeset
|
120 |
* |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
diff
changeset
|
121 |
* @return a list of directories, represented with {@code Path} |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
diff
changeset
|
122 |
* @throws IOException |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
diff
changeset
|
123 |
*/ |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
diff
changeset
|
124 |
List<Path> getTestFilePathDirs() throws IOException { |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
diff
changeset
|
125 |
return Stream.of("test.src", "test.classes") |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
diff
changeset
|
126 |
.map(s -> System.getProperty(s)) |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
diff
changeset
|
127 |
.flatMap(s -> Stream.of(s.split(File.pathSeparator, 0))) |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
diff
changeset
|
128 |
.filter(s -> !s.isEmpty()) |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
diff
changeset
|
129 |
.map(s -> Paths.get(s)) |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
diff
changeset
|
130 |
.collect(Collectors.toList()); |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
diff
changeset
|
131 |
} |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
diff
changeset
|
132 |
|
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
diff
changeset
|
133 |
|
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
diff
changeset
|
134 |
/** |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
diff
changeset
|
135 |
* Compares two lists of items by comparing their individual string representations. |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
diff
changeset
|
136 |
* |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
diff
changeset
|
137 |
* @param in the first set of items to be compared |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
diff
changeset
|
138 |
* @param out the second set of items to be compared |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
diff
changeset
|
139 |
*/ |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
diff
changeset
|
140 |
void compare(Iterable<?> in, Iterable<?> out) { |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
diff
changeset
|
141 |
List<String> ins = toString(in); |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
diff
changeset
|
142 |
List<String> outs = toString(out); |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
diff
changeset
|
143 |
if (!ins.equals(outs)) { |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
diff
changeset
|
144 |
error("mismatch in comparison"); |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
diff
changeset
|
145 |
System.err.println("in:"); |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
diff
changeset
|
146 |
for (String s: ins) System.err.println(s); |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
diff
changeset
|
147 |
System.err.println("out:"); |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
diff
changeset
|
148 |
for (String s: outs) System.err.println(s); |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
diff
changeset
|
149 |
} |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
diff
changeset
|
150 |
} |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
diff
changeset
|
151 |
|
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
diff
changeset
|
152 |
List<String> toString(Iterable<?> iter) { |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
diff
changeset
|
153 |
List<String> strings = new ArrayList<>(); |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
diff
changeset
|
154 |
for (Object item: iter) |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
diff
changeset
|
155 |
strings.add(item.toString()); |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
diff
changeset
|
156 |
return strings; |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
diff
changeset
|
157 |
} |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
diff
changeset
|
158 |
|
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
diff
changeset
|
159 |
/** |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
diff
changeset
|
160 |
* Create an instance of a location. |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
diff
changeset
|
161 |
* @return a location |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
diff
changeset
|
162 |
*/ |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
diff
changeset
|
163 |
JavaFileManager.Location newLocation() { |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
diff
changeset
|
164 |
final String name = "locn" + (count++); |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
diff
changeset
|
165 |
return new JavaFileManager.Location() { |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
diff
changeset
|
166 |
@Override |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
diff
changeset
|
167 |
public String getName() { |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
diff
changeset
|
168 |
return name; |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
diff
changeset
|
169 |
} |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
diff
changeset
|
170 |
|
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
diff
changeset
|
171 |
@Override |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
diff
changeset
|
172 |
public boolean isOutputLocation() { |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
diff
changeset
|
173 |
return false; |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
diff
changeset
|
174 |
} |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
diff
changeset
|
175 |
}; |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
diff
changeset
|
176 |
} |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
diff
changeset
|
177 |
|
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
diff
changeset
|
178 |
int count = 0; |
cd3ea1087d2b
8059977: StandardJavaFileManager should support java.nio.file.Path
jjg
parents:
diff
changeset
|
179 |
} |