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. |
30 import java.io.*; |
30 import java.io.*; |
31 import java.util.*; |
31 import java.util.*; |
32 import java.util.zip.*; |
32 import java.util.zip.*; |
33 import javax.tools.*; |
33 import javax.tools.*; |
34 import com.sun.tools.javac.file.JavacFileManager; |
34 import com.sun.tools.javac.file.JavacFileManager; |
|
35 import com.sun.tools.javac.main.OptionName; |
35 import com.sun.tools.javac.util.Context; |
36 import com.sun.tools.javac.util.Context; |
|
37 import com.sun.tools.javac.util.Options; |
36 |
38 |
37 public class T6838467 { |
39 public class T6838467 { |
38 boolean fileSystemIsCaseSignificant = !new File("a").equals(new File("A")); |
40 boolean fileSystemIsCaseSignificant = !new File("a").equals(new File("A")); |
39 |
41 |
40 enum FileKind { |
42 enum FileKind { |
174 StandardJavaFileManager fm = createFileManager(fk == FileKind.ZIP); |
176 StandardJavaFileManager fm = createFileManager(fk == FileKind.ZIP); |
175 fm.setLocation(StandardLocation.CLASS_PATH, Arrays.asList(classpath)); |
177 fm.setLocation(StandardLocation.CLASS_PATH, Arrays.asList(classpath)); |
176 return fm; |
178 return fm; |
177 } |
179 } |
178 |
180 |
179 JavacFileManager createFileManager(boolean useJavaUtilZip) { |
181 JavacFileManager createFileManager(boolean useOptimedZipIndex) { |
180 // javac should really not be using system properties like this |
182 Context ctx = new Context(); |
181 // -- it should really be using (hidden) options -- but until then |
183 if (useOptimedZipIndex) { |
182 // take care to leave system properties as we find them, so as not |
184 Options options = Options.instance(ctx); |
183 // to adversely affect other tests that might follow. |
185 options.put("useOptimizedZip", "true"); |
184 String prev = System.getProperty("useJavaUtilZip"); |
186 } |
185 boolean resetProperties = false; |
187 return new JavacFileManager(ctx, false, null); |
186 try { |
|
187 if (useJavaUtilZip) { |
|
188 System.setProperty("useJavaUtilZip", "true"); |
|
189 resetProperties = true; |
|
190 } else if (System.getProperty("useJavaUtilZip") != null) { |
|
191 System.getProperties().remove("useJavaUtilZip"); |
|
192 resetProperties = true; |
|
193 } |
|
194 |
|
195 Context c = new Context(); |
|
196 return new JavacFileManager(c, false, null); |
|
197 } finally { |
|
198 if (resetProperties) { |
|
199 if (prev == null) { |
|
200 System.getProperties().remove("useJavaUtilZip"); |
|
201 } else { |
|
202 System.setProperty("useJavaUtilZip", prev); |
|
203 } |
|
204 } |
|
205 } |
|
206 } |
188 } |
207 |
189 |
208 // create a directory containing a given set of paths |
190 // create a directory containing a given set of paths |
209 void createTestDir(File dir, String[] paths) throws IOException { |
191 void createTestDir(File dir, String[] paths) throws IOException { |
210 for (String p: paths) { |
192 for (String p: paths) { |