6714365: refactor JavacFileManager to move nested classes to top level

Wed, 18 Jun 2008 07:23:25 -0700

author
jjg
date
Wed, 18 Jun 2008 07:23:25 -0700
changeset 57
aa67a5da66e3
parent 56
f9a4b9e1a521
child 58
8bc2ca2a3b0a

6714365: refactor JavacFileManager to move nested classes to top level
Reviewed-by: mcimadamore

src/share/classes/com/sun/tools/javac/file/BaseFileObject.java file | annotate | diff | comparison | revisions
src/share/classes/com/sun/tools/javac/file/JavacFileManager.java file | annotate | diff | comparison | revisions
src/share/classes/com/sun/tools/javac/file/RegularFileObject.java file | annotate | diff | comparison | revisions
src/share/classes/com/sun/tools/javac/file/SymbolArchive.java file | annotate | diff | comparison | revisions
src/share/classes/com/sun/tools/javac/file/ZipArchive.java file | annotate | diff | comparison | revisions
src/share/classes/com/sun/tools/javac/file/ZipFileIndex.java file | annotate | diff | comparison | revisions
src/share/classes/com/sun/tools/javac/file/ZipFileIndexArchive.java file | annotate | diff | comparison | revisions
src/share/classes/com/sun/tools/javac/file/ZipFileIndexEntry.java file | annotate | diff | comparison | revisions
src/share/classes/com/sun/tools/javac/jvm/ClassReader.java file | annotate | diff | comparison | revisions
src/share/classes/com/sun/tools/javadoc/JavadocClassReader.java file | annotate | diff | comparison | revisions
     1.1 --- a/src/share/classes/com/sun/tools/javac/file/BaseFileObject.java	Tue Jun 17 10:44:32 2008 -0700
     1.2 +++ b/src/share/classes/com/sun/tools/javac/file/BaseFileObject.java	Wed Jun 18 07:23:25 2008 -0700
     1.3 @@ -25,6 +25,7 @@
     1.4  
     1.5  package com.sun.tools.javac.file;
     1.6  
     1.7 +import java.io.File;
     1.8  import java.io.IOException;
     1.9  import java.io.InputStreamReader;
    1.10  import java.io.Reader;
    1.11 @@ -36,6 +37,9 @@
    1.12  import static javax.tools.JavaFileObject.Kind.*;
    1.13  
    1.14  public abstract class BaseFileObject implements JavaFileObject {
    1.15 +    protected BaseFileObject(JavacFileManager fileManager) {
    1.16 +        this.fileManager = fileManager;
    1.17 +    }
    1.18  
    1.19      public JavaFileObject.Kind getKind() {
    1.20          String n = getName();
    1.21 @@ -76,4 +80,14 @@
    1.22          throw new UnsupportedOperationException();
    1.23      }
    1.24  
    1.25 +    protected abstract String inferBinaryName(Iterable<? extends File> path);
    1.26 +
    1.27 +    protected static String removeExtension(String fileName) {
    1.28 +        int lastDot = fileName.lastIndexOf(".");
    1.29 +        return (lastDot == -1 ? fileName : fileName.substring(0, lastDot));
    1.30 +    }
    1.31 +
    1.32 +    /** The file manager that created this JavaFileObject. */
    1.33 +    protected final JavacFileManager fileManager;
    1.34 +
    1.35  }
     2.1 --- a/src/share/classes/com/sun/tools/javac/file/JavacFileManager.java	Tue Jun 17 10:44:32 2008 -0700
     2.2 +++ b/src/share/classes/com/sun/tools/javac/file/JavacFileManager.java	Wed Jun 18 07:23:25 2008 -0700
     2.3 @@ -1,5 +1,5 @@
     2.4  /*
     2.5 - * Copyright 2005-2006 Sun Microsystems, Inc.  All Rights Reserved.
     2.6 + * Copyright 2005-2008 Sun Microsystems, Inc.  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 @@ -25,21 +25,16 @@
    2.11  
    2.12  package com.sun.tools.javac.file;
    2.13  
    2.14 -import java.io.ByteArrayInputStream;
    2.15  import java.io.ByteArrayOutputStream;
    2.16  import java.io.File;
    2.17  import java.io.FileInputStream;
    2.18  import java.io.FileNotFoundException;
    2.19 -import java.io.FileOutputStream;
    2.20  import java.io.IOException;
    2.21  import java.io.InputStream;
    2.22 -import java.io.OutputStream;
    2.23  import java.io.OutputStreamWriter;
    2.24 -import java.io.Writer;
    2.25  import java.lang.ref.SoftReference;
    2.26  import java.net.MalformedURLException;
    2.27  import java.net.URI;
    2.28 -import java.net.URISyntaxException;
    2.29  import java.net.URL;
    2.30  import java.net.URLClassLoader;
    2.31  import java.nio.ByteBuffer;
    2.32 @@ -56,13 +51,11 @@
    2.33  import java.util.Collection;
    2.34  import java.util.Collections;
    2.35  import java.util.EnumSet;
    2.36 -import java.util.Enumeration;
    2.37  import java.util.HashMap;
    2.38  import java.util.Iterator;
    2.39  import java.util.Map;
    2.40  import java.util.Set;
    2.41  import java.util.concurrent.ConcurrentHashMap;
    2.42 -import java.util.zip.ZipEntry;
    2.43  import java.util.zip.ZipFile;
    2.44  
    2.45  import javax.lang.model.SourceVersion;
    2.46 @@ -96,15 +89,6 @@
    2.47  
    2.48      boolean useZipFileIndex;
    2.49  
    2.50 -    private static int symbolFilePrefixLength = 0;
    2.51 -    static {
    2.52 -        try {
    2.53 -            symbolFilePrefixLength = symbolFilePrefix.getBytes("UTF-8").length;
    2.54 -        } catch (java.io.UnsupportedEncodingException uee) {
    2.55 -            // Can't happen...UTF-8 is always supported.
    2.56 -        }
    2.57 -    }
    2.58 -
    2.59      private static boolean CHECK_ZIP_TIMESTAMP = false;
    2.60      private static Map<File, Boolean> isDirectory = new ConcurrentHashMap<File, Boolean>();
    2.61  
    2.62 @@ -202,7 +186,7 @@
    2.63      }
    2.64  
    2.65      public JavaFileObject getRegularFile(File file) {
    2.66 -        return new RegularFileObject(file);
    2.67 +        return new RegularFileObject(this, file);
    2.68      }
    2.69  
    2.70      public JavaFileObject getFileForOutput(String classname,
    2.71 @@ -405,7 +389,7 @@
    2.72                  } else {
    2.73                      if (isValidFile(fname, fileKinds)) {
    2.74                          JavaFileObject fe =
    2.75 -                        new RegularFileObject(fname, new File(d, fname));
    2.76 +                            new RegularFileObject(this, fname, new File(d, fname));
    2.77                          l.append(fe);
    2.78                      }
    2.79                  }
    2.80 @@ -469,106 +453,13 @@
    2.81          Set<String> getSubdirectories();
    2.82      }
    2.83  
    2.84 -    public class ZipArchive implements Archive {
    2.85 -        protected final Map<String,List<String>> map;
    2.86 -        protected final ZipFile zdir;
    2.87 -        public ZipArchive(ZipFile zdir) throws IOException {
    2.88 -            this.zdir = zdir;
    2.89 -            this.map = new HashMap<String,List<String>>();
    2.90 -            for (Enumeration<? extends ZipEntry> e = zdir.entries(); e.hasMoreElements(); ) {
    2.91 -                ZipEntry entry;
    2.92 -                try {
    2.93 -                    entry = e.nextElement();
    2.94 -                } catch (InternalError ex) {
    2.95 -                    IOException io = new IOException();
    2.96 -                    io.initCause(ex); // convenience constructors added in Mustang :-(
    2.97 -                    throw io;
    2.98 -                }
    2.99 -                addZipEntry(entry);
   2.100 -            }
   2.101 -        }
   2.102 -
   2.103 -        void addZipEntry(ZipEntry entry) {
   2.104 -            String name = entry.getName();
   2.105 -            int i = name.lastIndexOf('/');
   2.106 -            String dirname = name.substring(0, i+1);
   2.107 -            String basename = name.substring(i+1);
   2.108 -            if (basename.length() == 0)
   2.109 -                return;
   2.110 -            List<String> list = map.get(dirname);
   2.111 -            if (list == null)
   2.112 -                list = List.nil();
   2.113 -            list = list.prepend(basename);
   2.114 -            map.put(dirname, list);
   2.115 -        }
   2.116 -
   2.117 -        public boolean contains(String name) {
   2.118 -            int i = name.lastIndexOf('/');
   2.119 -            String dirname = name.substring(0, i+1);
   2.120 -            String basename = name.substring(i+1);
   2.121 -            if (basename.length() == 0)
   2.122 -                return false;
   2.123 -            List<String> list = map.get(dirname);
   2.124 -            return (list != null && list.contains(basename));
   2.125 -        }
   2.126 -
   2.127 -        public List<String> getFiles(String subdirectory) {
   2.128 -            return map.get(subdirectory);
   2.129 -        }
   2.130 -
   2.131 -        public JavaFileObject getFileObject(String subdirectory, String file) {
   2.132 -            ZipEntry ze = zdir.getEntry(subdirectory + file);
   2.133 -            return new ZipFileObject(file, zdir, ze);
   2.134 -        }
   2.135 -
   2.136 -        public Set<String> getSubdirectories() {
   2.137 -            return map.keySet();
   2.138 -        }
   2.139 -
   2.140 -        public void close() throws IOException {
   2.141 -            zdir.close();
   2.142 -        }
   2.143 -    }
   2.144 -
   2.145 -    public class SymbolArchive extends ZipArchive {
   2.146 -        final File origFile;
   2.147 -        public SymbolArchive(File orig, ZipFile zdir) throws IOException {
   2.148 -            super(zdir);
   2.149 -            this.origFile = orig;
   2.150 -        }
   2.151 -
   2.152 -        @Override
   2.153 -        void addZipEntry(ZipEntry entry) {
   2.154 -            // called from super constructor, may not refer to origFile.
   2.155 -            String name = entry.getName();
   2.156 -            if (!name.startsWith(symbolFilePrefix))
   2.157 -                return;
   2.158 -            name = name.substring(symbolFilePrefix.length());
   2.159 -            int i = name.lastIndexOf('/');
   2.160 -            String dirname = name.substring(0, i+1);
   2.161 -            String basename = name.substring(i+1);
   2.162 -            if (basename.length() == 0)
   2.163 -                return;
   2.164 -            List<String> list = map.get(dirname);
   2.165 -            if (list == null)
   2.166 -                list = List.nil();
   2.167 -            list = list.prepend(basename);
   2.168 -            map.put(dirname, list);
   2.169 -        }
   2.170 -
   2.171 -        @Override
   2.172 -        public JavaFileObject getFileObject(String subdirectory, String file) {
   2.173 -            return super.getFileObject(symbolFilePrefix + subdirectory, file);
   2.174 -        }
   2.175 -    }
   2.176 -
   2.177      public class MissingArchive implements Archive {
   2.178          final File zipFileName;
   2.179          public MissingArchive(File name) {
   2.180              zipFileName = name;
   2.181          }
   2.182          public boolean contains(String name) {
   2.183 -              return false;
   2.184 +            return false;
   2.185          }
   2.186  
   2.187          public void close() {
   2.188 @@ -647,19 +538,23 @@
   2.189  
   2.190                  if (origZipFileName == zipFileName) {
   2.191                      if (!useZipFileIndex) {
   2.192 -                        archive = new ZipArchive(zdir);
   2.193 +                        archive = new ZipArchive(this, zdir);
   2.194                      } else {
   2.195 -                        archive = new ZipFileIndexArchive(this, ZipFileIndex.getZipFileIndex(zipFileName, 0,
   2.196 +                        archive = new ZipFileIndexArchive(this, ZipFileIndex.getZipFileIndex(zipFileName, null,
   2.197                                  usePreindexedCache, preindexCacheLocation, options.get("writezipindexfiles") != null));
   2.198                      }
   2.199                  }
   2.200                  else {
   2.201                      if (!useZipFileIndex) {
   2.202 -                        archive = new SymbolArchive(origZipFileName, zdir);
   2.203 +                        archive = new SymbolArchive(this, origZipFileName, zdir, symbolFilePrefix);
   2.204                      }
   2.205                      else {
   2.206 -                        archive = new ZipFileIndexArchive(this, ZipFileIndex.getZipFileIndex(zipFileName, symbolFilePrefixLength,
   2.207 -                                usePreindexedCache, preindexCacheLocation, options.get("writezipindexfiles") != null));
   2.208 +                        archive = new ZipFileIndexArchive(this,
   2.209 +                                ZipFileIndex.getZipFileIndex(zipFileName,
   2.210 +                                symbolFilePrefix,
   2.211 +                                usePreindexedCache,
   2.212 +                                preindexCacheLocation,
   2.213 +                                options.get("writezipindexfiles") != null));
   2.214                      }
   2.215                  }
   2.216              } catch (FileNotFoundException ex) {
   2.217 @@ -695,7 +590,17 @@
   2.218          }
   2.219      }
   2.220  
   2.221 -    private Map<JavaFileObject, SoftReference<CharBuffer>> contentCache = new HashMap<JavaFileObject, SoftReference<CharBuffer>>();
   2.222 +    CharBuffer getCachedContent(JavaFileObject file) {
   2.223 +        SoftReference<CharBuffer> r = contentCache.get(file);
   2.224 +        return (r == null ? null : r.get());
   2.225 +    }
   2.226 +
   2.227 +    void cache(JavaFileObject file, CharBuffer cb) {
   2.228 +        contentCache.put(file, new SoftReference<CharBuffer>(cb));
   2.229 +    }
   2.230 +
   2.231 +    private final Map<JavaFileObject, SoftReference<CharBuffer>> contentCache
   2.232 +            = new HashMap<JavaFileObject, SoftReference<CharBuffer>>();
   2.233  
   2.234      private String defaultEncodingName;
   2.235      private String getDefaultEncodingName() {
   2.236 @@ -725,7 +630,7 @@
   2.237      /**
   2.238       * Make a byte buffer from an input stream.
   2.239       */
   2.240 -    private ByteBuffer makeByteBuffer(InputStream in)
   2.241 +    ByteBuffer makeByteBuffer(InputStream in)
   2.242          throws IOException {
   2.243          int limit = in.available();
   2.244          if (mmappedIO && in instanceof FileInputStream) {
   2.245 @@ -751,6 +656,10 @@
   2.246          return (ByteBuffer)result.flip();
   2.247      }
   2.248  
   2.249 +    void recycleByteBuffer(ByteBuffer bb) {
   2.250 +        byteBufferCache.put(bb);
   2.251 +    }
   2.252 +
   2.253      /**
   2.254       * A single-element cache of direct byte buffers.
   2.255       */
   2.256 @@ -769,9 +678,10 @@
   2.257              cached = x;
   2.258          }
   2.259      }
   2.260 +
   2.261      private final ByteBufferCache byteBufferCache;
   2.262  
   2.263 -    private CharsetDecoder getDecoder(String encodingName, boolean ignoreEncodingErrors) {
   2.264 +    CharsetDecoder getDecoder(String encodingName, boolean ignoreEncodingErrors) {
   2.265          Charset charset = (this.charset == null)
   2.266              ? Charset.forName(encodingName)
   2.267              : this.charset;
   2.268 @@ -791,7 +701,7 @@
   2.269      /**
   2.270       * Decode a ByteBuffer into a CharBuffer.
   2.271       */
   2.272 -    private CharBuffer decode(ByteBuffer inbuf, boolean ignoreEncodingErrors) {
   2.273 +    CharBuffer decode(ByteBuffer inbuf, boolean ignoreEncodingErrors) {
   2.274          String encodingName = getEncodingName();
   2.275          CharsetDecoder decoder;
   2.276          try {
   2.277 @@ -901,48 +811,14 @@
   2.278          // Need to match the path semantics of list(location, ...)
   2.279          Iterable<? extends File> path = getLocation(location);
   2.280          if (path == null) {
   2.281 -            //System.err.println("Path for " + location + " is null");
   2.282              return null;
   2.283          }
   2.284 -        //System.err.println("Path for " + location + " is " + path);
   2.285  
   2.286 -        if (file instanceof RegularFileObject) {
   2.287 -            RegularFileObject r = (RegularFileObject) file;
   2.288 -            String rPath = r.getPath();
   2.289 -            //System.err.println("RegularFileObject " + file + " " +r.getPath());
   2.290 -            for (File dir: path) {
   2.291 -                //System.err.println("dir: " + dir);
   2.292 -                String dPath = dir.getPath();
   2.293 -                if (!dPath.endsWith(File.separator))
   2.294 -                    dPath += File.separator;
   2.295 -                if (rPath.regionMatches(true, 0, dPath, 0, dPath.length())
   2.296 -                    && new File(rPath.substring(0, dPath.length())).equals(new File(dPath))) {
   2.297 -                    String relativeName = rPath.substring(dPath.length());
   2.298 -                    return removeExtension(relativeName).replace(File.separatorChar, '.');
   2.299 -                }
   2.300 -            }
   2.301 -        } else if (file instanceof ZipFileObject) {
   2.302 -            ZipFileObject z = (ZipFileObject) file;
   2.303 -            String entryName = z.getZipEntryName();
   2.304 -            if (entryName.startsWith(symbolFilePrefix))
   2.305 -                entryName = entryName.substring(symbolFilePrefix.length());
   2.306 -            return removeExtension(entryName).replace('/', '.');
   2.307 -        } else if (file instanceof ZipFileIndexFileObject) {
   2.308 -            ZipFileIndexFileObject z = (ZipFileIndexFileObject) file;
   2.309 -            String entryName = z.getZipEntryName();
   2.310 -            if (entryName.startsWith(symbolFilePrefix))
   2.311 -                entryName = entryName.substring(symbolFilePrefix.length());
   2.312 -            return removeExtension(entryName).replace(File.separatorChar, '.');
   2.313 +        if (file instanceof BaseFileObject) {
   2.314 +            return ((BaseFileObject) file).inferBinaryName(path);
   2.315          } else
   2.316              throw new IllegalArgumentException(file.getClass().getName());
   2.317 -        // System.err.println("inferBinaryName failed for " + file);
   2.318 -        return null;
   2.319      }
   2.320 -    // where
   2.321 -        private static String removeExtension(String fileName) {
   2.322 -            int lastDot = fileName.lastIndexOf(".");
   2.323 -            return (lastDot == -1 ? fileName : fileName.substring(0, lastDot));
   2.324 -        }
   2.325  
   2.326      public boolean isSameFile(FileObject a, FileObject b) {
   2.327          nullCheck(a);
   2.328 @@ -1029,7 +905,7 @@
   2.329              if (dir.isDirectory()) {
   2.330                  File f = new File(dir, name.replace('/', File.separatorChar));
   2.331                  if (f.exists())
   2.332 -                    return new RegularFileObject(f);
   2.333 +                    return new RegularFileObject(this, f);
   2.334              } else {
   2.335                  Archive a = openArchive(dir);
   2.336                  if (a.contains(name)) {
   2.337 @@ -1091,7 +967,7 @@
   2.338                  if (sibling != null && sibling instanceof RegularFileObject) {
   2.339                      siblingDir = ((RegularFileObject)sibling).f.getParentFile();
   2.340                  }
   2.341 -                return new RegularFileObject(new File(siblingDir, baseName(fileName)));
   2.342 +                return new RegularFileObject(this, new File(siblingDir, baseName(fileName)));
   2.343              }
   2.344          } else if (location == SOURCE_OUTPUT) {
   2.345              dir = (getSourceOutDir() != null ? getSourceOutDir() : getClassOutDir());
   2.346 @@ -1105,7 +981,7 @@
   2.347          }
   2.348  
   2.349          File file = (dir == null ? new File(fileName) : new File(dir, fileName));
   2.350 -        return new RegularFileObject(file);
   2.351 +        return new RegularFileObject(this, file);
   2.352  
   2.353      }
   2.354  
   2.355 @@ -1118,7 +994,7 @@
   2.356          else
   2.357              result = new ArrayList<RegularFileObject>();
   2.358          for (File f: files)
   2.359 -            result.add(new RegularFileObject(nullCheck(f)));
   2.360 +            result.add(new RegularFileObject(this, nullCheck(f)));
   2.361          return result;
   2.362      }
   2.363  
   2.364 @@ -1268,452 +1144,4 @@
   2.365              t.getClass(); // null check
   2.366          return it;
   2.367      }
   2.368 -
   2.369 -    /**
   2.370 -     * A subclass of JavaFileObject representing regular files.
   2.371 -     */
   2.372 -    private class RegularFileObject extends BaseFileObject {
   2.373 -        /** Have the parent directories been created?
   2.374 -         */
   2.375 -        private boolean hasParents=false;
   2.376 -
   2.377 -        /** The file's name.
   2.378 -         */
   2.379 -        private String name;
   2.380 -
   2.381 -        /** The underlying file.
   2.382 -         */
   2.383 -        final File f;
   2.384 -
   2.385 -        public RegularFileObject(File f) {
   2.386 -            this(f.getName(), f);
   2.387 -        }
   2.388 -
   2.389 -        public RegularFileObject(String name, File f) {
   2.390 -            if (f.isDirectory())
   2.391 -                throw new IllegalArgumentException("directories not supported");
   2.392 -            this.name = name;
   2.393 -            this.f = f;
   2.394 -        }
   2.395 -
   2.396 -        public InputStream openInputStream() throws IOException {
   2.397 -            return new FileInputStream(f);
   2.398 -        }
   2.399 -
   2.400 -        protected CharsetDecoder getDecoder(boolean ignoreEncodingErrors) {
   2.401 -            return JavacFileManager.this.getDecoder(getEncodingName(), ignoreEncodingErrors);
   2.402 -        }
   2.403 -
   2.404 -        public OutputStream openOutputStream() throws IOException {
   2.405 -            ensureParentDirectoriesExist();
   2.406 -            return new FileOutputStream(f);
   2.407 -        }
   2.408 -
   2.409 -        public Writer openWriter() throws IOException {
   2.410 -            ensureParentDirectoriesExist();
   2.411 -            return new OutputStreamWriter(new FileOutputStream(f), getEncodingName());
   2.412 -        }
   2.413 -
   2.414 -        private void ensureParentDirectoriesExist() throws IOException {
   2.415 -            if (!hasParents) {
   2.416 -                File parent = f.getParentFile();
   2.417 -                if (parent != null && !parent.exists()) {
   2.418 -                    if (!parent.mkdirs()) {
   2.419 -                        // if the mkdirs failed, it may be because another process concurrently
   2.420 -                        // created the directory, so check if the directory got created
   2.421 -                        // anyway before throwing an exception
   2.422 -                        if (!parent.exists() || !parent.isDirectory())
   2.423 -                            throw new IOException("could not create parent directories");
   2.424 -                    }
   2.425 -                }
   2.426 -                hasParents = true;
   2.427 -            }
   2.428 -        }
   2.429 -
   2.430 -        /** @deprecated see bug 6410637 */
   2.431 -        @Deprecated
   2.432 -        public String getName() {
   2.433 -            return name;
   2.434 -        }
   2.435 -
   2.436 -        public boolean isNameCompatible(String cn, JavaFileObject.Kind kind) {
   2.437 -            cn.getClass(); // null check
   2.438 -            if (kind == Kind.OTHER && getKind() != kind)
   2.439 -                return false;
   2.440 -            String n = cn + kind.extension;
   2.441 -            if (name.equals(n))
   2.442 -                return true;
   2.443 -            if (name.equalsIgnoreCase(n)) {
   2.444 -                try {
   2.445 -                    // allow for Windows
   2.446 -                    return (f.getCanonicalFile().getName().equals(n));
   2.447 -                } catch (IOException e) {
   2.448 -                }
   2.449 -            }
   2.450 -            return false;
   2.451 -        }
   2.452 -
   2.453 -        /** @deprecated see bug 6410637 */
   2.454 -        @Deprecated
   2.455 -        public String getPath() {
   2.456 -            return f.getPath();
   2.457 -        }
   2.458 -
   2.459 -        public long getLastModified() {
   2.460 -            return f.lastModified();
   2.461 -        }
   2.462 -
   2.463 -        public boolean delete() {
   2.464 -            return f.delete();
   2.465 -        }
   2.466 -
   2.467 -        public CharBuffer getCharContent(boolean ignoreEncodingErrors) throws IOException {
   2.468 -            SoftReference<CharBuffer> r = contentCache.get(this);
   2.469 -            CharBuffer cb = (r == null ? null : r.get());
   2.470 -            if (cb == null) {
   2.471 -                InputStream in = new FileInputStream(f);
   2.472 -                try {
   2.473 -                    ByteBuffer bb = makeByteBuffer(in);
   2.474 -                    JavaFileObject prev = log.useSource(this);
   2.475 -                    try {
   2.476 -                        cb = decode(bb, ignoreEncodingErrors);
   2.477 -                    } finally {
   2.478 -                        log.useSource(prev);
   2.479 -                    }
   2.480 -                    byteBufferCache.put(bb); // save for next time
   2.481 -                    if (!ignoreEncodingErrors)
   2.482 -                        contentCache.put(this, new SoftReference<CharBuffer>(cb));
   2.483 -                } finally {
   2.484 -                    in.close();
   2.485 -                }
   2.486 -            }
   2.487 -            return cb;
   2.488 -        }
   2.489 -
   2.490 -        @Override
   2.491 -        public boolean equals(Object other) {
   2.492 -            if (!(other instanceof RegularFileObject))
   2.493 -                return false;
   2.494 -            RegularFileObject o = (RegularFileObject) other;
   2.495 -            try {
   2.496 -                return f.equals(o.f)
   2.497 -                    || f.getCanonicalFile().equals(o.f.getCanonicalFile());
   2.498 -            } catch (IOException e) {
   2.499 -                return false;
   2.500 -            }
   2.501 -        }
   2.502 -
   2.503 -        @Override
   2.504 -        public int hashCode() {
   2.505 -            return f.hashCode();
   2.506 -        }
   2.507 -
   2.508 -        public URI toUri() {
   2.509 -            try {
   2.510 -                // Do no use File.toURI to avoid file system access
   2.511 -                String path = f.getAbsolutePath().replace(File.separatorChar, '/');
   2.512 -                return new URI("file://" + path).normalize();
   2.513 -            } catch (URISyntaxException ex) {
   2.514 -                return f.toURI();
   2.515 -            }
   2.516 -        }
   2.517 -
   2.518 -    }
   2.519 -
   2.520 -    /**
   2.521 -     * A subclass of JavaFileObject representing zip entries.
   2.522 -     */
   2.523 -    public class ZipFileObject extends BaseFileObject {
   2.524 -
   2.525 -        /** The entry's name.
   2.526 -         */
   2.527 -        private String name;
   2.528 -
   2.529 -        /** The zipfile containing the entry.
   2.530 -         */
   2.531 -        ZipFile zdir;
   2.532 -
   2.533 -        /** The underlying zip entry object.
   2.534 -         */
   2.535 -        ZipEntry entry;
   2.536 -
   2.537 -        public ZipFileObject(String name, ZipFile zdir, ZipEntry entry) {
   2.538 -            this.name = name;
   2.539 -            this.zdir = zdir;
   2.540 -            this.entry = entry;
   2.541 -        }
   2.542 -
   2.543 -        public InputStream openInputStream() throws IOException {
   2.544 -            return zdir.getInputStream(entry);
   2.545 -        }
   2.546 -
   2.547 -        public OutputStream openOutputStream() throws IOException {
   2.548 -            throw new UnsupportedOperationException();
   2.549 -        }
   2.550 -
   2.551 -        protected CharsetDecoder getDecoder(boolean ignoreEncodingErrors) {
   2.552 -            return JavacFileManager.this.getDecoder(getEncodingName(), ignoreEncodingErrors);
   2.553 -        }
   2.554 -
   2.555 -        public Writer openWriter() throws IOException {
   2.556 -            throw new UnsupportedOperationException();
   2.557 -        }
   2.558 -
   2.559 -        /** @deprecated see bug 6410637 */
   2.560 -        @Deprecated
   2.561 -        public String getName() {
   2.562 -            return name;
   2.563 -        }
   2.564 -
   2.565 -        public boolean isNameCompatible(String cn, JavaFileObject.Kind k) {
   2.566 -            cn.getClass(); // null check
   2.567 -            if (k == Kind.OTHER && getKind() != k)
   2.568 -                return false;
   2.569 -            return name.equals(cn + k.extension);
   2.570 -        }
   2.571 -
   2.572 -        /** @deprecated see bug 6410637 */
   2.573 -        @Deprecated
   2.574 -        public String getPath() {
   2.575 -            return zdir.getName() + "(" + entry + ")";
   2.576 -        }
   2.577 -
   2.578 -        public long getLastModified() {
   2.579 -            return entry.getTime();
   2.580 -        }
   2.581 -
   2.582 -        public boolean delete() {
   2.583 -            throw new UnsupportedOperationException();
   2.584 -        }
   2.585 -
   2.586 -        public CharBuffer getCharContent(boolean ignoreEncodingErrors) throws IOException {
   2.587 -            SoftReference<CharBuffer> r = contentCache.get(this);
   2.588 -            CharBuffer cb = (r == null ? null : r.get());
   2.589 -            if (cb == null) {
   2.590 -                InputStream in = zdir.getInputStream(entry);
   2.591 -                try {
   2.592 -                    ByteBuffer bb = makeByteBuffer(in);
   2.593 -                    JavaFileObject prev = log.useSource(this);
   2.594 -                    try {
   2.595 -                        cb = decode(bb, ignoreEncodingErrors);
   2.596 -                    } finally {
   2.597 -                        log.useSource(prev);
   2.598 -                    }
   2.599 -                    byteBufferCache.put(bb); // save for next time
   2.600 -                    if (!ignoreEncodingErrors)
   2.601 -                        contentCache.put(this, new SoftReference<CharBuffer>(cb));
   2.602 -                } finally {
   2.603 -                    in.close();
   2.604 -                }
   2.605 -            }
   2.606 -            return cb;
   2.607 -        }
   2.608 -
   2.609 -        @Override
   2.610 -        public boolean equals(Object other) {
   2.611 -            if (!(other instanceof ZipFileObject))
   2.612 -                return false;
   2.613 -            ZipFileObject o = (ZipFileObject) other;
   2.614 -            return zdir.equals(o.zdir) || name.equals(o.name);
   2.615 -        }
   2.616 -
   2.617 -        @Override
   2.618 -        public int hashCode() {
   2.619 -            return zdir.hashCode() + name.hashCode();
   2.620 -        }
   2.621 -
   2.622 -        public String getZipName() {
   2.623 -            return zdir.getName();
   2.624 -        }
   2.625 -
   2.626 -        public String getZipEntryName() {
   2.627 -            return entry.getName();
   2.628 -        }
   2.629 -
   2.630 -        public URI toUri() {
   2.631 -            String zipName = new File(getZipName()).toURI().normalize().getPath();
   2.632 -            String entryName = getZipEntryName();
   2.633 -            return URI.create("jar:" + zipName + "!" + entryName);
   2.634 -        }
   2.635 -
   2.636 -    }
   2.637 -
   2.638 -    /**
   2.639 -     * A subclass of JavaFileObject representing zip entries using the com.sun.tools.javac.zip.ZipFileIndex implementation.
   2.640 -     */
   2.641 -    public class ZipFileIndexFileObject extends BaseFileObject {
   2.642 -
   2.643 -            /** The entry's name.
   2.644 -         */
   2.645 -        private String name;
   2.646 -
   2.647 -        /** The zipfile containing the entry.
   2.648 -         */
   2.649 -        ZipFileIndex zfIndex;
   2.650 -
   2.651 -        /** The underlying zip entry object.
   2.652 -         */
   2.653 -        ZipFileIndexEntry entry;
   2.654 -
   2.655 -        /** The InputStream for this zip entry (file.)
   2.656 -         */
   2.657 -        InputStream inputStream = null;
   2.658 -
   2.659 -        /** The name of the zip file where this entry resides.
   2.660 -         */
   2.661 -        String zipName;
   2.662 -
   2.663 -        JavacFileManager defFileManager = null;
   2.664 -
   2.665 -        public ZipFileIndexFileObject(JavacFileManager fileManager, ZipFileIndex zfIndex, ZipFileIndexEntry entry, String zipFileName) {
   2.666 -            super();
   2.667 -            this.name = entry.getFileName();
   2.668 -            this.zfIndex = zfIndex;
   2.669 -            this.entry = entry;
   2.670 -            this.zipName = zipFileName;
   2.671 -            defFileManager = fileManager;
   2.672 -        }
   2.673 -
   2.674 -        public InputStream openInputStream() throws IOException {
   2.675 -
   2.676 -            if (inputStream == null) {
   2.677 -                inputStream = new ByteArrayInputStream(read());
   2.678 -            }
   2.679 -            return inputStream;
   2.680 -        }
   2.681 -
   2.682 -        protected CharsetDecoder getDecoder(boolean ignoreEncodingErrors) {
   2.683 -            return JavacFileManager.this.getDecoder(getEncodingName(), ignoreEncodingErrors);
   2.684 -        }
   2.685 -
   2.686 -        public OutputStream openOutputStream() throws IOException {
   2.687 -            throw new UnsupportedOperationException();
   2.688 -        }
   2.689 -
   2.690 -        public Writer openWriter() throws IOException {
   2.691 -            throw new UnsupportedOperationException();
   2.692 -        }
   2.693 -
   2.694 -        /** @deprecated see bug 6410637 */
   2.695 -        @Deprecated
   2.696 -        public String getName() {
   2.697 -            return name;
   2.698 -        }
   2.699 -
   2.700 -        public boolean isNameCompatible(String cn, JavaFileObject.Kind k) {
   2.701 -            cn.getClass(); // null check
   2.702 -            if (k == Kind.OTHER && getKind() != k)
   2.703 -                return false;
   2.704 -            return name.equals(cn + k.extension);
   2.705 -        }
   2.706 -
   2.707 -        /** @deprecated see bug 6410637 */
   2.708 -        @Deprecated
   2.709 -        public String getPath() {
   2.710 -            return zipName + "(" + entry.getName() + ")";
   2.711 -        }
   2.712 -
   2.713 -        public long getLastModified() {
   2.714 -            return entry.getLastModified();
   2.715 -        }
   2.716 -
   2.717 -        public boolean delete() {
   2.718 -            throw new UnsupportedOperationException();
   2.719 -        }
   2.720 -
   2.721 -        @Override
   2.722 -        public boolean equals(Object other) {
   2.723 -            if (!(other instanceof ZipFileIndexFileObject))
   2.724 -                return false;
   2.725 -            ZipFileIndexFileObject o = (ZipFileIndexFileObject) other;
   2.726 -            return entry.equals(o.entry);
   2.727 -        }
   2.728 -
   2.729 -        @Override
   2.730 -        public int hashCode() {
   2.731 -            return zipName.hashCode() + (name.hashCode() << 10);
   2.732 -        }
   2.733 -
   2.734 -        public String getZipName() {
   2.735 -            return zipName;
   2.736 -        }
   2.737 -
   2.738 -        public String getZipEntryName() {
   2.739 -            return entry.getName();
   2.740 -        }
   2.741 -
   2.742 -        public URI toUri() {
   2.743 -            String zipName = new File(getZipName()).toURI().normalize().getPath();
   2.744 -            String entryName = getZipEntryName();
   2.745 -            if (File.separatorChar != '/') {
   2.746 -                entryName = entryName.replace(File.separatorChar, '/');
   2.747 -            }
   2.748 -            return URI.create("jar:" + zipName + "!" + entryName);
   2.749 -        }
   2.750 -
   2.751 -        private byte[] read() throws IOException {
   2.752 -            if (entry == null) {
   2.753 -                entry = zfIndex.getZipIndexEntry(name);
   2.754 -                if (entry == null)
   2.755 -                  throw new FileNotFoundException();
   2.756 -            }
   2.757 -            return zfIndex.read(entry);
   2.758 -        }
   2.759 -
   2.760 -        public CharBuffer getCharContent(boolean ignoreEncodingErrors) throws IOException {
   2.761 -            SoftReference<CharBuffer> r = defFileManager.contentCache.get(this);
   2.762 -            CharBuffer cb = (r == null ? null : r.get());
   2.763 -            if (cb == null) {
   2.764 -                InputStream in = new ByteArrayInputStream(zfIndex.read(entry));
   2.765 -                try {
   2.766 -                    ByteBuffer bb = makeByteBuffer(in);
   2.767 -                    JavaFileObject prev = log.useSource(this);
   2.768 -                    try {
   2.769 -                        cb = decode(bb, ignoreEncodingErrors);
   2.770 -                    } finally {
   2.771 -                        log.useSource(prev);
   2.772 -                    }
   2.773 -                    byteBufferCache.put(bb); // save for next time
   2.774 -                    if (!ignoreEncodingErrors)
   2.775 -                        defFileManager.contentCache.put(this, new SoftReference<CharBuffer>(cb));
   2.776 -                } finally {
   2.777 -                    in.close();
   2.778 -                }
   2.779 -            }
   2.780 -            return cb;
   2.781 -        }
   2.782 -    }
   2.783 -
   2.784 -    public class ZipFileIndexArchive implements Archive {
   2.785 -        private final ZipFileIndex zfIndex;
   2.786 -        private JavacFileManager fileManager;
   2.787 -
   2.788 -        public ZipFileIndexArchive(JavacFileManager fileManager, ZipFileIndex zdir) throws IOException {
   2.789 -            this.fileManager = fileManager;
   2.790 -            this.zfIndex = zdir;
   2.791 -        }
   2.792 -
   2.793 -        public boolean contains(String name) {
   2.794 -            return zfIndex.contains(name);
   2.795 -        }
   2.796 -
   2.797 -        public com.sun.tools.javac.util.List<String> getFiles(String subdirectory) {
   2.798 -              return zfIndex.getFiles(((subdirectory.endsWith("/") || subdirectory.endsWith("\\"))? subdirectory.substring(0, subdirectory.length() - 1) : subdirectory));
   2.799 -        }
   2.800 -
   2.801 -        public JavaFileObject getFileObject(String subdirectory, String file) {
   2.802 -            String fullZipFileName = subdirectory + file;
   2.803 -            ZipFileIndexEntry entry = zfIndex.getZipIndexEntry(fullZipFileName);
   2.804 -            JavaFileObject ret = new ZipFileIndexFileObject(fileManager, zfIndex, entry, zfIndex.getZipFile().getPath());
   2.805 -            return ret;
   2.806 -        }
   2.807 -
   2.808 -        public Set<String> getSubdirectories() {
   2.809 -            return zfIndex.getAllDirectories();
   2.810 -        }
   2.811 -
   2.812 -        public void close() throws IOException {
   2.813 -            zfIndex.close();
   2.814 -        }
   2.815 -    }
   2.816  }
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/src/share/classes/com/sun/tools/javac/file/RegularFileObject.java	Wed Jun 18 07:23:25 2008 -0700
     3.3 @@ -0,0 +1,204 @@
     3.4 +/*
     3.5 + * Copyright 2005-2008 Sun Microsystems, Inc.  All Rights Reserved.
     3.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3.7 + *
     3.8 + * This code is free software; you can redistribute it and/or modify it
     3.9 + * under the terms of the GNU General Public License version 2 only, as
    3.10 + * published by the Free Software Foundation.  Sun designates this
    3.11 + * particular file as subject to the "Classpath" exception as provided
    3.12 + * by Sun in the LICENSE file that accompanied this code.
    3.13 + *
    3.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
    3.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    3.16 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    3.17 + * version 2 for more details (a copy is included in the LICENSE file that
    3.18 + * accompanied this code).
    3.19 + *
    3.20 + * You should have received a copy of the GNU General Public License version
    3.21 + * 2 along with this work; if not, write to the Free Software Foundation,
    3.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    3.23 + *
    3.24 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
    3.25 + * CA 95054 USA or visit www.sun.com if you need additional information or
    3.26 + * have any questions.
    3.27 + */
    3.28 +
    3.29 +package com.sun.tools.javac.file;
    3.30 +
    3.31 +import java.io.File;
    3.32 +import java.io.FileInputStream;
    3.33 +import java.io.FileOutputStream;
    3.34 +import java.io.IOException;
    3.35 +import java.io.InputStream;
    3.36 +import java.io.OutputStream;
    3.37 +import java.io.OutputStreamWriter;
    3.38 +import java.io.Writer;
    3.39 +import java.net.URI;
    3.40 +import java.net.URISyntaxException;
    3.41 +import java.nio.ByteBuffer;
    3.42 +import java.nio.CharBuffer;
    3.43 +import java.nio.charset.CharsetDecoder;
    3.44 +import javax.tools.JavaFileObject;
    3.45 +
    3.46 +/**
    3.47 + * A subclass of JavaFileObject representing regular files.
    3.48 + */
    3.49 +class RegularFileObject extends BaseFileObject {
    3.50 +
    3.51 +    /** Have the parent directories been created?
    3.52 +     */
    3.53 +    private boolean hasParents = false;
    3.54 +    private String name;
    3.55 +    final File f;
    3.56 +
    3.57 +    public RegularFileObject(JavacFileManager fileManager, File f) {
    3.58 +        this(fileManager, f.getName(), f);
    3.59 +    }
    3.60 +
    3.61 +    public RegularFileObject(JavacFileManager fileManager, String name, File f) {
    3.62 +        super(fileManager);
    3.63 +        if (f.isDirectory()) {
    3.64 +            throw new IllegalArgumentException("directories not supported");
    3.65 +        }
    3.66 +        this.name = name;
    3.67 +        this.f = f;
    3.68 +    }
    3.69 +
    3.70 +    public InputStream openInputStream() throws IOException {
    3.71 +        return new FileInputStream(f);
    3.72 +    }
    3.73 +
    3.74 +    protected CharsetDecoder getDecoder(boolean ignoreEncodingErrors) {
    3.75 +        return fileManager.getDecoder(fileManager.getEncodingName(), ignoreEncodingErrors);
    3.76 +    }
    3.77 +
    3.78 +    public OutputStream openOutputStream() throws IOException {
    3.79 +        ensureParentDirectoriesExist();
    3.80 +        return new FileOutputStream(f);
    3.81 +    }
    3.82 +
    3.83 +    public Writer openWriter() throws IOException {
    3.84 +        ensureParentDirectoriesExist();
    3.85 +        return new OutputStreamWriter(new FileOutputStream(f), fileManager.getEncodingName());
    3.86 +    }
    3.87 +
    3.88 +    @Override
    3.89 +    protected String inferBinaryName(Iterable<? extends File> path) {
    3.90 +        String fPath = f.getPath();
    3.91 +        //System.err.println("RegularFileObject " + file + " " +r.getPath());
    3.92 +        for (File dir: path) {
    3.93 +            //System.err.println("dir: " + dir);
    3.94 +            String dPath = dir.getPath();
    3.95 +            if (!dPath.endsWith(File.separator))
    3.96 +                dPath += File.separator;
    3.97 +            if (fPath.regionMatches(true, 0, dPath, 0, dPath.length())
    3.98 +                && new File(fPath.substring(0, dPath.length())).equals(new File(dPath))) {
    3.99 +                String relativeName = fPath.substring(dPath.length());
   3.100 +                return removeExtension(relativeName).replace(File.separatorChar, '.');
   3.101 +            }
   3.102 +        }
   3.103 +        return null;
   3.104 +    }
   3.105 +
   3.106 +    private void ensureParentDirectoriesExist() throws IOException {
   3.107 +        if (!hasParents) {
   3.108 +            File parent = f.getParentFile();
   3.109 +            if (parent != null && !parent.exists()) {
   3.110 +                if (!parent.mkdirs()) {
   3.111 +                    if (!parent.exists() || !parent.isDirectory()) {
   3.112 +                        throw new IOException("could not create parent directories");
   3.113 +                    }
   3.114 +                }
   3.115 +            }
   3.116 +            hasParents = true;
   3.117 +        }
   3.118 +    }
   3.119 +
   3.120 +    @Deprecated
   3.121 +    public String getName() {
   3.122 +        return name;
   3.123 +    }
   3.124 +
   3.125 +    public boolean isNameCompatible(String cn, JavaFileObject.Kind kind) {
   3.126 +        cn.getClass();
   3.127 +        // null check
   3.128 +        if (kind == Kind.OTHER && getKind() != kind) {
   3.129 +            return false;
   3.130 +        }
   3.131 +        String n = cn + kind.extension;
   3.132 +        if (name.equals(n)) {
   3.133 +            return true;
   3.134 +        }
   3.135 +        if (name.equalsIgnoreCase(n)) {
   3.136 +            try {
   3.137 +                // allow for Windows
   3.138 +                return f.getCanonicalFile().getName().equals(n);
   3.139 +            } catch (IOException e) {
   3.140 +            }
   3.141 +        }
   3.142 +        return false;
   3.143 +    }
   3.144 +
   3.145 +    @Deprecated
   3.146 +    public String getPath() {
   3.147 +        return f.getPath();
   3.148 +    }
   3.149 +
   3.150 +    public long getLastModified() {
   3.151 +        return f.lastModified();
   3.152 +    }
   3.153 +
   3.154 +    public boolean delete() {
   3.155 +        return f.delete();
   3.156 +    }
   3.157 +
   3.158 +    public CharBuffer getCharContent(boolean ignoreEncodingErrors) throws IOException {
   3.159 +        CharBuffer cb = fileManager.getCachedContent(this);
   3.160 +        if (cb == null) {
   3.161 +            InputStream in = new FileInputStream(f);
   3.162 +            try {
   3.163 +                ByteBuffer bb = fileManager.makeByteBuffer(in);
   3.164 +                JavaFileObject prev = fileManager.log.useSource(this);
   3.165 +                try {
   3.166 +                    cb = fileManager.decode(bb, ignoreEncodingErrors);
   3.167 +                } finally {
   3.168 +                    fileManager.log.useSource(prev);
   3.169 +                }
   3.170 +                fileManager.recycleByteBuffer(bb);
   3.171 +                if (!ignoreEncodingErrors) {
   3.172 +                    fileManager.cache(this, cb);
   3.173 +                }
   3.174 +            } finally {
   3.175 +                in.close();
   3.176 +            }
   3.177 +        }
   3.178 +        return cb;
   3.179 +    }
   3.180 +
   3.181 +    @Override
   3.182 +    public boolean equals(Object other) {
   3.183 +        if (!(other instanceof RegularFileObject)) {
   3.184 +            return false;
   3.185 +        }
   3.186 +        RegularFileObject o = (RegularFileObject) other;
   3.187 +        try {
   3.188 +            return f.equals(o.f) || f.getCanonicalFile().equals(o.f.getCanonicalFile());
   3.189 +        } catch (IOException e) {
   3.190 +            return false;
   3.191 +        }
   3.192 +    }
   3.193 +
   3.194 +    @Override
   3.195 +    public int hashCode() {
   3.196 +        return f.hashCode();
   3.197 +    }
   3.198 +
   3.199 +    public URI toUri() {
   3.200 +        try {
   3.201 +            String path = f.getAbsolutePath().replace(File.separatorChar, '/');
   3.202 +            return new URI("file://" + path).normalize();
   3.203 +        } catch (URISyntaxException ex) {
   3.204 +            return f.toURI();
   3.205 +        }
   3.206 +    }
   3.207 +}
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/src/share/classes/com/sun/tools/javac/file/SymbolArchive.java	Wed Jun 18 07:23:25 2008 -0700
     4.3 @@ -0,0 +1,71 @@
     4.4 +/*
     4.5 + * Copyright 2005-2008 Sun Microsystems, Inc.  All Rights Reserved.
     4.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4.7 + *
     4.8 + * This code is free software; you can redistribute it and/or modify it
     4.9 + * under the terms of the GNU General Public License version 2 only, as
    4.10 + * published by the Free Software Foundation.  Sun designates this
    4.11 + * particular file as subject to the "Classpath" exception as provided
    4.12 + * by Sun in the LICENSE file that accompanied this code.
    4.13 + *
    4.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
    4.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    4.16 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    4.17 + * version 2 for more details (a copy is included in the LICENSE file that
    4.18 + * accompanied this code).
    4.19 + *
    4.20 + * You should have received a copy of the GNU General Public License version
    4.21 + * 2 along with this work; if not, write to the Free Software Foundation,
    4.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    4.23 + *
    4.24 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
    4.25 + * CA 95054 USA or visit www.sun.com if you need additional information or
    4.26 + * have any questions.
    4.27 + */
    4.28 +
    4.29 +package com.sun.tools.javac.file;
    4.30 +
    4.31 +import com.sun.tools.javac.util.List;
    4.32 +import java.io.File;
    4.33 +import java.io.IOException;
    4.34 +import java.util.zip.ZipEntry;
    4.35 +import java.util.zip.ZipFile;
    4.36 +import javax.tools.JavaFileObject;
    4.37 +
    4.38 +public class SymbolArchive extends ZipArchive {
    4.39 +
    4.40 +    final File origFile;
    4.41 +    final String prefix;
    4.42 +
    4.43 +    public SymbolArchive(JavacFileManager fileManager, File orig, ZipFile zdir, String prefix) throws IOException {
    4.44 +        super(fileManager, zdir);
    4.45 +        this.origFile = orig;
    4.46 +        this.prefix = prefix;
    4.47 +    }
    4.48 +
    4.49 +    @Override
    4.50 +    void addZipEntry(ZipEntry entry) {
    4.51 +        String name = entry.getName();
    4.52 +        if (!name.startsWith(prefix)) {
    4.53 +            return;
    4.54 +        }
    4.55 +        name = name.substring(prefix.length());
    4.56 +        int i = name.lastIndexOf('/');
    4.57 +        String dirname = name.substring(0, i + 1);
    4.58 +        String basename = name.substring(i + 1);
    4.59 +        if (basename.length() == 0) {
    4.60 +            return;
    4.61 +        }
    4.62 +        List<String> list = map.get(dirname);
    4.63 +        if (list == null) {
    4.64 +            list = List.nil();
    4.65 +        }
    4.66 +        list = list.prepend(basename);
    4.67 +        map.put(dirname, list);
    4.68 +    }
    4.69 +
    4.70 +    @Override
    4.71 +    public JavaFileObject getFileObject(String subdirectory, String file) {
    4.72 +        return super.getFileObject(prefix + subdirectory, file);
    4.73 +    }
    4.74 +}
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/src/share/classes/com/sun/tools/javac/file/ZipArchive.java	Wed Jun 18 07:23:25 2008 -0700
     5.3 @@ -0,0 +1,234 @@
     5.4 +/*
     5.5 + * Copyright 2005-2008 Sun Microsystems, Inc.  All Rights Reserved.
     5.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     5.7 + *
     5.8 + * This code is free software; you can redistribute it and/or modify it
     5.9 + * under the terms of the GNU General Public License version 2 only, as
    5.10 + * published by the Free Software Foundation.  Sun designates this
    5.11 + * particular file as subject to the "Classpath" exception as provided
    5.12 + * by Sun in the LICENSE file that accompanied this code.
    5.13 + *
    5.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
    5.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    5.16 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    5.17 + * version 2 for more details (a copy is included in the LICENSE file that
    5.18 + * accompanied this code).
    5.19 + *
    5.20 + * You should have received a copy of the GNU General Public License version
    5.21 + * 2 along with this work; if not, write to the Free Software Foundation,
    5.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    5.23 + *
    5.24 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
    5.25 + * CA 95054 USA or visit www.sun.com if you need additional information or
    5.26 + * have any questions.
    5.27 + */
    5.28 +
    5.29 +package com.sun.tools.javac.file;
    5.30 +
    5.31 +import java.io.IOException;
    5.32 +import java.util.Enumeration;
    5.33 +import java.util.HashMap;
    5.34 +import java.util.Map;
    5.35 +import java.util.Set;
    5.36 +import java.util.zip.ZipEntry;
    5.37 +import java.util.zip.ZipFile;
    5.38 +import javax.tools.JavaFileObject;
    5.39 +
    5.40 +import com.sun.tools.javac.file.JavacFileManager.Archive;
    5.41 +import com.sun.tools.javac.util.List;
    5.42 +import java.io.File;
    5.43 +import java.io.InputStream;
    5.44 +import java.io.OutputStream;
    5.45 +import java.io.Writer;
    5.46 +import java.net.URI;
    5.47 +import java.nio.ByteBuffer;
    5.48 +import java.nio.CharBuffer;
    5.49 +import java.nio.charset.CharsetDecoder;
    5.50 +
    5.51 +public class ZipArchive implements Archive {
    5.52 +
    5.53 +    public ZipArchive(JavacFileManager fm, ZipFile zdir) throws IOException {
    5.54 +        this.fileManager = fm;
    5.55 +        this.zdir = zdir;
    5.56 +        this.map = new HashMap<String,List<String>>();
    5.57 +        for (Enumeration<? extends ZipEntry> e = zdir.entries(); e.hasMoreElements(); ) {
    5.58 +            ZipEntry entry;
    5.59 +            try {
    5.60 +                entry = e.nextElement();
    5.61 +            } catch (InternalError ex) {
    5.62 +                IOException io = new IOException();
    5.63 +                io.initCause(ex); // convenience constructors added in Mustang :-(
    5.64 +                throw io;
    5.65 +            }
    5.66 +            addZipEntry(entry);
    5.67 +        }
    5.68 +    }
    5.69 +
    5.70 +    void addZipEntry(ZipEntry entry) {
    5.71 +        String name = entry.getName();
    5.72 +        int i = name.lastIndexOf('/');
    5.73 +        String dirname = name.substring(0, i+1);
    5.74 +        String basename = name.substring(i+1);
    5.75 +        if (basename.length() == 0)
    5.76 +            return;
    5.77 +        List<String> list = map.get(dirname);
    5.78 +        if (list == null)
    5.79 +            list = List.nil();
    5.80 +        list = list.prepend(basename);
    5.81 +        map.put(dirname, list);
    5.82 +    }
    5.83 +
    5.84 +    public boolean contains(String name) {
    5.85 +        int i = name.lastIndexOf('/');
    5.86 +        String dirname = name.substring(0, i+1);
    5.87 +        String basename = name.substring(i+1);
    5.88 +        if (basename.length() == 0)
    5.89 +            return false;
    5.90 +        List<String> list = map.get(dirname);
    5.91 +        return (list != null && list.contains(basename));
    5.92 +    }
    5.93 +
    5.94 +    public List<String> getFiles(String subdirectory) {
    5.95 +        return map.get(subdirectory);
    5.96 +    }
    5.97 +
    5.98 +    public JavaFileObject getFileObject(String subdirectory, String file) {
    5.99 +        ZipEntry ze = zdir.getEntry(subdirectory + file);
   5.100 +        return new ZipFileObject(this, file, ze);
   5.101 +    }
   5.102 +
   5.103 +    public Set<String> getSubdirectories() {
   5.104 +        return map.keySet();
   5.105 +    }
   5.106 +
   5.107 +    public void close() throws IOException {
   5.108 +        zdir.close();
   5.109 +    }
   5.110 +
   5.111 +    protected JavacFileManager fileManager;
   5.112 +    protected final Map<String,List<String>> map;
   5.113 +    protected final ZipFile zdir;
   5.114 +
   5.115 +    /**
   5.116 +     * A subclass of JavaFileObject representing zip entries.
   5.117 +     */
   5.118 +    public static class ZipFileObject extends BaseFileObject {
   5.119 +
   5.120 +        private String name;
   5.121 +        ZipArchive zarch;
   5.122 +        ZipEntry entry;
   5.123 +
   5.124 +        public ZipFileObject(ZipArchive zarch, String name, ZipEntry entry) {
   5.125 +            super(zarch.fileManager);
   5.126 +            this.zarch = zarch;
   5.127 +            this.name = name;
   5.128 +            this.entry = entry;
   5.129 +        }
   5.130 +
   5.131 +        public InputStream openInputStream() throws IOException {
   5.132 +            return zarch.zdir.getInputStream(entry);
   5.133 +        }
   5.134 +
   5.135 +        public OutputStream openOutputStream() throws IOException {
   5.136 +            throw new UnsupportedOperationException();
   5.137 +        }
   5.138 +
   5.139 +        protected CharsetDecoder getDecoder(boolean ignoreEncodingErrors) {
   5.140 +            return fileManager.getDecoder(fileManager.getEncodingName(), ignoreEncodingErrors);
   5.141 +        }
   5.142 +
   5.143 +        public Writer openWriter() throws IOException {
   5.144 +            throw new UnsupportedOperationException();
   5.145 +        }
   5.146 +
   5.147 +        @Deprecated
   5.148 +        public String getName() {
   5.149 +            return name;
   5.150 +        }
   5.151 +
   5.152 +        public boolean isNameCompatible(String cn, JavaFileObject.Kind k) {
   5.153 +            cn.getClass();
   5.154 +            // null check
   5.155 +            if (k == Kind.OTHER && getKind() != k) {
   5.156 +                return false;
   5.157 +            }
   5.158 +            return name.equals(cn + k.extension);
   5.159 +        }
   5.160 +
   5.161 +        @Deprecated
   5.162 +        public String getPath() {
   5.163 +            return zarch.zdir.getName() + "(" + entry + ")";
   5.164 +        }
   5.165 +
   5.166 +        public long getLastModified() {
   5.167 +            return entry.getTime();
   5.168 +        }
   5.169 +
   5.170 +        public boolean delete() {
   5.171 +            throw new UnsupportedOperationException();
   5.172 +        }
   5.173 +
   5.174 +        public CharBuffer getCharContent(boolean ignoreEncodingErrors) throws IOException {
   5.175 +            CharBuffer cb = fileManager.getCachedContent(this);
   5.176 +            if (cb == null) {
   5.177 +                InputStream in = zarch.zdir.getInputStream(entry);
   5.178 +                try {
   5.179 +                    ByteBuffer bb = fileManager.makeByteBuffer(in);
   5.180 +                    JavaFileObject prev = fileManager.log.useSource(this);
   5.181 +                    try {
   5.182 +                        cb = fileManager.decode(bb, ignoreEncodingErrors);
   5.183 +                    } finally {
   5.184 +                        fileManager.log.useSource(prev);
   5.185 +                    }
   5.186 +                    fileManager.recycleByteBuffer(bb);
   5.187 +                    if (!ignoreEncodingErrors) {
   5.188 +                        fileManager.cache(this, cb);
   5.189 +                    }
   5.190 +                } finally {
   5.191 +                    in.close();
   5.192 +                }
   5.193 +            }
   5.194 +            return cb;
   5.195 +        }
   5.196 +
   5.197 +        @Override
   5.198 +        public boolean equals(Object other) {
   5.199 +            if (!(other instanceof ZipFileObject)) {
   5.200 +                return false;
   5.201 +            }
   5.202 +            ZipFileObject o = (ZipFileObject) other;
   5.203 +            return zarch.zdir.equals(o.zarch.zdir) || name.equals(o.name);
   5.204 +        }
   5.205 +
   5.206 +        @Override
   5.207 +        public int hashCode() {
   5.208 +            return zarch.zdir.hashCode() + name.hashCode();
   5.209 +        }
   5.210 +
   5.211 +        public String getZipName() {
   5.212 +            return zarch.zdir.getName();
   5.213 +        }
   5.214 +
   5.215 +        public String getZipEntryName() {
   5.216 +            return entry.getName();
   5.217 +        }
   5.218 +
   5.219 +        public URI toUri() {
   5.220 +            String zipName = new File(getZipName()).toURI().normalize().getPath();
   5.221 +            String entryName = getZipEntryName();
   5.222 +            return URI.create("jar:" + zipName + "!" + entryName);
   5.223 +        }
   5.224 +
   5.225 +        @Override
   5.226 +        protected String inferBinaryName(Iterable<? extends File> path) {
   5.227 +            String entryName = getZipEntryName();
   5.228 +            if (zarch instanceof SymbolArchive) {
   5.229 +                String prefix = ((SymbolArchive) zarch).prefix;
   5.230 +                if (entryName.startsWith(prefix))
   5.231 +                    entryName = entryName.substring(prefix.length());
   5.232 +            }
   5.233 +            return removeExtension(entryName).replace('/', '.');
   5.234 +        }
   5.235 +    }
   5.236 +
   5.237 +}
     6.1 --- a/src/share/classes/com/sun/tools/javac/file/ZipFileIndex.java	Tue Jun 17 10:44:32 2008 -0700
     6.2 +++ b/src/share/classes/com/sun/tools/javac/file/ZipFileIndex.java	Wed Jun 18 07:23:25 2008 -0700
     6.3 @@ -81,11 +81,12 @@
     6.4      private File zipFile;
     6.5      private long zipFileLastModified = NOT_MODIFIED;
     6.6      private RandomAccessFile zipRandomFile;
     6.7 -    private ZipFileIndexEntry[] entries;
     6.8 +    private Entry[] entries;
     6.9  
    6.10      private boolean readFromIndex = false;
    6.11      private File zipIndexFile = null;
    6.12      private boolean triedToReadIndex = false;
    6.13 +    final String symbolFilePrefix;
    6.14      private int symbolFilePrefixLength = 0;
    6.15      private boolean hasPopulatedData = false;
    6.16      private long lastReferenceTimeStamp = NOT_MODIFIED;
    6.17 @@ -141,14 +142,14 @@
    6.18          }
    6.19      }
    6.20  
    6.21 -    public static ZipFileIndex getZipFileIndex(File zipFile, int symbolFilePrefixLen, boolean useCache, String cacheLocation, boolean writeIndex) throws IOException {
    6.22 +    public static ZipFileIndex getZipFileIndex(File zipFile, String symbolFilePrefix, boolean useCache, String cacheLocation, boolean writeIndex) throws IOException {
    6.23          ZipFileIndex zi = null;
    6.24          lock.lock();
    6.25          try {
    6.26              zi = getExistingZipIndex(zipFile);
    6.27  
    6.28              if (zi == null || (zi != null && zipFile.lastModified() != zi.zipFileLastModified)) {
    6.29 -                zi = new ZipFileIndex(zipFile, symbolFilePrefixLen, writeIndex,
    6.30 +                zi = new ZipFileIndex(zipFile, symbolFilePrefix, writeIndex,
    6.31                          useCache, cacheLocation);
    6.32                  zipFileIndexCache.put(zipFile, zi);
    6.33              }
    6.34 @@ -229,10 +230,12 @@
    6.35          }
    6.36      }
    6.37  
    6.38 -    private ZipFileIndex(File zipFile, int symbolFilePrefixLen, boolean writeIndex,
    6.39 +    private ZipFileIndex(File zipFile, String symbolFilePrefix, boolean writeIndex,
    6.40              boolean useCache, String cacheLocation) throws IOException {
    6.41          this.zipFile = zipFile;
    6.42 -        this.symbolFilePrefixLength = symbolFilePrefixLen;
    6.43 +        this.symbolFilePrefix = symbolFilePrefix;
    6.44 +        this.symbolFilePrefixLength = (symbolFilePrefix == null ? 0 :
    6.45 +            symbolFilePrefix.getBytes("UTF-8").length);
    6.46          this.writeIndex = writeIndex;
    6.47          this.usePreindexedCache = useCache;
    6.48          this.preindexedCacheLocation = cacheLocation;
    6.49 @@ -312,7 +315,7 @@
    6.50  
    6.51      private void cleanupState() {
    6.52          // Make sure there is a valid but empty index if the file doesn't exist
    6.53 -        entries = ZipFileIndexEntry.EMPTY_ARRAY;
    6.54 +        entries = Entry.EMPTY_ARRAY;
    6.55          directories = Collections.<String, DirectoryEntry>emptyMap();
    6.56          zipFileLastModified = NOT_MODIFIED;
    6.57          allDirs = Collections.<String>emptySet();
    6.58 @@ -342,7 +345,7 @@
    6.59      /**
    6.60       * Returns the ZipFileIndexEntry for an absolute path, if there is one.
    6.61       */
    6.62 -    public ZipFileIndexEntry getZipIndexEntry(String path) {
    6.63 +    Entry getZipIndexEntry(String path) {
    6.64          if (File.separatorChar != '/') {
    6.65              path = path.replace('/', File.separatorChar);
    6.66          }
    6.67 @@ -493,7 +496,7 @@
    6.68      public long getLastModified(String path) throws IOException {
    6.69          lock.lock();
    6.70          try {
    6.71 -            ZipFileIndexEntry entry = getZipIndexEntry(path);
    6.72 +            Entry entry = getZipIndexEntry(path);
    6.73              if (entry == null)
    6.74                  throw new FileNotFoundException();
    6.75              return entry.getLastModified();
    6.76 @@ -506,7 +509,7 @@
    6.77      public int length(String path) throws IOException {
    6.78          lock.lock();
    6.79          try {
    6.80 -            ZipFileIndexEntry entry = getZipIndexEntry(path);
    6.81 +            Entry entry = getZipIndexEntry(path);
    6.82              if (entry == null)
    6.83                  throw new FileNotFoundException();
    6.84  
    6.85 @@ -530,7 +533,7 @@
    6.86      public byte[] read(String path) throws IOException {
    6.87          lock.lock();
    6.88          try {
    6.89 -            ZipFileIndexEntry entry = getZipIndexEntry(path);
    6.90 +            Entry entry = getZipIndexEntry(path);
    6.91              if (entry == null)
    6.92                  throw new FileNotFoundException(MessageFormat.format("Path not found in ZIP: {0}", path));
    6.93              return read(entry);
    6.94 @@ -540,7 +543,7 @@
    6.95          }
    6.96      }
    6.97  
    6.98 -    public byte[] read(ZipFileIndexEntry entry) throws IOException {
    6.99 +    byte[] read(Entry entry) throws IOException {
   6.100          lock.lock();
   6.101          try {
   6.102              openFile();
   6.103 @@ -556,7 +559,7 @@
   6.104      public int read(String path, byte[] buffer) throws IOException {
   6.105          lock.lock();
   6.106          try {
   6.107 -            ZipFileIndexEntry entry = getZipIndexEntry(path);
   6.108 +            Entry entry = getZipIndexEntry(path);
   6.109              if (entry == null)
   6.110                  throw new FileNotFoundException();
   6.111              return read(entry, buffer);
   6.112 @@ -566,7 +569,7 @@
   6.113          }
   6.114      }
   6.115  
   6.116 -    public int read(ZipFileIndexEntry entry, byte[] buffer)
   6.117 +    int read(Entry entry, byte[] buffer)
   6.118              throws IOException {
   6.119          lock.lock();
   6.120          try {
   6.121 @@ -578,7 +581,7 @@
   6.122          }
   6.123      }
   6.124  
   6.125 -    private byte[] readBytes(ZipFileIndexEntry entry) throws IOException {
   6.126 +    private byte[] readBytes(Entry entry) throws IOException {
   6.127          byte[] header = getHeader(entry);
   6.128          int csize = entry.compressedSize;
   6.129          byte[] cbuf = new byte[csize];
   6.130 @@ -600,7 +603,7 @@
   6.131      /**
   6.132       *
   6.133       */
   6.134 -    private int readBytes(ZipFileIndexEntry entry, byte[] buffer) throws IOException {
   6.135 +    private int readBytes(Entry entry, byte[] buffer) throws IOException {
   6.136          byte[] header = getHeader(entry);
   6.137  
   6.138          // entry is not compressed?
   6.139 @@ -633,7 +636,7 @@
   6.140      // Zip utilities
   6.141      //----------------------------------------------------------------------------
   6.142  
   6.143 -    private byte[] getHeader(ZipFileIndexEntry entry) throws IOException {
   6.144 +    private byte[] getHeader(Entry entry) throws IOException {
   6.145          zipRandomFile.seek(entry.offset);
   6.146          byte[] header = new byte[30];
   6.147          zipRandomFile.readFully(header);
   6.148 @@ -746,11 +749,11 @@
   6.149          private void buildIndex() throws IOException {
   6.150              int entryCount = get2ByteLittleEndian(zipDir, 0);
   6.151  
   6.152 -            entries = new ZipFileIndexEntry[entryCount];
   6.153 +            entries = new Entry[entryCount];
   6.154              // Add each of the files
   6.155              if (entryCount > 0) {
   6.156                  directories = new HashMap<String, DirectoryEntry>();
   6.157 -                ArrayList<ZipFileIndexEntry> entryList = new ArrayList<ZipFileIndexEntry>();
   6.158 +                ArrayList<Entry> entryList = new ArrayList<Entry>();
   6.159                  int pos = 2;
   6.160                  for (int i = 0; i < entryCount; i++) {
   6.161                      pos = readEntry(pos, entryList, directories);
   6.162 @@ -759,19 +762,19 @@
   6.163                  // Add the accumulated dirs into the same list
   6.164                  Iterator i = directories.keySet().iterator();
   6.165                  while (i.hasNext()) {
   6.166 -                    ZipFileIndexEntry zipFileIndexEntry = new ZipFileIndexEntry( (String) i.next());
   6.167 +                    Entry zipFileIndexEntry = new Entry( (String) i.next());
   6.168                      zipFileIndexEntry.isDir = true;
   6.169                      entryList.add(zipFileIndexEntry);
   6.170                  }
   6.171  
   6.172 -                entries = entryList.toArray(new ZipFileIndexEntry[entryList.size()]);
   6.173 +                entries = entryList.toArray(new Entry[entryList.size()]);
   6.174                  Arrays.sort(entries);
   6.175              } else {
   6.176                  cleanupState();
   6.177              }
   6.178          }
   6.179  
   6.180 -        private int readEntry(int pos, List<ZipFileIndexEntry> entryList,
   6.181 +        private int readEntry(int pos, List<Entry> entryList,
   6.182                  Map<String, DirectoryEntry> directories) throws IOException {
   6.183              if (get4ByteLittleEndian(zipDir, pos) != 0x02014b50) {
   6.184                  throw new ZipException("cannot read zip file entry");
   6.185 @@ -838,7 +841,7 @@
   6.186  
   6.187              // For each dir create also a file
   6.188              if (fileStart != fileEnd) {
   6.189 -                ZipFileIndexEntry entry = new ZipFileIndexEntry(directory,
   6.190 +                Entry entry = new Entry(directory,
   6.191                          new String(zipDir, fileStart, fileEnd - fileStart, "UTF-8"));
   6.192  
   6.193                  entry.setNativeTime(get4ByteLittleEndian(zipDir, pos + 12));
   6.194 @@ -873,6 +876,7 @@
   6.195      /** ------------------------------------------------------------------------
   6.196       *  DirectoryEntry class
   6.197       * -------------------------------------------------------------------------*/
   6.198 +
   6.199      static class DirectoryEntry {
   6.200          private boolean filesInited;
   6.201          private boolean directoriesInited;
   6.202 @@ -885,9 +889,9 @@
   6.203  
   6.204          private com.sun.tools.javac.util.List<String> zipFileEntriesFiles = com.sun.tools.javac.util.List.<String>nil();
   6.205          private com.sun.tools.javac.util.List<String> zipFileEntriesDirectories = com.sun.tools.javac.util.List.<String>nil();
   6.206 -        private com.sun.tools.javac.util.List<ZipFileIndexEntry>  zipFileEntries = com.sun.tools.javac.util.List.<ZipFileIndexEntry>nil();
   6.207 +        private com.sun.tools.javac.util.List<Entry>  zipFileEntries = com.sun.tools.javac.util.List.<Entry>nil();
   6.208  
   6.209 -        private List<ZipFileIndexEntry> entries = new ArrayList<ZipFileIndexEntry>();
   6.210 +        private List<Entry> entries = new ArrayList<Entry>();
   6.211  
   6.212          private ZipFileIndex zipFileIndex;
   6.213  
   6.214 @@ -916,7 +920,7 @@
   6.215  
   6.216              initEntries();
   6.217  
   6.218 -            for (ZipFileIndexEntry e : entries) {
   6.219 +            for (Entry e : entries) {
   6.220                  if (!e.isDir) {
   6.221                      zipFileEntriesFiles = zipFileEntriesFiles.append(e.name);
   6.222                  }
   6.223 @@ -932,7 +936,7 @@
   6.224  
   6.225              initEntries();
   6.226  
   6.227 -            for (ZipFileIndexEntry e : entries) {
   6.228 +            for (Entry e : entries) {
   6.229                  if (e.isDir) {
   6.230                      zipFileEntriesDirectories = zipFileEntriesDirectories.append(e.name);
   6.231                  }
   6.232 @@ -943,7 +947,7 @@
   6.233              return zipFileEntriesDirectories;
   6.234          }
   6.235  
   6.236 -        private com.sun.tools.javac.util.List<ZipFileIndexEntry> getEntries() {
   6.237 +        private com.sun.tools.javac.util.List<Entry> getEntries() {
   6.238              if (zipFileEntriesInited) {
   6.239                  return zipFileEntries;
   6.240              }
   6.241 @@ -951,7 +955,7 @@
   6.242              initEntries();
   6.243  
   6.244              zipFileEntries = com.sun.tools.javac.util.List.nil();
   6.245 -            for (ZipFileIndexEntry zfie : entries) {
   6.246 +            for (Entry zfie : entries) {
   6.247                  zipFileEntries = zipFileEntries.append(zfie);
   6.248              }
   6.249  
   6.250 @@ -960,9 +964,9 @@
   6.251              return zipFileEntries;
   6.252          }
   6.253  
   6.254 -        private ZipFileIndexEntry getEntry(String rootName) {
   6.255 +        private Entry getEntry(String rootName) {
   6.256              initEntries();
   6.257 -            int index = Collections.binarySearch(entries, new ZipFileIndexEntry(dirName, rootName));
   6.258 +            int index = Collections.binarySearch(entries, new Entry(dirName, rootName));
   6.259              if (index < 0) {
   6.260                  return null;
   6.261              }
   6.262 @@ -977,9 +981,9 @@
   6.263  
   6.264              if (!zipFileIndex.readFromIndex) {
   6.265                  int from = -Arrays.binarySearch(zipFileIndex.entries,
   6.266 -                        new ZipFileIndexEntry(dirName, ZipFileIndex.MIN_CHAR)) - 1;
   6.267 +                        new Entry(dirName, ZipFileIndex.MIN_CHAR)) - 1;
   6.268                  int to = -Arrays.binarySearch(zipFileIndex.entries,
   6.269 -                        new ZipFileIndexEntry(dirName, MAX_CHAR)) - 1;
   6.270 +                        new Entry(dirName, MAX_CHAR)) - 1;
   6.271  
   6.272                  boolean emptyList = false;
   6.273  
   6.274 @@ -1016,7 +1020,7 @@
   6.275                              // Read java time stamp of the file in the real Jar/Zip file
   6.276                              long eJavaTimestamp = raf.readLong();
   6.277  
   6.278 -                            ZipFileIndexEntry rfie = new ZipFileIndexEntry(dirName, eName);
   6.279 +                            Entry rfie = new Entry(dirName, eName);
   6.280                              rfie.isDir = eIsDir;
   6.281                              rfie.offset = eOffset;
   6.282                              rfie.size = eSize;
   6.283 @@ -1041,7 +1045,7 @@
   6.284              entriesInited = true;
   6.285          }
   6.286  
   6.287 -        List<ZipFileIndexEntry> getEntriesAsCollection() {
   6.288 +        List<Entry> getEntriesAsCollection() {
   6.289              initEntries();
   6.290  
   6.291              return entries;
   6.292 @@ -1173,8 +1177,8 @@
   6.293                  raf.seek(currFP);
   6.294  
   6.295                  // Now write each of the files in the DirectoryEntry
   6.296 -                List<ZipFileIndexEntry> entries = de.getEntriesAsCollection();
   6.297 -                for (ZipFileIndexEntry zfie : entries) {
   6.298 +                List<Entry> entries = de.getEntriesAsCollection();
   6.299 +                for (Entry zfie : entries) {
   6.300                      // Write the name bytes
   6.301                      byte [] zfieNameBytes = zfie.name.getBytes("UTF-8");
   6.302                      int zfieNameBytesLen = zfieNameBytes.length;
   6.303 @@ -1245,4 +1249,94 @@
   6.304      public File getZipFile() {
   6.305          return zipFile;
   6.306      }
   6.307 +
   6.308 +
   6.309 +    static class Entry implements Comparable<Entry> {
   6.310 +        public static final Entry[] EMPTY_ARRAY = {};
   6.311 +
   6.312 +        // Directory related
   6.313 +        String dir;
   6.314 +        boolean isDir;
   6.315 +
   6.316 +        // File related
   6.317 +        String name;
   6.318 +
   6.319 +        int offset;
   6.320 +        int size;
   6.321 +        int compressedSize;
   6.322 +        long javatime;
   6.323 +
   6.324 +        private int nativetime;
   6.325 +
   6.326 +        public Entry(String path) {
   6.327 +            int separator = path.lastIndexOf(File.separatorChar);
   6.328 +            if (separator == -1) {
   6.329 +                dir = "".intern();
   6.330 +                name = path;
   6.331 +            } else {
   6.332 +                dir = path.substring(0, separator).intern();
   6.333 +                name = path.substring(separator + 1);
   6.334 +            }
   6.335 +        }
   6.336 +
   6.337 +        public Entry(String directory, String name) {
   6.338 +            this.dir = directory.intern();
   6.339 +            this.name = name;
   6.340 +        }
   6.341 +
   6.342 +        public String getName() {
   6.343 +            if (dir == null || dir.length() == 0) {
   6.344 +                return name;
   6.345 +            }
   6.346 +
   6.347 +            StringBuilder sb = new StringBuilder();
   6.348 +            sb.append(dir);
   6.349 +            sb.append(File.separatorChar);
   6.350 +            sb.append(name);
   6.351 +            return sb.toString();
   6.352 +        }
   6.353 +
   6.354 +        public String getFileName() {
   6.355 +            return name;
   6.356 +        }
   6.357 +
   6.358 +        public long getLastModified() {
   6.359 +            if (javatime == 0) {
   6.360 +                    javatime = dosToJavaTime(nativetime);
   6.361 +            }
   6.362 +            return javatime;
   6.363 +        }
   6.364 +
   6.365 +        // From java.util.zip
   6.366 +        private static long dosToJavaTime(int nativetime) {
   6.367 +            // Bootstrap build problems prevent me from using the code directly
   6.368 +            // Convert the raw/native time to a long for now
   6.369 +            return (long)nativetime;
   6.370 +        }
   6.371 +
   6.372 +        void setNativeTime(int natTime) {
   6.373 +            nativetime = natTime;
   6.374 +        }
   6.375 +
   6.376 +        public boolean isDirectory() {
   6.377 +            return isDir;
   6.378 +        }
   6.379 +
   6.380 +        public int compareTo(Entry other) {
   6.381 +            String otherD = other.dir;
   6.382 +            if (dir != otherD) {
   6.383 +                int c = dir.compareTo(otherD);
   6.384 +                if (c != 0)
   6.385 +                    return c;
   6.386 +            }
   6.387 +            return name.compareTo(other.name);
   6.388 +        }
   6.389 +
   6.390 +
   6.391 +        public String toString() {
   6.392 +            return isDir ? ("Dir:" + dir + " : " + name) :
   6.393 +                (dir + ":" + name);
   6.394 +        }
   6.395 +    }
   6.396 +
   6.397  }
     7.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.2 +++ b/src/share/classes/com/sun/tools/javac/file/ZipFileIndexArchive.java	Wed Jun 18 07:23:25 2008 -0700
     7.3 @@ -0,0 +1,233 @@
     7.4 +/*
     7.5 + * Copyright 2005-2008 Sun Microsystems, Inc.  All Rights Reserved.
     7.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     7.7 + *
     7.8 + * This code is free software; you can redistribute it and/or modify it
     7.9 + * under the terms of the GNU General Public License version 2 only, as
    7.10 + * published by the Free Software Foundation.  Sun designates this
    7.11 + * particular file as subject to the "Classpath" exception as provided
    7.12 + * by Sun in the LICENSE file that accompanied this code.
    7.13 + *
    7.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
    7.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    7.16 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    7.17 + * version 2 for more details (a copy is included in the LICENSE file that
    7.18 + * accompanied this code).
    7.19 + *
    7.20 + * You should have received a copy of the GNU General Public License version
    7.21 + * 2 along with this work; if not, write to the Free Software Foundation,
    7.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    7.23 + *
    7.24 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
    7.25 + * CA 95054 USA or visit www.sun.com if you need additional information or
    7.26 + * have any questions.
    7.27 + */
    7.28 +
    7.29 +package com.sun.tools.javac.file;
    7.30 +
    7.31 +import java.io.IOException;
    7.32 +import java.util.Set;
    7.33 +import javax.tools.JavaFileObject;
    7.34 +
    7.35 +import com.sun.tools.javac.file.JavacFileManager.Archive;
    7.36 +import com.sun.tools.javac.util.List;
    7.37 +import java.io.ByteArrayInputStream;
    7.38 +import java.io.File;
    7.39 +import java.io.FileNotFoundException;
    7.40 +import java.io.InputStream;
    7.41 +import java.io.OutputStream;
    7.42 +import java.io.Writer;
    7.43 +import java.net.URI;
    7.44 +import java.nio.ByteBuffer;
    7.45 +import java.nio.CharBuffer;
    7.46 +import java.nio.charset.CharsetDecoder;
    7.47 +
    7.48 +public class ZipFileIndexArchive implements Archive {
    7.49 +
    7.50 +    private final ZipFileIndex zfIndex;
    7.51 +    private JavacFileManager fileManager;
    7.52 +
    7.53 +    public ZipFileIndexArchive(JavacFileManager fileManager, ZipFileIndex zdir) throws IOException {
    7.54 +        super();
    7.55 +        this.fileManager = fileManager;
    7.56 +        this.zfIndex = zdir;
    7.57 +    }
    7.58 +
    7.59 +    public boolean contains(String name) {
    7.60 +        return zfIndex.contains(name);
    7.61 +    }
    7.62 +
    7.63 +    public List<String> getFiles(String subdirectory) {
    7.64 +        return zfIndex.getFiles((subdirectory.endsWith("/") || subdirectory.endsWith("\\")) ? subdirectory.substring(0, subdirectory.length() - 1) : subdirectory);
    7.65 +    }
    7.66 +
    7.67 +    public JavaFileObject getFileObject(String subdirectory, String file) {
    7.68 +        String fullZipFileName = subdirectory + file;
    7.69 +        ZipFileIndex.Entry entry = zfIndex.getZipIndexEntry(fullZipFileName);
    7.70 +        JavaFileObject ret = new ZipFileIndexFileObject(fileManager, zfIndex, entry, zfIndex.getZipFile().getPath());
    7.71 +        return ret;
    7.72 +    }
    7.73 +
    7.74 +    public Set<String> getSubdirectories() {
    7.75 +        return zfIndex.getAllDirectories();
    7.76 +    }
    7.77 +
    7.78 +    public void close() throws IOException {
    7.79 +        zfIndex.close();
    7.80 +    }
    7.81 +
    7.82 +    /**
    7.83 +     * A subclass of JavaFileObject representing zip entries using the com.sun.tools.javac.file.ZipFileIndex implementation.
    7.84 +     */
    7.85 +    public static class ZipFileIndexFileObject extends BaseFileObject {
    7.86 +
    7.87 +        /** The entry's name.
    7.88 +         */
    7.89 +        private String name;
    7.90 +
    7.91 +        /** The zipfile containing the entry.
    7.92 +         */
    7.93 +        ZipFileIndex zfIndex;
    7.94 +
    7.95 +        /** The underlying zip entry object.
    7.96 +         */
    7.97 +        ZipFileIndex.Entry entry;
    7.98 +
    7.99 +        /** The InputStream for this zip entry (file.)
   7.100 +         */
   7.101 +        InputStream inputStream = null;
   7.102 +
   7.103 +        /** The name of the zip file where this entry resides.
   7.104 +         */
   7.105 +        String zipName;
   7.106 +
   7.107 +
   7.108 +        ZipFileIndexFileObject(JavacFileManager fileManager, ZipFileIndex zfIndex, ZipFileIndex.Entry entry, String zipFileName) {
   7.109 +            super(fileManager);
   7.110 +            this.name = entry.getFileName();
   7.111 +            this.zfIndex = zfIndex;
   7.112 +            this.entry = entry;
   7.113 +            this.zipName = zipFileName;
   7.114 +        }
   7.115 +
   7.116 +        public InputStream openInputStream() throws IOException {
   7.117 +
   7.118 +            if (inputStream == null) {
   7.119 +                inputStream = new ByteArrayInputStream(read());
   7.120 +            }
   7.121 +            return inputStream;
   7.122 +        }
   7.123 +
   7.124 +        protected CharsetDecoder getDecoder(boolean ignoreEncodingErrors) {
   7.125 +            return fileManager.getDecoder(fileManager.getEncodingName(), ignoreEncodingErrors);
   7.126 +        }
   7.127 +
   7.128 +        public OutputStream openOutputStream() throws IOException {
   7.129 +            throw new UnsupportedOperationException();
   7.130 +        }
   7.131 +
   7.132 +        public Writer openWriter() throws IOException {
   7.133 +            throw new UnsupportedOperationException();
   7.134 +        }
   7.135 +
   7.136 +        /** @deprecated see bug 6410637 */
   7.137 +        @Deprecated
   7.138 +        public String getName() {
   7.139 +            return name;
   7.140 +        }
   7.141 +
   7.142 +        public boolean isNameCompatible(String cn, JavaFileObject.Kind k) {
   7.143 +            cn.getClass(); // null check
   7.144 +            if (k == Kind.OTHER && getKind() != k)
   7.145 +                return false;
   7.146 +            return name.equals(cn + k.extension);
   7.147 +        }
   7.148 +
   7.149 +        /** @deprecated see bug 6410637 */
   7.150 +        @Deprecated
   7.151 +        public String getPath() {
   7.152 +            return zipName + "(" + entry.getName() + ")";
   7.153 +        }
   7.154 +
   7.155 +        public long getLastModified() {
   7.156 +            return entry.getLastModified();
   7.157 +        }
   7.158 +
   7.159 +        public boolean delete() {
   7.160 +            throw new UnsupportedOperationException();
   7.161 +        }
   7.162 +
   7.163 +        @Override
   7.164 +        public boolean equals(Object other) {
   7.165 +            if (!(other instanceof ZipFileIndexFileObject))
   7.166 +                return false;
   7.167 +            ZipFileIndexFileObject o = (ZipFileIndexFileObject) other;
   7.168 +            return entry.equals(o.entry);
   7.169 +        }
   7.170 +
   7.171 +        @Override
   7.172 +        public int hashCode() {
   7.173 +            return zipName.hashCode() + (name.hashCode() << 10);
   7.174 +        }
   7.175 +
   7.176 +        public String getZipName() {
   7.177 +            return zipName;
   7.178 +        }
   7.179 +
   7.180 +        public String getZipEntryName() {
   7.181 +            return entry.getName();
   7.182 +        }
   7.183 +
   7.184 +        public URI toUri() {
   7.185 +            String zipName = new File(getZipName()).toURI().normalize().getPath();
   7.186 +            String entryName = getZipEntryName();
   7.187 +            if (File.separatorChar != '/') {
   7.188 +                entryName = entryName.replace(File.separatorChar, '/');
   7.189 +            }
   7.190 +            return URI.create("jar:" + zipName + "!" + entryName);
   7.191 +        }
   7.192 +
   7.193 +        private byte[] read() throws IOException {
   7.194 +            if (entry == null) {
   7.195 +                entry = zfIndex.getZipIndexEntry(name);
   7.196 +                if (entry == null)
   7.197 +                  throw new FileNotFoundException();
   7.198 +            }
   7.199 +            return zfIndex.read(entry);
   7.200 +        }
   7.201 +
   7.202 +        public CharBuffer getCharContent(boolean ignoreEncodingErrors) throws IOException {
   7.203 +            CharBuffer cb = fileManager.getCachedContent(this);
   7.204 +            if (cb == null) {
   7.205 +                InputStream in = new ByteArrayInputStream(zfIndex.read(entry));
   7.206 +                try {
   7.207 +                    ByteBuffer bb = fileManager.makeByteBuffer(in);
   7.208 +                    JavaFileObject prev = fileManager.log.useSource(this);
   7.209 +                    try {
   7.210 +                        cb = fileManager.decode(bb, ignoreEncodingErrors);
   7.211 +                    } finally {
   7.212 +                        fileManager.log.useSource(prev);
   7.213 +                    }
   7.214 +                    fileManager.recycleByteBuffer(bb); // save for next time
   7.215 +                    if (!ignoreEncodingErrors)
   7.216 +                        fileManager.cache(this, cb);
   7.217 +                } finally {
   7.218 +                    in.close();
   7.219 +                }
   7.220 +            }
   7.221 +            return cb;
   7.222 +        }
   7.223 +
   7.224 +        @Override
   7.225 +        protected String inferBinaryName(Iterable<? extends File> path) {
   7.226 +            String entryName = getZipEntryName();
   7.227 +            if (zfIndex.symbolFilePrefix != null) {
   7.228 +                String prefix = zfIndex.symbolFilePrefix;
   7.229 +                if (entryName.startsWith(prefix))
   7.230 +                    entryName = entryName.substring(prefix.length());
   7.231 +            }
   7.232 +            return removeExtension(entryName).replace(File.separatorChar, '.');
   7.233 +        }
   7.234 +    }
   7.235 +
   7.236 +}
     8.1 --- a/src/share/classes/com/sun/tools/javac/file/ZipFileIndexEntry.java	Tue Jun 17 10:44:32 2008 -0700
     8.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     8.3 @@ -1,116 +0,0 @@
     8.4 -/*
     8.5 - * Copyright 2007-2008 Sun Microsystems, Inc.  All Rights Reserved.
     8.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     8.7 - *
     8.8 - * This code is free software; you can redistribute it and/or modify it
     8.9 - * under the terms of the GNU General Public License version 2 only, as
    8.10 - * published by the Free Software Foundation.  Sun designates this
    8.11 - * particular file as subject to the "Classpath" exception as provided
    8.12 - * by Sun in the LICENSE file that accompanied this code.
    8.13 - *
    8.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
    8.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    8.16 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    8.17 - * version 2 for more details (a copy is included in the LICENSE file that
    8.18 - * accompanied this code).
    8.19 - *
    8.20 - * You should have received a copy of the GNU General Public License version
    8.21 - * 2 along with this work; if not, write to the Free Software Foundation,
    8.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    8.23 - *
    8.24 - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
    8.25 - * CA 95054 USA or visit www.sun.com if you need additional information or
    8.26 - * have any questions.
    8.27 - */
    8.28 -
    8.29 -package com.sun.tools.javac.file;
    8.30 -
    8.31 -import java.io.File;
    8.32 -
    8.33 -public final class ZipFileIndexEntry implements Comparable<ZipFileIndexEntry> {
    8.34 -    public static final ZipFileIndexEntry[] EMPTY_ARRAY = {};
    8.35 -
    8.36 -    // Directory related
    8.37 -    String dir;
    8.38 -    boolean isDir;
    8.39 -
    8.40 -    // File related
    8.41 -    String name;
    8.42 -
    8.43 -    int offset;
    8.44 -    int size;
    8.45 -    int compressedSize;
    8.46 -    long javatime;
    8.47 -
    8.48 -    private int nativetime;
    8.49 -
    8.50 -    public ZipFileIndexEntry(String path) {
    8.51 -        int separator = path.lastIndexOf(File.separatorChar);
    8.52 -        if (separator == -1) {
    8.53 -            dir = "".intern();
    8.54 -            name = path;
    8.55 -        } else {
    8.56 -            dir = path.substring(0, separator).intern();
    8.57 -            name = path.substring(separator + 1);
    8.58 -        }
    8.59 -    }
    8.60 -
    8.61 -    public ZipFileIndexEntry(String directory, String name) {
    8.62 -        this.dir = directory.intern();
    8.63 -        this.name = name;
    8.64 -    }
    8.65 -
    8.66 -    public String getName() {
    8.67 -        if (dir == null || dir.length() == 0) {
    8.68 -            return name;
    8.69 -        }
    8.70 -
    8.71 -        StringBuilder sb = new StringBuilder();
    8.72 -        sb.append(dir);
    8.73 -        sb.append(File.separatorChar);
    8.74 -        sb.append(name);
    8.75 -        return sb.toString();
    8.76 -    }
    8.77 -
    8.78 -    public String getFileName() {
    8.79 -        return name;
    8.80 -    }
    8.81 -
    8.82 -    public long getLastModified() {
    8.83 -        if (javatime == 0) {
    8.84 -                javatime = dosToJavaTime(nativetime);
    8.85 -        }
    8.86 -        return javatime;
    8.87 -    }
    8.88 -
    8.89 -    // From java.util.zip
    8.90 -    private static long dosToJavaTime(int nativetime) {
    8.91 -        // Bootstrap build problems prevent me from using the code directly
    8.92 -        // Convert the raw/native time to a long for now
    8.93 -        return (long)nativetime;
    8.94 -    }
    8.95 -
    8.96 -    void setNativeTime(int natTime) {
    8.97 -        nativetime = natTime;
    8.98 -    }
    8.99 -
   8.100 -    public boolean isDirectory() {
   8.101 -        return isDir;
   8.102 -    }
   8.103 -
   8.104 -    public int compareTo(ZipFileIndexEntry other) {
   8.105 -        String otherD = other.dir;
   8.106 -        if (dir != otherD) {
   8.107 -            int c = dir.compareTo(otherD);
   8.108 -            if (c != 0)
   8.109 -                return c;
   8.110 -        }
   8.111 -        return name.compareTo(other.name);
   8.112 -    }
   8.113 -
   8.114 -
   8.115 -    public String toString() {
   8.116 -        return isDir ? ("Dir:" + dir + " : " + name) :
   8.117 -            (dir + ":" + name);
   8.118 -    }
   8.119 -}
     9.1 --- a/src/share/classes/com/sun/tools/javac/jvm/ClassReader.java	Tue Jun 17 10:44:32 2008 -0700
     9.2 +++ b/src/share/classes/com/sun/tools/javac/jvm/ClassReader.java	Wed Jun 18 07:23:25 2008 -0700
     9.3 @@ -1056,7 +1056,7 @@
     9.4      void readClassAttr(ClassSymbol c, Name attrName, int attrLen) {
     9.5          if (attrName == names.SourceFile) {
     9.6              Name n = readName(nextChar());
     9.7 -            c.sourcefile = new SourceFileObject(n);
     9.8 +            c.sourcefile = new SourceFileObject(n, c.flatname);
     9.9          } else if (attrName == names.InnerClasses) {
    9.10              readInnerClasses(c);
    9.11          } else if (allowGenerics && attrName == names.Signature) {
    9.12 @@ -2221,9 +2221,12 @@
    9.13          /** The file's name.
    9.14           */
    9.15          private Name name;
    9.16 +        private Name flatname;
    9.17  
    9.18 -        public SourceFileObject(Name name) {
    9.19 +        public SourceFileObject(Name name, Name flatname) {
    9.20 +            super(null); // no file manager; never referenced for this file object
    9.21              this.name = name;
    9.22 +            this.flatname = flatname;
    9.23          }
    9.24  
    9.25          public InputStream openInputStream() {
    9.26 @@ -2285,5 +2288,9 @@
    9.27              throw new UnsupportedOperationException();
    9.28          }
    9.29  
    9.30 +        @Override
    9.31 +        protected String inferBinaryName(Iterable<? extends File> path) {
    9.32 +            return flatname.toString();
    9.33 +        }
    9.34      }
    9.35  }
    10.1 --- a/src/share/classes/com/sun/tools/javadoc/JavadocClassReader.java	Tue Jun 17 10:44:32 2008 -0700
    10.2 +++ b/src/share/classes/com/sun/tools/javadoc/JavadocClassReader.java	Wed Jun 18 07:23:25 2008 -0700
    10.3 @@ -27,7 +27,9 @@
    10.4  
    10.5  import com.sun.tools.javac.code.Symbol.PackageSymbol;
    10.6  import com.sun.tools.javac.file.JavacFileManager;
    10.7 +import com.sun.tools.javac.file.ZipArchive.ZipFileObject;
    10.8  import com.sun.tools.javac.file.Old199;
    10.9 +import com.sun.tools.javac.file.ZipFileIndexArchive;
   10.10  import com.sun.tools.javac.jvm.ClassReader;
   10.11  import com.sun.tools.javac.util.Context;
   10.12  
   10.13 @@ -82,16 +84,16 @@
   10.14      protected void extraFileActions(PackageSymbol pack, JavaFileObject fo) {
   10.15          CharSequence fileName = Old199.getName(fo);
   10.16          if (docenv != null && fileName.equals("package.html")) {
   10.17 -            if (fo instanceof JavacFileManager.ZipFileObject) {
   10.18 -                JavacFileManager.ZipFileObject zfo = (JavacFileManager.ZipFileObject) fo;
   10.19 +            if (fo instanceof ZipFileObject) {
   10.20 +                ZipFileObject zfo = (ZipFileObject) fo;
   10.21                  String zipName = zfo.getZipName();
   10.22                  String entryName = zfo.getZipEntryName();
   10.23                  int lastSep = entryName.lastIndexOf("/");
   10.24                  String classPathName = entryName.substring(0, lastSep + 1);
   10.25                  docenv.getPackageDoc(pack).setDocPath(zipName, classPathName);
   10.26              }
   10.27 -            else if (fo instanceof JavacFileManager.ZipFileIndexFileObject) {
   10.28 -                JavacFileManager.ZipFileIndexFileObject zfo = (JavacFileManager.ZipFileIndexFileObject) fo;
   10.29 +            else if (fo instanceof ZipFileIndexArchive.ZipFileIndexFileObject) {
   10.30 +                ZipFileIndexArchive.ZipFileIndexFileObject zfo = (ZipFileIndexArchive.ZipFileIndexFileObject) fo;
   10.31                  String zipName = zfo.getZipName();
   10.32                  String entryName = zfo.getZipEntryName();
   10.33                  if (File.separatorChar != '/') {

mercurial