1 /* |
1 /* |
2 * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2009, 2011 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. |
61 // cover all sources of URIs within JavacFileManager's support classes |
61 // cover all sources of URIs within JavacFileManager's support classes |
62 |
62 |
63 test(createFileManager(), createDir("dir", entries), "p", entries.length); |
63 test(createFileManager(), createDir("dir", entries), "p", entries.length); |
64 test(createFileManager(), createDir("a b/dir", entries), "p", entries.length); |
64 test(createFileManager(), createDir("a b/dir", entries), "p", entries.length); |
65 |
65 |
66 for (boolean useJavaUtilZip: new boolean[] { false, true }) { |
66 for (boolean useOptimizedZip: new boolean[] { false, true }) { |
67 test(createFileManager(useJavaUtilZip), createJar("jar", entries), "p", entries.length); |
67 test(createFileManager(useOptimizedZip), createJar("jar", entries), "p", entries.length); |
68 test(createFileManager(useJavaUtilZip), createJar("jar jar", entries), "p", entries.length); |
68 test(createFileManager(useOptimizedZip), createJar("jar jar", entries), "p", entries.length); |
69 |
69 |
70 for (boolean useSymbolFile: new boolean[] { false, true }) { |
70 for (boolean useSymbolFile: new boolean[] { false, true }) { |
71 test(createFileManager(useJavaUtilZip, useSymbolFile), rt_jar, "java.lang.ref", -1); |
71 test(createFileManager(useOptimizedZip, useSymbolFile), rt_jar, "java.lang.ref", -1); |
72 } |
72 } |
73 } |
73 } |
74 |
74 |
75 // Verify that we hit all the impl classes we intended |
75 // Verify that we hit all the impl classes we intended |
76 checkCoverage("classes", foundClasses, |
76 checkCoverage("classes", foundClasses, |
159 |
159 |
160 JavacFileManager createFileManager() { |
160 JavacFileManager createFileManager() { |
161 return createFileManager(false, false); |
161 return createFileManager(false, false); |
162 } |
162 } |
163 |
163 |
164 JavacFileManager createFileManager(boolean useJavaUtilZip) { |
164 JavacFileManager createFileManager(boolean useOptimizedZip) { |
165 return createFileManager(useJavaUtilZip, false); |
165 return createFileManager(useOptimizedZip, false); |
166 } |
166 } |
167 |
167 |
168 JavacFileManager createFileManager(boolean useJavaUtilZip, boolean useSymbolFile) { |
168 JavacFileManager createFileManager(boolean useOptimizedZip, boolean useSymbolFile) { |
169 // javac should really not be using system properties like this |
169 Context ctx = new Context(); |
170 // -- it should really be using (hidden) options -- but until then |
170 Options options = Options.instance(ctx); |
171 // take care to leave system properties as we find them, so as not |
171 if (useOptimizedZip) { |
172 // to adversely affect other tests that might follow. |
172 options.put("useOptimizedZip", "true"); |
173 String prev = System.getProperty("useJavaUtilZip"); |
173 } |
174 boolean resetProperties = false; |
174 if (!useSymbolFile) { |
175 try { |
175 options.put("ignore.symbol.file", "true"); |
176 if (useJavaUtilZip) { |
176 } |
177 System.setProperty("useJavaUtilZip", "true"); |
177 return new JavacFileManager(ctx, false, null); |
178 resetProperties = true; |
|
179 } else if (System.getProperty("useJavaUtilZip") != null) { |
|
180 System.getProperties().remove("useJavaUtilZip"); |
|
181 resetProperties = true; |
|
182 } |
|
183 |
|
184 Context c = new Context(); |
|
185 if (!useSymbolFile) { |
|
186 Options options = Options.instance(c); |
|
187 options.put("ignore.symbol.file", "true"); |
|
188 } |
|
189 |
|
190 return new JavacFileManager(c, false, null); |
|
191 } finally { |
|
192 if (resetProperties) { |
|
193 if (prev == null) { |
|
194 System.getProperties().remove("useJavaUtilZip"); |
|
195 } else { |
|
196 System.setProperty("useJavaUtilZip", prev); |
|
197 } |
|
198 } |
|
199 } |
|
200 } |
178 } |
201 |
179 |
202 File createDir(String name, String... entries) throws Exception { |
180 File createDir(String name, String... entries) throws Exception { |
203 File dir = new File(name); |
181 File dir = new File(name); |
204 if (!dir.mkdirs()) |
182 if (!dir.mkdirs()) |