changeset 951:3d45cc94ee0f

7018859: javac turn off the Zip optimization by default Reviewed-by: jjg
author ksrini
date Fri, 18 Feb 2011 08:12:06 -0800
parents 4ce95dc0b908
children 51e643f41a3a
files src/share/classes/com/sun/tools/javac/file/JavacFileManager.java test/tools/javac/4241573/T4241573.java test/tools/javac/6508981/TestInferBinaryName.java test/tools/javac/api/6411310/Test.java test/tools/javac/api/T6838467.java test/tools/javac/api/T6877206.java
diffstat 6 files changed, 54 insertions(+), 113 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/com/sun/tools/javac/file/JavacFileManager.java	Fri Feb 18 12:28:49 2011 +0000
+++ b/src/share/classes/com/sun/tools/javac/file/JavacFileManager.java	Fri Feb 18 08:12:06 2011 -0800
@@ -164,9 +164,7 @@
 
         fsInfo = FSInfo.instance(context);
 
-        // retain check for system property for compatibility
-        useZipFileIndex = options.isUnset("useJavaUtilZip")
-                && System.getProperty("useJavaUtilZip") == null;
+        useZipFileIndex = options.isSet("useOptimizedZip");
         if (useZipFileIndex)
             zipFileIndexCache = ZipFileIndexCache.getSharedInstance();
 
@@ -499,8 +497,7 @@
 
             if (!useZipFileIndex) {
                 zdir = new ZipFile(zipFileName);
-            }
-            else {
+            } else {
                 usePreindexedCache = options.isSet("usezipindex");
                 preindexCacheLocation = options.get("java.io.tmpdir");
                 String optCacheLoc = options.get("cachezipindexdir");
--- a/test/tools/javac/4241573/T4241573.java	Fri Feb 18 12:28:49 2011 +0000
+++ b/test/tools/javac/4241573/T4241573.java	Fri Feb 18 08:12:06 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2011 Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -123,7 +123,7 @@
         if (!dir.mkdirs())
             throw new Exception("cannot create directories " + dir);
         for (String e: entries) {
-            writeFile(new File(dir, getPathForEntry(e)), getBodyForEntry(e));
+            writeFile(new File(dir, getPathForDirEntry(e)), getBodyForEntry(e));
         }
         return dir;
     }
@@ -134,7 +134,7 @@
         try {
             JarOutputStream jos = new JarOutputStream(out);
             for (String e: entries) {
-                jos.putNextEntry(new JarEntry(getPathForEntry(e)));
+                jos.putNextEntry(new JarEntry(getPathForZipEntry(e)));
                 jos.write(getBodyForEntry(e).getBytes());
             }
             jos.close();
@@ -144,11 +144,16 @@
         return jar;
     }
 
-    /** Return the path for an entry given to createDir or createJar. */
-    String getPathForEntry(String e) {
+    /** Return the path for an entry given to createDir */
+    String getPathForDirEntry(String e) {
         return e.replace(".", File.separator) + ".java";
     }
 
+    /** Return the path for an entry given to createJar. */
+    String getPathForZipEntry(String e) {
+        return e.replace(".", "/") + ".java";
+    }
+
     /** Return the body text for an entry given to createDir or createJar. */
     String getBodyForEntry(String e) {
         int sep = e.lastIndexOf(".");
--- a/test/tools/javac/6508981/TestInferBinaryName.java	Fri Feb 18 12:28:49 2011 +0000
+++ b/test/tools/javac/6508981/TestInferBinaryName.java	Fri Feb 18 08:12:06 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2011 Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -138,12 +138,11 @@
                                    boolean zipFileIndexKind)
             throws IOException {
         Context ctx = new Context();
+        Options options = Options.instance(ctx);
         // uugh, ugly back door, should be cleaned up, someday
         if (zipFileIndexKind == USE_ZIP_FILE_INDEX)
-            System.clearProperty("useJavaUtilZip");
-        else
-            System.setProperty("useJavaUtilZip", "true");
-        Options options = Options.instance(ctx);
+            options.put("useOptimizedZip", "true");
+
         if (symFileKind == IGNORE_SYMBOL_FILE)
             options.put("ignore.symbol.file", "true");
         JavacFileManager fm = new JavacFileManager(ctx, false, null);
--- a/test/tools/javac/api/6411310/Test.java	Fri Feb 18 12:28:49 2011 +0000
+++ b/test/tools/javac/api/6411310/Test.java	Fri Feb 18 08:12:06 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2011 Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -59,12 +59,12 @@
         test(createFileManager(), createDir("dir", entries), "p", entries);
         test(createFileManager(), createDir("a b/dir", entries), "p", entries);
 
-        for (boolean useJavaUtilZip: new boolean[] { false, true }) {
-            test(createFileManager(useJavaUtilZip), createJar("jar", entries), "p", entries);
-            test(createFileManager(useJavaUtilZip), createJar("jar jar", entries), "p", entries);
+        for (boolean useOptimizedZip: new boolean[] { false, true }) {
+            test(createFileManager(useOptimizedZip), createJar("jar", entries), "p", entries);
+            test(createFileManager(useOptimizedZip), createJar("jar jar", entries), "p", entries);
 
             for (boolean useSymbolFile: new boolean[] { false, true }) {
-                test(createFileManager(useJavaUtilZip, useSymbolFile), rt_jar, "java.lang.ref", null);
+                test(createFileManager(useOptimizedZip, useSymbolFile), rt_jar, "java.lang.ref", null);
             }
         }
 
@@ -145,42 +145,22 @@
         return createFileManager(false, false);
     }
 
-    JavacFileManager createFileManager(boolean useJavaUtilZip) {
-        return createFileManager(useJavaUtilZip, false);
+    JavacFileManager createFileManager(boolean useOptimizedZip) {
+        return createFileManager(useOptimizedZip, false);
     }
 
-    JavacFileManager createFileManager(boolean useJavaUtilZip, boolean useSymbolFile) {
-        // javac should really not be using system properties like this
-        // -- it should really be using (hidden) options -- but until then
-        // take care to leave system properties as we find them, so as not
-        // to adversely affect other tests that might follow.
-        String prev = System.getProperty("useJavaUtilZip");
-        boolean resetProperties = false;
-        try {
-            if (useJavaUtilZip) {
-                System.setProperty("useJavaUtilZip", "true");
-                resetProperties = true;
-            } else if (System.getProperty("useJavaUtilZip") != null) {
-                System.getProperties().remove("useJavaUtilZip");
-                resetProperties = true;
+    JavacFileManager createFileManager(boolean useOptimizedZip, boolean useSymbolFile) {
+        Context c = new Context();
+        Options options = Options.instance(c);
+
+            if (useOptimizedZip) {
+                options.put("useOptimizedZip", "true");
             }
 
-            Context c = new Context();
             if (!useSymbolFile) {
-                Options options = Options.instance(c);
                 options.put("ignore.symbol.file", "true");
             }
-
             return new JavacFileManager(c, false, null);
-        } finally {
-            if (resetProperties) {
-                if (prev == null) {
-                    System.getProperties().remove("useJavaUtilZip");
-                } else {
-                    System.setProperty("useJavaUtilZip", prev);
-                }
-            }
-        }
     }
 
     File createDir(String name, String... entries) throws Exception {
--- a/test/tools/javac/api/T6838467.java	Fri Feb 18 12:28:49 2011 +0000
+++ b/test/tools/javac/api/T6838467.java	Fri Feb 18 08:12:06 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2011 Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -32,7 +32,9 @@
 import java.util.zip.*;
 import javax.tools.*;
 import com.sun.tools.javac.file.JavacFileManager;
+import com.sun.tools.javac.main.OptionName;
 import com.sun.tools.javac.util.Context;
+import com.sun.tools.javac.util.Options;
 
 public class T6838467 {
     boolean fileSystemIsCaseSignificant = !new File("a").equals(new File("A"));
@@ -176,33 +178,13 @@
         return fm;
     }
 
-    JavacFileManager createFileManager(boolean useJavaUtilZip) {
-        // javac should really not be using system properties like this
-        // -- it should really be using (hidden) options -- but until then
-        // take care to leave system properties as we find them, so as not
-        // to adversely affect other tests that might follow.
-        String prev = System.getProperty("useJavaUtilZip");
-        boolean resetProperties = false;
-        try {
-            if (useJavaUtilZip) {
-                System.setProperty("useJavaUtilZip", "true");
-                resetProperties = true;
-            } else if (System.getProperty("useJavaUtilZip") != null) {
-                System.getProperties().remove("useJavaUtilZip");
-                resetProperties = true;
-            }
-
-            Context c = new Context();
-            return new JavacFileManager(c, false, null);
-        } finally {
-            if (resetProperties) {
-                if (prev == null) {
-                    System.getProperties().remove("useJavaUtilZip");
-                } else {
-                    System.setProperty("useJavaUtilZip", prev);
-                }
-            }
+    JavacFileManager createFileManager(boolean useOptimedZipIndex) {
+        Context ctx = new Context();
+        if (useOptimedZipIndex) {
+            Options options = Options.instance(ctx);
+            options.put("useOptimizedZip", "true");
         }
+        return new JavacFileManager(ctx, false, null);
     }
 
     // create a directory containing a given set of paths
--- a/test/tools/javac/api/T6877206.java	Fri Feb 18 12:28:49 2011 +0000
+++ b/test/tools/javac/api/T6877206.java	Fri Feb 18 08:12:06 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2011 Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -63,12 +63,12 @@
         test(createFileManager(), createDir("dir", entries), "p", entries.length);
         test(createFileManager(), createDir("a b/dir", entries), "p", entries.length);
 
-        for (boolean useJavaUtilZip: new boolean[] { false, true }) {
-            test(createFileManager(useJavaUtilZip), createJar("jar", entries), "p", entries.length);
-            test(createFileManager(useJavaUtilZip), createJar("jar jar", entries), "p", entries.length);
+        for (boolean useOptimizedZip: new boolean[] { false, true }) {
+            test(createFileManager(useOptimizedZip), createJar("jar", entries), "p", entries.length);
+            test(createFileManager(useOptimizedZip), createJar("jar jar", entries), "p", entries.length);
 
             for (boolean useSymbolFile: new boolean[] { false, true }) {
-                test(createFileManager(useJavaUtilZip, useSymbolFile), rt_jar, "java.lang.ref", -1);
+                test(createFileManager(useOptimizedZip, useSymbolFile), rt_jar, "java.lang.ref", -1);
             }
         }
 
@@ -161,42 +161,20 @@
         return createFileManager(false, false);
     }
 
-    JavacFileManager createFileManager(boolean useJavaUtilZip) {
-        return createFileManager(useJavaUtilZip, false);
+    JavacFileManager createFileManager(boolean useOptimizedZip) {
+        return createFileManager(useOptimizedZip, false);
     }
 
-    JavacFileManager createFileManager(boolean useJavaUtilZip, boolean useSymbolFile) {
-        // javac should really not be using system properties like this
-        // -- it should really be using (hidden) options -- but until then
-        // take care to leave system properties as we find them, so as not
-        // to adversely affect other tests that might follow.
-        String prev = System.getProperty("useJavaUtilZip");
-        boolean resetProperties = false;
-        try {
-            if (useJavaUtilZip) {
-                System.setProperty("useJavaUtilZip", "true");
-                resetProperties = true;
-            } else if (System.getProperty("useJavaUtilZip") != null) {
-                System.getProperties().remove("useJavaUtilZip");
-                resetProperties = true;
-            }
-
-            Context c = new Context();
-            if (!useSymbolFile) {
-                Options options = Options.instance(c);
-                options.put("ignore.symbol.file", "true");
-            }
-
-            return new JavacFileManager(c, false, null);
-        } finally {
-            if (resetProperties) {
-                if (prev == null) {
-                    System.getProperties().remove("useJavaUtilZip");
-                } else {
-                    System.setProperty("useJavaUtilZip", prev);
-                }
-            }
+    JavacFileManager createFileManager(boolean useOptimizedZip, boolean useSymbolFile) {
+        Context ctx = new Context();
+        Options options = Options.instance(ctx);
+        if (useOptimizedZip) {
+            options.put("useOptimizedZip", "true");
         }
+        if (!useSymbolFile) {
+            options.put("ignore.symbol.file", "true");
+        }
+        return new JavacFileManager(ctx, false, null);
     }
 
     File createDir(String name, String... entries) throws Exception {