7018859: javac turn off the Zip optimization by default

Fri, 18 Feb 2011 08:12:06 -0800

author
ksrini
date
Fri, 18 Feb 2011 08:12:06 -0800
changeset 882
3d45cc94ee0f
parent 881
4ce95dc0b908
child 883
51e643f41a3a

7018859: javac turn off the Zip optimization by default
Reviewed-by: jjg

src/share/classes/com/sun/tools/javac/file/JavacFileManager.java file | annotate | diff | comparison | revisions
test/tools/javac/4241573/T4241573.java file | annotate | diff | comparison | revisions
test/tools/javac/6508981/TestInferBinaryName.java file | annotate | diff | comparison | revisions
test/tools/javac/api/6411310/Test.java file | annotate | diff | comparison | revisions
test/tools/javac/api/T6838467.java file | annotate | diff | comparison | revisions
test/tools/javac/api/T6877206.java file | annotate | diff | comparison | revisions
     1.1 --- a/src/share/classes/com/sun/tools/javac/file/JavacFileManager.java	Fri Feb 18 12:28:49 2011 +0000
     1.2 +++ b/src/share/classes/com/sun/tools/javac/file/JavacFileManager.java	Fri Feb 18 08:12:06 2011 -0800
     1.3 @@ -164,9 +164,7 @@
     1.4  
     1.5          fsInfo = FSInfo.instance(context);
     1.6  
     1.7 -        // retain check for system property for compatibility
     1.8 -        useZipFileIndex = options.isUnset("useJavaUtilZip")
     1.9 -                && System.getProperty("useJavaUtilZip") == null;
    1.10 +        useZipFileIndex = options.isSet("useOptimizedZip");
    1.11          if (useZipFileIndex)
    1.12              zipFileIndexCache = ZipFileIndexCache.getSharedInstance();
    1.13  
    1.14 @@ -499,8 +497,7 @@
    1.15  
    1.16              if (!useZipFileIndex) {
    1.17                  zdir = new ZipFile(zipFileName);
    1.18 -            }
    1.19 -            else {
    1.20 +            } else {
    1.21                  usePreindexedCache = options.isSet("usezipindex");
    1.22                  preindexCacheLocation = options.get("java.io.tmpdir");
    1.23                  String optCacheLoc = options.get("cachezipindexdir");
     2.1 --- a/test/tools/javac/4241573/T4241573.java	Fri Feb 18 12:28:49 2011 +0000
     2.2 +++ b/test/tools/javac/4241573/T4241573.java	Fri Feb 18 08:12:06 2011 -0800
     2.3 @@ -1,5 +1,5 @@
     2.4  /*
     2.5 - * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
     2.6 + * Copyright (c) 2009, 2011 Oracle and/or its affiliates. All rights reserved.
     2.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     2.8   *
     2.9   * This code is free software; you can redistribute it and/or modify it
    2.10 @@ -123,7 +123,7 @@
    2.11          if (!dir.mkdirs())
    2.12              throw new Exception("cannot create directories " + dir);
    2.13          for (String e: entries) {
    2.14 -            writeFile(new File(dir, getPathForEntry(e)), getBodyForEntry(e));
    2.15 +            writeFile(new File(dir, getPathForDirEntry(e)), getBodyForEntry(e));
    2.16          }
    2.17          return dir;
    2.18      }
    2.19 @@ -134,7 +134,7 @@
    2.20          try {
    2.21              JarOutputStream jos = new JarOutputStream(out);
    2.22              for (String e: entries) {
    2.23 -                jos.putNextEntry(new JarEntry(getPathForEntry(e)));
    2.24 +                jos.putNextEntry(new JarEntry(getPathForZipEntry(e)));
    2.25                  jos.write(getBodyForEntry(e).getBytes());
    2.26              }
    2.27              jos.close();
    2.28 @@ -144,11 +144,16 @@
    2.29          return jar;
    2.30      }
    2.31  
    2.32 -    /** Return the path for an entry given to createDir or createJar. */
    2.33 -    String getPathForEntry(String e) {
    2.34 +    /** Return the path for an entry given to createDir */
    2.35 +    String getPathForDirEntry(String e) {
    2.36          return e.replace(".", File.separator) + ".java";
    2.37      }
    2.38  
    2.39 +    /** Return the path for an entry given to createJar. */
    2.40 +    String getPathForZipEntry(String e) {
    2.41 +        return e.replace(".", "/") + ".java";
    2.42 +    }
    2.43 +
    2.44      /** Return the body text for an entry given to createDir or createJar. */
    2.45      String getBodyForEntry(String e) {
    2.46          int sep = e.lastIndexOf(".");
     3.1 --- a/test/tools/javac/6508981/TestInferBinaryName.java	Fri Feb 18 12:28:49 2011 +0000
     3.2 +++ b/test/tools/javac/6508981/TestInferBinaryName.java	Fri Feb 18 08:12:06 2011 -0800
     3.3 @@ -1,5 +1,5 @@
     3.4  /*
     3.5 - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
     3.6 + * Copyright (c) 2008, 2011 Oracle and/or its affiliates. All rights reserved.
     3.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3.8   *
     3.9   * This code is free software; you can redistribute it and/or modify it
    3.10 @@ -138,12 +138,11 @@
    3.11                                     boolean zipFileIndexKind)
    3.12              throws IOException {
    3.13          Context ctx = new Context();
    3.14 +        Options options = Options.instance(ctx);
    3.15          // uugh, ugly back door, should be cleaned up, someday
    3.16          if (zipFileIndexKind == USE_ZIP_FILE_INDEX)
    3.17 -            System.clearProperty("useJavaUtilZip");
    3.18 -        else
    3.19 -            System.setProperty("useJavaUtilZip", "true");
    3.20 -        Options options = Options.instance(ctx);
    3.21 +            options.put("useOptimizedZip", "true");
    3.22 +
    3.23          if (symFileKind == IGNORE_SYMBOL_FILE)
    3.24              options.put("ignore.symbol.file", "true");
    3.25          JavacFileManager fm = new JavacFileManager(ctx, false, null);
     4.1 --- a/test/tools/javac/api/6411310/Test.java	Fri Feb 18 12:28:49 2011 +0000
     4.2 +++ b/test/tools/javac/api/6411310/Test.java	Fri Feb 18 08:12:06 2011 -0800
     4.3 @@ -1,5 +1,5 @@
     4.4  /*
     4.5 - * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
     4.6 + * Copyright (c) 2009, 2011 Oracle and/or its affiliates. All rights reserved.
     4.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4.8   *
     4.9   * This code is free software; you can redistribute it and/or modify it
    4.10 @@ -59,12 +59,12 @@
    4.11          test(createFileManager(), createDir("dir", entries), "p", entries);
    4.12          test(createFileManager(), createDir("a b/dir", entries), "p", entries);
    4.13  
    4.14 -        for (boolean useJavaUtilZip: new boolean[] { false, true }) {
    4.15 -            test(createFileManager(useJavaUtilZip), createJar("jar", entries), "p", entries);
    4.16 -            test(createFileManager(useJavaUtilZip), createJar("jar jar", entries), "p", entries);
    4.17 +        for (boolean useOptimizedZip: new boolean[] { false, true }) {
    4.18 +            test(createFileManager(useOptimizedZip), createJar("jar", entries), "p", entries);
    4.19 +            test(createFileManager(useOptimizedZip), createJar("jar jar", entries), "p", entries);
    4.20  
    4.21              for (boolean useSymbolFile: new boolean[] { false, true }) {
    4.22 -                test(createFileManager(useJavaUtilZip, useSymbolFile), rt_jar, "java.lang.ref", null);
    4.23 +                test(createFileManager(useOptimizedZip, useSymbolFile), rt_jar, "java.lang.ref", null);
    4.24              }
    4.25          }
    4.26  
    4.27 @@ -145,42 +145,22 @@
    4.28          return createFileManager(false, false);
    4.29      }
    4.30  
    4.31 -    JavacFileManager createFileManager(boolean useJavaUtilZip) {
    4.32 -        return createFileManager(useJavaUtilZip, false);
    4.33 +    JavacFileManager createFileManager(boolean useOptimizedZip) {
    4.34 +        return createFileManager(useOptimizedZip, false);
    4.35      }
    4.36  
    4.37 -    JavacFileManager createFileManager(boolean useJavaUtilZip, boolean useSymbolFile) {
    4.38 -        // javac should really not be using system properties like this
    4.39 -        // -- it should really be using (hidden) options -- but until then
    4.40 -        // take care to leave system properties as we find them, so as not
    4.41 -        // to adversely affect other tests that might follow.
    4.42 -        String prev = System.getProperty("useJavaUtilZip");
    4.43 -        boolean resetProperties = false;
    4.44 -        try {
    4.45 -            if (useJavaUtilZip) {
    4.46 -                System.setProperty("useJavaUtilZip", "true");
    4.47 -                resetProperties = true;
    4.48 -            } else if (System.getProperty("useJavaUtilZip") != null) {
    4.49 -                System.getProperties().remove("useJavaUtilZip");
    4.50 -                resetProperties = true;
    4.51 +    JavacFileManager createFileManager(boolean useOptimizedZip, boolean useSymbolFile) {
    4.52 +        Context c = new Context();
    4.53 +        Options options = Options.instance(c);
    4.54 +
    4.55 +            if (useOptimizedZip) {
    4.56 +                options.put("useOptimizedZip", "true");
    4.57              }
    4.58  
    4.59 -            Context c = new Context();
    4.60              if (!useSymbolFile) {
    4.61 -                Options options = Options.instance(c);
    4.62                  options.put("ignore.symbol.file", "true");
    4.63              }
    4.64 -
    4.65              return new JavacFileManager(c, false, null);
    4.66 -        } finally {
    4.67 -            if (resetProperties) {
    4.68 -                if (prev == null) {
    4.69 -                    System.getProperties().remove("useJavaUtilZip");
    4.70 -                } else {
    4.71 -                    System.setProperty("useJavaUtilZip", prev);
    4.72 -                }
    4.73 -            }
    4.74 -        }
    4.75      }
    4.76  
    4.77      File createDir(String name, String... entries) throws Exception {
     5.1 --- a/test/tools/javac/api/T6838467.java	Fri Feb 18 12:28:49 2011 +0000
     5.2 +++ b/test/tools/javac/api/T6838467.java	Fri Feb 18 08:12:06 2011 -0800
     5.3 @@ -1,5 +1,5 @@
     5.4  /*
     5.5 - * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
     5.6 + * Copyright (c) 2009, 2011 Oracle and/or its affiliates. All rights reserved.
     5.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     5.8   *
     5.9   * This code is free software; you can redistribute it and/or modify it
    5.10 @@ -32,7 +32,9 @@
    5.11  import java.util.zip.*;
    5.12  import javax.tools.*;
    5.13  import com.sun.tools.javac.file.JavacFileManager;
    5.14 +import com.sun.tools.javac.main.OptionName;
    5.15  import com.sun.tools.javac.util.Context;
    5.16 +import com.sun.tools.javac.util.Options;
    5.17  
    5.18  public class T6838467 {
    5.19      boolean fileSystemIsCaseSignificant = !new File("a").equals(new File("A"));
    5.20 @@ -176,33 +178,13 @@
    5.21          return fm;
    5.22      }
    5.23  
    5.24 -    JavacFileManager createFileManager(boolean useJavaUtilZip) {
    5.25 -        // javac should really not be using system properties like this
    5.26 -        // -- it should really be using (hidden) options -- but until then
    5.27 -        // take care to leave system properties as we find them, so as not
    5.28 -        // to adversely affect other tests that might follow.
    5.29 -        String prev = System.getProperty("useJavaUtilZip");
    5.30 -        boolean resetProperties = false;
    5.31 -        try {
    5.32 -            if (useJavaUtilZip) {
    5.33 -                System.setProperty("useJavaUtilZip", "true");
    5.34 -                resetProperties = true;
    5.35 -            } else if (System.getProperty("useJavaUtilZip") != null) {
    5.36 -                System.getProperties().remove("useJavaUtilZip");
    5.37 -                resetProperties = true;
    5.38 -            }
    5.39 -
    5.40 -            Context c = new Context();
    5.41 -            return new JavacFileManager(c, false, null);
    5.42 -        } finally {
    5.43 -            if (resetProperties) {
    5.44 -                if (prev == null) {
    5.45 -                    System.getProperties().remove("useJavaUtilZip");
    5.46 -                } else {
    5.47 -                    System.setProperty("useJavaUtilZip", prev);
    5.48 -                }
    5.49 -            }
    5.50 +    JavacFileManager createFileManager(boolean useOptimedZipIndex) {
    5.51 +        Context ctx = new Context();
    5.52 +        if (useOptimedZipIndex) {
    5.53 +            Options options = Options.instance(ctx);
    5.54 +            options.put("useOptimizedZip", "true");
    5.55          }
    5.56 +        return new JavacFileManager(ctx, false, null);
    5.57      }
    5.58  
    5.59      // create a directory containing a given set of paths
     6.1 --- a/test/tools/javac/api/T6877206.java	Fri Feb 18 12:28:49 2011 +0000
     6.2 +++ b/test/tools/javac/api/T6877206.java	Fri Feb 18 08:12:06 2011 -0800
     6.3 @@ -1,5 +1,5 @@
     6.4  /*
     6.5 - * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
     6.6 + * Copyright (c) 2009, 2011 Oracle and/or its affiliates. All rights reserved.
     6.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     6.8   *
     6.9   * This code is free software; you can redistribute it and/or modify it
    6.10 @@ -63,12 +63,12 @@
    6.11          test(createFileManager(), createDir("dir", entries), "p", entries.length);
    6.12          test(createFileManager(), createDir("a b/dir", entries), "p", entries.length);
    6.13  
    6.14 -        for (boolean useJavaUtilZip: new boolean[] { false, true }) {
    6.15 -            test(createFileManager(useJavaUtilZip), createJar("jar", entries), "p", entries.length);
    6.16 -            test(createFileManager(useJavaUtilZip), createJar("jar jar", entries), "p", entries.length);
    6.17 +        for (boolean useOptimizedZip: new boolean[] { false, true }) {
    6.18 +            test(createFileManager(useOptimizedZip), createJar("jar", entries), "p", entries.length);
    6.19 +            test(createFileManager(useOptimizedZip), createJar("jar jar", entries), "p", entries.length);
    6.20  
    6.21              for (boolean useSymbolFile: new boolean[] { false, true }) {
    6.22 -                test(createFileManager(useJavaUtilZip, useSymbolFile), rt_jar, "java.lang.ref", -1);
    6.23 +                test(createFileManager(useOptimizedZip, useSymbolFile), rt_jar, "java.lang.ref", -1);
    6.24              }
    6.25          }
    6.26  
    6.27 @@ -161,42 +161,20 @@
    6.28          return createFileManager(false, false);
    6.29      }
    6.30  
    6.31 -    JavacFileManager createFileManager(boolean useJavaUtilZip) {
    6.32 -        return createFileManager(useJavaUtilZip, false);
    6.33 +    JavacFileManager createFileManager(boolean useOptimizedZip) {
    6.34 +        return createFileManager(useOptimizedZip, false);
    6.35      }
    6.36  
    6.37 -    JavacFileManager createFileManager(boolean useJavaUtilZip, boolean useSymbolFile) {
    6.38 -        // javac should really not be using system properties like this
    6.39 -        // -- it should really be using (hidden) options -- but until then
    6.40 -        // take care to leave system properties as we find them, so as not
    6.41 -        // to adversely affect other tests that might follow.
    6.42 -        String prev = System.getProperty("useJavaUtilZip");
    6.43 -        boolean resetProperties = false;
    6.44 -        try {
    6.45 -            if (useJavaUtilZip) {
    6.46 -                System.setProperty("useJavaUtilZip", "true");
    6.47 -                resetProperties = true;
    6.48 -            } else if (System.getProperty("useJavaUtilZip") != null) {
    6.49 -                System.getProperties().remove("useJavaUtilZip");
    6.50 -                resetProperties = true;
    6.51 -            }
    6.52 -
    6.53 -            Context c = new Context();
    6.54 -            if (!useSymbolFile) {
    6.55 -                Options options = Options.instance(c);
    6.56 -                options.put("ignore.symbol.file", "true");
    6.57 -            }
    6.58 -
    6.59 -            return new JavacFileManager(c, false, null);
    6.60 -        } finally {
    6.61 -            if (resetProperties) {
    6.62 -                if (prev == null) {
    6.63 -                    System.getProperties().remove("useJavaUtilZip");
    6.64 -                } else {
    6.65 -                    System.setProperty("useJavaUtilZip", prev);
    6.66 -                }
    6.67 -            }
    6.68 +    JavacFileManager createFileManager(boolean useOptimizedZip, boolean useSymbolFile) {
    6.69 +        Context ctx = new Context();
    6.70 +        Options options = Options.instance(ctx);
    6.71 +        if (useOptimizedZip) {
    6.72 +            options.put("useOptimizedZip", "true");
    6.73          }
    6.74 +        if (!useSymbolFile) {
    6.75 +            options.put("ignore.symbol.file", "true");
    6.76 +        }
    6.77 +        return new JavacFileManager(ctx, false, null);
    6.78      }
    6.79  
    6.80      File createDir(String name, String... entries) throws Exception {

mercurial