Merge

Wed, 25 Jun 2008 23:30:55 -0700

author
tbell
date
Wed, 25 Jun 2008 23:30:55 -0700
changeset 61
a0de486e86a1
parent 53
0c66311205c2
parent 60
29d2485c1085
child 62
07c916ecfc71

Merge

src/share/classes/com/sun/tools/javac/file/ZipFileIndexEntry.java file | annotate | diff | comparison | revisions
     1.1 --- a/src/share/classes/com/sun/tools/javac/comp/Check.java	Fri Jun 20 16:36:18 2008 -0700
     1.2 +++ b/src/share/classes/com/sun/tools/javac/comp/Check.java	Wed Jun 25 23:30:55 2008 -0700
     1.3 @@ -100,9 +100,12 @@
     1.4  
     1.5          boolean verboseDeprecated = lint.isEnabled(LintCategory.DEPRECATION);
     1.6          boolean verboseUnchecked = lint.isEnabled(LintCategory.UNCHECKED);
     1.7 +        boolean enforceMandatoryWarnings = source.enforceMandatoryWarnings();
     1.8  
     1.9 -        deprecationHandler = new MandatoryWarningHandler(log,verboseDeprecated, "deprecated");
    1.10 -        uncheckedHandler = new MandatoryWarningHandler(log, verboseUnchecked, "unchecked");
    1.11 +        deprecationHandler = new MandatoryWarningHandler(log, verboseDeprecated,
    1.12 +                enforceMandatoryWarnings, "deprecated");
    1.13 +        uncheckedHandler = new MandatoryWarningHandler(log, verboseUnchecked,
    1.14 +                enforceMandatoryWarnings, "unchecked");
    1.15      }
    1.16  
    1.17      /** Switch: generics enabled?
    1.18 @@ -1367,13 +1370,47 @@
    1.19                          types.isSameType(rt1, rt2) ||
    1.20                          rt1.tag >= CLASS && rt2.tag >= CLASS &&
    1.21                          (types.covariantReturnType(rt1, rt2, Warner.noWarnings) ||
    1.22 -                         types.covariantReturnType(rt2, rt1, Warner.noWarnings));
    1.23 +                         types.covariantReturnType(rt2, rt1, Warner.noWarnings)) ||
    1.24 +                         checkCommonOverriderIn(s1,s2,site);
    1.25                      if (!compat) return s2;
    1.26                  }
    1.27              }
    1.28          }
    1.29          return null;
    1.30      }
    1.31 +    //WHERE
    1.32 +    boolean checkCommonOverriderIn(Symbol s1, Symbol s2, Type site) {
    1.33 +        Map<TypeSymbol,Type> supertypes = new HashMap<TypeSymbol,Type>();
    1.34 +        Type st1 = types.memberType(site, s1);
    1.35 +        Type st2 = types.memberType(site, s2);
    1.36 +        closure(site, supertypes);
    1.37 +        for (Type t : supertypes.values()) {
    1.38 +            for (Scope.Entry e = t.tsym.members().lookup(s1.name); e.scope != null; e = e.next()) {
    1.39 +                Symbol s3 = e.sym;
    1.40 +                if (s3 == s1 || s3 == s2 || s3.kind != MTH || (s3.flags() & (BRIDGE|SYNTHETIC)) != 0) continue;
    1.41 +                Type st3 = types.memberType(site,s3);
    1.42 +                if (types.overrideEquivalent(st3, st1) && types.overrideEquivalent(st3, st2)) {
    1.43 +                    if (s3.owner == site.tsym) {
    1.44 +                        return true;
    1.45 +                    }
    1.46 +                    List<Type> tvars1 = st1.getTypeArguments();
    1.47 +                    List<Type> tvars2 = st2.getTypeArguments();
    1.48 +                    List<Type> tvars3 = st3.getTypeArguments();
    1.49 +                    Type rt1 = st1.getReturnType();
    1.50 +                    Type rt2 = st2.getReturnType();
    1.51 +                    Type rt13 = types.subst(st3.getReturnType(), tvars3, tvars1);
    1.52 +                    Type rt23 = types.subst(st3.getReturnType(), tvars3, tvars2);
    1.53 +                    boolean compat =
    1.54 +                        rt13.tag >= CLASS && rt23.tag >= CLASS &&
    1.55 +                        (types.covariantReturnType(rt13, rt1, Warner.noWarnings) &&
    1.56 +                         types.covariantReturnType(rt23, rt2, Warner.noWarnings));
    1.57 +                    if (compat)
    1.58 +                        return true;
    1.59 +                }
    1.60 +            }
    1.61 +        }
    1.62 +        return false;
    1.63 +    }
    1.64  
    1.65      /** Check that a given method conforms with any method it overrides.
    1.66       *  @param tree         The tree from which positions are extracted
     2.1 --- a/src/share/classes/com/sun/tools/javac/file/BaseFileObject.java	Fri Jun 20 16:36:18 2008 -0700
     2.2 +++ b/src/share/classes/com/sun/tools/javac/file/BaseFileObject.java	Wed Jun 25 23:30:55 2008 -0700
     2.3 @@ -25,6 +25,7 @@
     2.4  
     2.5  package com.sun.tools.javac.file;
     2.6  
     2.7 +import java.io.File;
     2.8  import java.io.IOException;
     2.9  import java.io.InputStreamReader;
    2.10  import java.io.Reader;
    2.11 @@ -36,6 +37,9 @@
    2.12  import static javax.tools.JavaFileObject.Kind.*;
    2.13  
    2.14  public abstract class BaseFileObject implements JavaFileObject {
    2.15 +    protected BaseFileObject(JavacFileManager fileManager) {
    2.16 +        this.fileManager = fileManager;
    2.17 +    }
    2.18  
    2.19      public JavaFileObject.Kind getKind() {
    2.20          String n = getName();
    2.21 @@ -76,4 +80,14 @@
    2.22          throw new UnsupportedOperationException();
    2.23      }
    2.24  
    2.25 +    protected abstract String inferBinaryName(Iterable<? extends File> path);
    2.26 +
    2.27 +    protected static String removeExtension(String fileName) {
    2.28 +        int lastDot = fileName.lastIndexOf(".");
    2.29 +        return (lastDot == -1 ? fileName : fileName.substring(0, lastDot));
    2.30 +    }
    2.31 +
    2.32 +    /** The file manager that created this JavaFileObject. */
    2.33 +    protected final JavacFileManager fileManager;
    2.34 +
    2.35  }
     3.1 --- a/src/share/classes/com/sun/tools/javac/file/JavacFileManager.java	Fri Jun 20 16:36:18 2008 -0700
     3.2 +++ b/src/share/classes/com/sun/tools/javac/file/JavacFileManager.java	Wed Jun 25 23:30:55 2008 -0700
     3.3 @@ -1,5 +1,5 @@
     3.4  /*
     3.5 - * Copyright 2005-2006 Sun Microsystems, Inc.  All Rights Reserved.
     3.6 + * Copyright 2005-2008 Sun Microsystems, Inc.  All Rights Reserved.
     3.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3.8   *
     3.9   * This code is free software; you can redistribute it and/or modify it
    3.10 @@ -25,21 +25,16 @@
    3.11  
    3.12  package com.sun.tools.javac.file;
    3.13  
    3.14 -import java.io.ByteArrayInputStream;
    3.15  import java.io.ByteArrayOutputStream;
    3.16  import java.io.File;
    3.17  import java.io.FileInputStream;
    3.18  import java.io.FileNotFoundException;
    3.19 -import java.io.FileOutputStream;
    3.20  import java.io.IOException;
    3.21  import java.io.InputStream;
    3.22 -import java.io.OutputStream;
    3.23  import java.io.OutputStreamWriter;
    3.24 -import java.io.Writer;
    3.25  import java.lang.ref.SoftReference;
    3.26  import java.net.MalformedURLException;
    3.27  import java.net.URI;
    3.28 -import java.net.URISyntaxException;
    3.29  import java.net.URL;
    3.30  import java.net.URLClassLoader;
    3.31  import java.nio.ByteBuffer;
    3.32 @@ -56,13 +51,11 @@
    3.33  import java.util.Collection;
    3.34  import java.util.Collections;
    3.35  import java.util.EnumSet;
    3.36 -import java.util.Enumeration;
    3.37  import java.util.HashMap;
    3.38  import java.util.Iterator;
    3.39  import java.util.Map;
    3.40  import java.util.Set;
    3.41  import java.util.concurrent.ConcurrentHashMap;
    3.42 -import java.util.zip.ZipEntry;
    3.43  import java.util.zip.ZipFile;
    3.44  
    3.45  import javax.lang.model.SourceVersion;
    3.46 @@ -96,15 +89,6 @@
    3.47  
    3.48      boolean useZipFileIndex;
    3.49  
    3.50 -    private static int symbolFilePrefixLength = 0;
    3.51 -    static {
    3.52 -        try {
    3.53 -            symbolFilePrefixLength = symbolFilePrefix.getBytes("UTF-8").length;
    3.54 -        } catch (java.io.UnsupportedEncodingException uee) {
    3.55 -            // Can't happen...UTF-8 is always supported.
    3.56 -        }
    3.57 -    }
    3.58 -
    3.59      private static boolean CHECK_ZIP_TIMESTAMP = false;
    3.60      private static Map<File, Boolean> isDirectory = new ConcurrentHashMap<File, Boolean>();
    3.61  
    3.62 @@ -202,7 +186,7 @@
    3.63      }
    3.64  
    3.65      public JavaFileObject getRegularFile(File file) {
    3.66 -        return new RegularFileObject(file);
    3.67 +        return new RegularFileObject(this, file);
    3.68      }
    3.69  
    3.70      public JavaFileObject getFileForOutput(String classname,
    3.71 @@ -405,7 +389,7 @@
    3.72                  } else {
    3.73                      if (isValidFile(fname, fileKinds)) {
    3.74                          JavaFileObject fe =
    3.75 -                        new RegularFileObject(fname, new File(d, fname));
    3.76 +                            new RegularFileObject(this, fname, new File(d, fname));
    3.77                          l.append(fe);
    3.78                      }
    3.79                  }
    3.80 @@ -469,106 +453,13 @@
    3.81          Set<String> getSubdirectories();
    3.82      }
    3.83  
    3.84 -    public class ZipArchive implements Archive {
    3.85 -        protected final Map<String,List<String>> map;
    3.86 -        protected final ZipFile zdir;
    3.87 -        public ZipArchive(ZipFile zdir) throws IOException {
    3.88 -            this.zdir = zdir;
    3.89 -            this.map = new HashMap<String,List<String>>();
    3.90 -            for (Enumeration<? extends ZipEntry> e = zdir.entries(); e.hasMoreElements(); ) {
    3.91 -                ZipEntry entry;
    3.92 -                try {
    3.93 -                    entry = e.nextElement();
    3.94 -                } catch (InternalError ex) {
    3.95 -                    IOException io = new IOException();
    3.96 -                    io.initCause(ex); // convenience constructors added in Mustang :-(
    3.97 -                    throw io;
    3.98 -                }
    3.99 -                addZipEntry(entry);
   3.100 -            }
   3.101 -        }
   3.102 -
   3.103 -        void addZipEntry(ZipEntry entry) {
   3.104 -            String name = entry.getName();
   3.105 -            int i = name.lastIndexOf('/');
   3.106 -            String dirname = name.substring(0, i+1);
   3.107 -            String basename = name.substring(i+1);
   3.108 -            if (basename.length() == 0)
   3.109 -                return;
   3.110 -            List<String> list = map.get(dirname);
   3.111 -            if (list == null)
   3.112 -                list = List.nil();
   3.113 -            list = list.prepend(basename);
   3.114 -            map.put(dirname, list);
   3.115 -        }
   3.116 -
   3.117 -        public boolean contains(String name) {
   3.118 -            int i = name.lastIndexOf('/');
   3.119 -            String dirname = name.substring(0, i+1);
   3.120 -            String basename = name.substring(i+1);
   3.121 -            if (basename.length() == 0)
   3.122 -                return false;
   3.123 -            List<String> list = map.get(dirname);
   3.124 -            return (list != null && list.contains(basename));
   3.125 -        }
   3.126 -
   3.127 -        public List<String> getFiles(String subdirectory) {
   3.128 -            return map.get(subdirectory);
   3.129 -        }
   3.130 -
   3.131 -        public JavaFileObject getFileObject(String subdirectory, String file) {
   3.132 -            ZipEntry ze = zdir.getEntry(subdirectory + file);
   3.133 -            return new ZipFileObject(file, zdir, ze);
   3.134 -        }
   3.135 -
   3.136 -        public Set<String> getSubdirectories() {
   3.137 -            return map.keySet();
   3.138 -        }
   3.139 -
   3.140 -        public void close() throws IOException {
   3.141 -            zdir.close();
   3.142 -        }
   3.143 -    }
   3.144 -
   3.145 -    public class SymbolArchive extends ZipArchive {
   3.146 -        final File origFile;
   3.147 -        public SymbolArchive(File orig, ZipFile zdir) throws IOException {
   3.148 -            super(zdir);
   3.149 -            this.origFile = orig;
   3.150 -        }
   3.151 -
   3.152 -        @Override
   3.153 -        void addZipEntry(ZipEntry entry) {
   3.154 -            // called from super constructor, may not refer to origFile.
   3.155 -            String name = entry.getName();
   3.156 -            if (!name.startsWith(symbolFilePrefix))
   3.157 -                return;
   3.158 -            name = name.substring(symbolFilePrefix.length());
   3.159 -            int i = name.lastIndexOf('/');
   3.160 -            String dirname = name.substring(0, i+1);
   3.161 -            String basename = name.substring(i+1);
   3.162 -            if (basename.length() == 0)
   3.163 -                return;
   3.164 -            List<String> list = map.get(dirname);
   3.165 -            if (list == null)
   3.166 -                list = List.nil();
   3.167 -            list = list.prepend(basename);
   3.168 -            map.put(dirname, list);
   3.169 -        }
   3.170 -
   3.171 -        @Override
   3.172 -        public JavaFileObject getFileObject(String subdirectory, String file) {
   3.173 -            return super.getFileObject(symbolFilePrefix + subdirectory, file);
   3.174 -        }
   3.175 -    }
   3.176 -
   3.177      public class MissingArchive implements Archive {
   3.178          final File zipFileName;
   3.179          public MissingArchive(File name) {
   3.180              zipFileName = name;
   3.181          }
   3.182          public boolean contains(String name) {
   3.183 -              return false;
   3.184 +            return false;
   3.185          }
   3.186  
   3.187          public void close() {
   3.188 @@ -647,25 +538,30 @@
   3.189  
   3.190                  if (origZipFileName == zipFileName) {
   3.191                      if (!useZipFileIndex) {
   3.192 -                        archive = new ZipArchive(zdir);
   3.193 +                        archive = new ZipArchive(this, zdir);
   3.194                      } else {
   3.195 -                        archive = new ZipFileIndexArchive(this, ZipFileIndex.getZipFileIndex(zipFileName, 0,
   3.196 +                        archive = new ZipFileIndexArchive(this, ZipFileIndex.getZipFileIndex(zipFileName, null,
   3.197                                  usePreindexedCache, preindexCacheLocation, options.get("writezipindexfiles") != null));
   3.198                      }
   3.199                  }
   3.200                  else {
   3.201                      if (!useZipFileIndex) {
   3.202 -                        archive = new SymbolArchive(origZipFileName, zdir);
   3.203 +                        archive = new SymbolArchive(this, origZipFileName, zdir, symbolFilePrefix);
   3.204                      }
   3.205                      else {
   3.206 -                        archive = new ZipFileIndexArchive(this, ZipFileIndex.getZipFileIndex(zipFileName, symbolFilePrefixLength,
   3.207 -                                usePreindexedCache, preindexCacheLocation, options.get("writezipindexfiles") != null));
   3.208 +                        archive = new ZipFileIndexArchive(this,
   3.209 +                                ZipFileIndex.getZipFileIndex(zipFileName,
   3.210 +                                symbolFilePrefix,
   3.211 +                                usePreindexedCache,
   3.212 +                                preindexCacheLocation,
   3.213 +                                options.get("writezipindexfiles") != null));
   3.214                      }
   3.215                  }
   3.216              } catch (FileNotFoundException ex) {
   3.217                  archive = new MissingArchive(zipFileName);
   3.218              } catch (IOException ex) {
   3.219 -                log.error("error.reading.file", zipFileName, ex.getLocalizedMessage());
   3.220 +                if (zipFileName.exists())
   3.221 +                    log.error("error.reading.file", zipFileName, ex.getLocalizedMessage());
   3.222                  archive = new MissingArchive(zipFileName);
   3.223              }
   3.224  
   3.225 @@ -694,7 +590,17 @@
   3.226          }
   3.227      }
   3.228  
   3.229 -    private Map<JavaFileObject, SoftReference<CharBuffer>> contentCache = new HashMap<JavaFileObject, SoftReference<CharBuffer>>();
   3.230 +    CharBuffer getCachedContent(JavaFileObject file) {
   3.231 +        SoftReference<CharBuffer> r = contentCache.get(file);
   3.232 +        return (r == null ? null : r.get());
   3.233 +    }
   3.234 +
   3.235 +    void cache(JavaFileObject file, CharBuffer cb) {
   3.236 +        contentCache.put(file, new SoftReference<CharBuffer>(cb));
   3.237 +    }
   3.238 +
   3.239 +    private final Map<JavaFileObject, SoftReference<CharBuffer>> contentCache
   3.240 +            = new HashMap<JavaFileObject, SoftReference<CharBuffer>>();
   3.241  
   3.242      private String defaultEncodingName;
   3.243      private String getDefaultEncodingName() {
   3.244 @@ -724,7 +630,7 @@
   3.245      /**
   3.246       * Make a byte buffer from an input stream.
   3.247       */
   3.248 -    private ByteBuffer makeByteBuffer(InputStream in)
   3.249 +    ByteBuffer makeByteBuffer(InputStream in)
   3.250          throws IOException {
   3.251          int limit = in.available();
   3.252          if (mmappedIO && in instanceof FileInputStream) {
   3.253 @@ -750,6 +656,10 @@
   3.254          return (ByteBuffer)result.flip();
   3.255      }
   3.256  
   3.257 +    void recycleByteBuffer(ByteBuffer bb) {
   3.258 +        byteBufferCache.put(bb);
   3.259 +    }
   3.260 +
   3.261      /**
   3.262       * A single-element cache of direct byte buffers.
   3.263       */
   3.264 @@ -768,9 +678,10 @@
   3.265              cached = x;
   3.266          }
   3.267      }
   3.268 +
   3.269      private final ByteBufferCache byteBufferCache;
   3.270  
   3.271 -    private CharsetDecoder getDecoder(String encodingName, boolean ignoreEncodingErrors) {
   3.272 +    CharsetDecoder getDecoder(String encodingName, boolean ignoreEncodingErrors) {
   3.273          Charset charset = (this.charset == null)
   3.274              ? Charset.forName(encodingName)
   3.275              : this.charset;
   3.276 @@ -790,7 +701,7 @@
   3.277      /**
   3.278       * Decode a ByteBuffer into a CharBuffer.
   3.279       */
   3.280 -    private CharBuffer decode(ByteBuffer inbuf, boolean ignoreEncodingErrors) {
   3.281 +    CharBuffer decode(ByteBuffer inbuf, boolean ignoreEncodingErrors) {
   3.282          String encodingName = getEncodingName();
   3.283          CharsetDecoder decoder;
   3.284          try {
   3.285 @@ -900,48 +811,14 @@
   3.286          // Need to match the path semantics of list(location, ...)
   3.287          Iterable<? extends File> path = getLocation(location);
   3.288          if (path == null) {
   3.289 -            //System.err.println("Path for " + location + " is null");
   3.290              return null;
   3.291          }
   3.292 -        //System.err.println("Path for " + location + " is " + path);
   3.293  
   3.294 -        if (file instanceof RegularFileObject) {
   3.295 -            RegularFileObject r = (RegularFileObject) file;
   3.296 -            String rPath = r.getPath();
   3.297 -            //System.err.println("RegularFileObject " + file + " " +r.getPath());
   3.298 -            for (File dir: path) {
   3.299 -                //System.err.println("dir: " + dir);
   3.300 -                String dPath = dir.getPath();
   3.301 -                if (!dPath.endsWith(File.separator))
   3.302 -                    dPath += File.separator;
   3.303 -                if (rPath.regionMatches(true, 0, dPath, 0, dPath.length())
   3.304 -                    && new File(rPath.substring(0, dPath.length())).equals(new File(dPath))) {
   3.305 -                    String relativeName = rPath.substring(dPath.length());
   3.306 -                    return removeExtension(relativeName).replace(File.separatorChar, '.');
   3.307 -                }
   3.308 -            }
   3.309 -        } else if (file instanceof ZipFileObject) {
   3.310 -            ZipFileObject z = (ZipFileObject) file;
   3.311 -            String entryName = z.getZipEntryName();
   3.312 -            if (entryName.startsWith(symbolFilePrefix))
   3.313 -                entryName = entryName.substring(symbolFilePrefix.length());
   3.314 -            return removeExtension(entryName).replace('/', '.');
   3.315 -        } else if (file instanceof ZipFileIndexFileObject) {
   3.316 -            ZipFileIndexFileObject z = (ZipFileIndexFileObject) file;
   3.317 -            String entryName = z.getZipEntryName();
   3.318 -            if (entryName.startsWith(symbolFilePrefix))
   3.319 -                entryName = entryName.substring(symbolFilePrefix.length());
   3.320 -            return removeExtension(entryName).replace(File.separatorChar, '.');
   3.321 +        if (file instanceof BaseFileObject) {
   3.322 +            return ((BaseFileObject) file).inferBinaryName(path);
   3.323          } else
   3.324              throw new IllegalArgumentException(file.getClass().getName());
   3.325 -        // System.err.println("inferBinaryName failed for " + file);
   3.326 -        return null;
   3.327      }
   3.328 -    // where
   3.329 -        private static String removeExtension(String fileName) {
   3.330 -            int lastDot = fileName.lastIndexOf(".");
   3.331 -            return (lastDot == -1 ? fileName : fileName.substring(0, lastDot));
   3.332 -        }
   3.333  
   3.334      public boolean isSameFile(FileObject a, FileObject b) {
   3.335          nullCheck(a);
   3.336 @@ -1028,7 +905,7 @@
   3.337              if (dir.isDirectory()) {
   3.338                  File f = new File(dir, name.replace('/', File.separatorChar));
   3.339                  if (f.exists())
   3.340 -                    return new RegularFileObject(f);
   3.341 +                    return new RegularFileObject(this, f);
   3.342              } else {
   3.343                  Archive a = openArchive(dir);
   3.344                  if (a.contains(name)) {
   3.345 @@ -1090,7 +967,7 @@
   3.346                  if (sibling != null && sibling instanceof RegularFileObject) {
   3.347                      siblingDir = ((RegularFileObject)sibling).f.getParentFile();
   3.348                  }
   3.349 -                return new RegularFileObject(new File(siblingDir, baseName(fileName)));
   3.350 +                return new RegularFileObject(this, new File(siblingDir, baseName(fileName)));
   3.351              }
   3.352          } else if (location == SOURCE_OUTPUT) {
   3.353              dir = (getSourceOutDir() != null ? getSourceOutDir() : getClassOutDir());
   3.354 @@ -1104,7 +981,7 @@
   3.355          }
   3.356  
   3.357          File file = (dir == null ? new File(fileName) : new File(dir, fileName));
   3.358 -        return new RegularFileObject(file);
   3.359 +        return new RegularFileObject(this, file);
   3.360  
   3.361      }
   3.362  
   3.363 @@ -1117,7 +994,7 @@
   3.364          else
   3.365              result = new ArrayList<RegularFileObject>();
   3.366          for (File f: files)
   3.367 -            result.add(new RegularFileObject(nullCheck(f)));
   3.368 +            result.add(new RegularFileObject(this, nullCheck(f)));
   3.369          return result;
   3.370      }
   3.371  
   3.372 @@ -1267,452 +1144,4 @@
   3.373              t.getClass(); // null check
   3.374          return it;
   3.375      }
   3.376 -
   3.377 -    /**
   3.378 -     * A subclass of JavaFileObject representing regular files.
   3.379 -     */
   3.380 -    private class RegularFileObject extends BaseFileObject {
   3.381 -        /** Have the parent directories been created?
   3.382 -         */
   3.383 -        private boolean hasParents=false;
   3.384 -
   3.385 -        /** The file's name.
   3.386 -         */
   3.387 -        private String name;
   3.388 -
   3.389 -        /** The underlying file.
   3.390 -         */
   3.391 -        final File f;
   3.392 -
   3.393 -        public RegularFileObject(File f) {
   3.394 -            this(f.getName(), f);
   3.395 -        }
   3.396 -
   3.397 -        public RegularFileObject(String name, File f) {
   3.398 -            if (f.isDirectory())
   3.399 -                throw new IllegalArgumentException("directories not supported");
   3.400 -            this.name = name;
   3.401 -            this.f = f;
   3.402 -        }
   3.403 -
   3.404 -        public InputStream openInputStream() throws IOException {
   3.405 -            return new FileInputStream(f);
   3.406 -        }
   3.407 -
   3.408 -        protected CharsetDecoder getDecoder(boolean ignoreEncodingErrors) {
   3.409 -            return JavacFileManager.this.getDecoder(getEncodingName(), ignoreEncodingErrors);
   3.410 -        }
   3.411 -
   3.412 -        public OutputStream openOutputStream() throws IOException {
   3.413 -            ensureParentDirectoriesExist();
   3.414 -            return new FileOutputStream(f);
   3.415 -        }
   3.416 -
   3.417 -        public Writer openWriter() throws IOException {
   3.418 -            ensureParentDirectoriesExist();
   3.419 -            return new OutputStreamWriter(new FileOutputStream(f), getEncodingName());
   3.420 -        }
   3.421 -
   3.422 -        private void ensureParentDirectoriesExist() throws IOException {
   3.423 -            if (!hasParents) {
   3.424 -                File parent = f.getParentFile();
   3.425 -                if (parent != null && !parent.exists()) {
   3.426 -                    if (!parent.mkdirs()) {
   3.427 -                        // if the mkdirs failed, it may be because another process concurrently
   3.428 -                        // created the directory, so check if the directory got created
   3.429 -                        // anyway before throwing an exception
   3.430 -                        if (!parent.exists() || !parent.isDirectory())
   3.431 -                            throw new IOException("could not create parent directories");
   3.432 -                    }
   3.433 -                }
   3.434 -                hasParents = true;
   3.435 -            }
   3.436 -        }
   3.437 -
   3.438 -        /** @deprecated see bug 6410637 */
   3.439 -        @Deprecated
   3.440 -        public String getName() {
   3.441 -            return name;
   3.442 -        }
   3.443 -
   3.444 -        public boolean isNameCompatible(String cn, JavaFileObject.Kind kind) {
   3.445 -            cn.getClass(); // null check
   3.446 -            if (kind == Kind.OTHER && getKind() != kind)
   3.447 -                return false;
   3.448 -            String n = cn + kind.extension;
   3.449 -            if (name.equals(n))
   3.450 -                return true;
   3.451 -            if (name.equalsIgnoreCase(n)) {
   3.452 -                try {
   3.453 -                    // allow for Windows
   3.454 -                    return (f.getCanonicalFile().getName().equals(n));
   3.455 -                } catch (IOException e) {
   3.456 -                }
   3.457 -            }
   3.458 -            return false;
   3.459 -        }
   3.460 -
   3.461 -        /** @deprecated see bug 6410637 */
   3.462 -        @Deprecated
   3.463 -        public String getPath() {
   3.464 -            return f.getPath();
   3.465 -        }
   3.466 -
   3.467 -        public long getLastModified() {
   3.468 -            return f.lastModified();
   3.469 -        }
   3.470 -
   3.471 -        public boolean delete() {
   3.472 -            return f.delete();
   3.473 -        }
   3.474 -
   3.475 -        public CharBuffer getCharContent(boolean ignoreEncodingErrors) throws IOException {
   3.476 -            SoftReference<CharBuffer> r = contentCache.get(this);
   3.477 -            CharBuffer cb = (r == null ? null : r.get());
   3.478 -            if (cb == null) {
   3.479 -                InputStream in = new FileInputStream(f);
   3.480 -                try {
   3.481 -                    ByteBuffer bb = makeByteBuffer(in);
   3.482 -                    JavaFileObject prev = log.useSource(this);
   3.483 -                    try {
   3.484 -                        cb = decode(bb, ignoreEncodingErrors);
   3.485 -                    } finally {
   3.486 -                        log.useSource(prev);
   3.487 -                    }
   3.488 -                    byteBufferCache.put(bb); // save for next time
   3.489 -                    if (!ignoreEncodingErrors)
   3.490 -                        contentCache.put(this, new SoftReference<CharBuffer>(cb));
   3.491 -                } finally {
   3.492 -                    in.close();
   3.493 -                }
   3.494 -            }
   3.495 -            return cb;
   3.496 -        }
   3.497 -
   3.498 -        @Override
   3.499 -        public boolean equals(Object other) {
   3.500 -            if (!(other instanceof RegularFileObject))
   3.501 -                return false;
   3.502 -            RegularFileObject o = (RegularFileObject) other;
   3.503 -            try {
   3.504 -                return f.equals(o.f)
   3.505 -                    || f.getCanonicalFile().equals(o.f.getCanonicalFile());
   3.506 -            } catch (IOException e) {
   3.507 -                return false;
   3.508 -            }
   3.509 -        }
   3.510 -
   3.511 -        @Override
   3.512 -        public int hashCode() {
   3.513 -            return f.hashCode();
   3.514 -        }
   3.515 -
   3.516 -        public URI toUri() {
   3.517 -            try {
   3.518 -                // Do no use File.toURI to avoid file system access
   3.519 -                String path = f.getAbsolutePath().replace(File.separatorChar, '/');
   3.520 -                return new URI("file://" + path).normalize();
   3.521 -            } catch (URISyntaxException ex) {
   3.522 -                return f.toURI();
   3.523 -            }
   3.524 -        }
   3.525 -
   3.526 -    }
   3.527 -
   3.528 -    /**
   3.529 -     * A subclass of JavaFileObject representing zip entries.
   3.530 -     */
   3.531 -    public class ZipFileObject extends BaseFileObject {
   3.532 -
   3.533 -        /** The entry's name.
   3.534 -         */
   3.535 -        private String name;
   3.536 -
   3.537 -        /** The zipfile containing the entry.
   3.538 -         */
   3.539 -        ZipFile zdir;
   3.540 -
   3.541 -        /** The underlying zip entry object.
   3.542 -         */
   3.543 -        ZipEntry entry;
   3.544 -
   3.545 -        public ZipFileObject(String name, ZipFile zdir, ZipEntry entry) {
   3.546 -            this.name = name;
   3.547 -            this.zdir = zdir;
   3.548 -            this.entry = entry;
   3.549 -        }
   3.550 -
   3.551 -        public InputStream openInputStream() throws IOException {
   3.552 -            return zdir.getInputStream(entry);
   3.553 -        }
   3.554 -
   3.555 -        public OutputStream openOutputStream() throws IOException {
   3.556 -            throw new UnsupportedOperationException();
   3.557 -        }
   3.558 -
   3.559 -        protected CharsetDecoder getDecoder(boolean ignoreEncodingErrors) {
   3.560 -            return JavacFileManager.this.getDecoder(getEncodingName(), ignoreEncodingErrors);
   3.561 -        }
   3.562 -
   3.563 -        public Writer openWriter() throws IOException {
   3.564 -            throw new UnsupportedOperationException();
   3.565 -        }
   3.566 -
   3.567 -        /** @deprecated see bug 6410637 */
   3.568 -        @Deprecated
   3.569 -        public String getName() {
   3.570 -            return name;
   3.571 -        }
   3.572 -
   3.573 -        public boolean isNameCompatible(String cn, JavaFileObject.Kind k) {
   3.574 -            cn.getClass(); // null check
   3.575 -            if (k == Kind.OTHER && getKind() != k)
   3.576 -                return false;
   3.577 -            return name.equals(cn + k.extension);
   3.578 -        }
   3.579 -
   3.580 -        /** @deprecated see bug 6410637 */
   3.581 -        @Deprecated
   3.582 -        public String getPath() {
   3.583 -            return zdir.getName() + "(" + entry + ")";
   3.584 -        }
   3.585 -
   3.586 -        public long getLastModified() {
   3.587 -            return entry.getTime();
   3.588 -        }
   3.589 -
   3.590 -        public boolean delete() {
   3.591 -            throw new UnsupportedOperationException();
   3.592 -        }
   3.593 -
   3.594 -        public CharBuffer getCharContent(boolean ignoreEncodingErrors) throws IOException {
   3.595 -            SoftReference<CharBuffer> r = contentCache.get(this);
   3.596 -            CharBuffer cb = (r == null ? null : r.get());
   3.597 -            if (cb == null) {
   3.598 -                InputStream in = zdir.getInputStream(entry);
   3.599 -                try {
   3.600 -                    ByteBuffer bb = makeByteBuffer(in);
   3.601 -                    JavaFileObject prev = log.useSource(this);
   3.602 -                    try {
   3.603 -                        cb = decode(bb, ignoreEncodingErrors);
   3.604 -                    } finally {
   3.605 -                        log.useSource(prev);
   3.606 -                    }
   3.607 -                    byteBufferCache.put(bb); // save for next time
   3.608 -                    if (!ignoreEncodingErrors)
   3.609 -                        contentCache.put(this, new SoftReference<CharBuffer>(cb));
   3.610 -                } finally {
   3.611 -                    in.close();
   3.612 -                }
   3.613 -            }
   3.614 -            return cb;
   3.615 -        }
   3.616 -
   3.617 -        @Override
   3.618 -        public boolean equals(Object other) {
   3.619 -            if (!(other instanceof ZipFileObject))
   3.620 -                return false;
   3.621 -            ZipFileObject o = (ZipFileObject) other;
   3.622 -            return zdir.equals(o.zdir) || name.equals(o.name);
   3.623 -        }
   3.624 -
   3.625 -        @Override
   3.626 -        public int hashCode() {
   3.627 -            return zdir.hashCode() + name.hashCode();
   3.628 -        }
   3.629 -
   3.630 -        public String getZipName() {
   3.631 -            return zdir.getName();
   3.632 -        }
   3.633 -
   3.634 -        public String getZipEntryName() {
   3.635 -            return entry.getName();
   3.636 -        }
   3.637 -
   3.638 -        public URI toUri() {
   3.639 -            String zipName = new File(getZipName()).toURI().normalize().getPath();
   3.640 -            String entryName = getZipEntryName();
   3.641 -            return URI.create("jar:" + zipName + "!" + entryName);
   3.642 -        }
   3.643 -
   3.644 -    }
   3.645 -
   3.646 -    /**
   3.647 -     * A subclass of JavaFileObject representing zip entries using the com.sun.tools.javac.zip.ZipFileIndex implementation.
   3.648 -     */
   3.649 -    public class ZipFileIndexFileObject extends BaseFileObject {
   3.650 -
   3.651 -            /** The entry's name.
   3.652 -         */
   3.653 -        private String name;
   3.654 -
   3.655 -        /** The zipfile containing the entry.
   3.656 -         */
   3.657 -        ZipFileIndex zfIndex;
   3.658 -
   3.659 -        /** The underlying zip entry object.
   3.660 -         */
   3.661 -        ZipFileIndexEntry entry;
   3.662 -
   3.663 -        /** The InputStream for this zip entry (file.)
   3.664 -         */
   3.665 -        InputStream inputStream = null;
   3.666 -
   3.667 -        /** The name of the zip file where this entry resides.
   3.668 -         */
   3.669 -        String zipName;
   3.670 -
   3.671 -        JavacFileManager defFileManager = null;
   3.672 -
   3.673 -        public ZipFileIndexFileObject(JavacFileManager fileManager, ZipFileIndex zfIndex, ZipFileIndexEntry entry, String zipFileName) {
   3.674 -            super();
   3.675 -            this.name = entry.getFileName();
   3.676 -            this.zfIndex = zfIndex;
   3.677 -            this.entry = entry;
   3.678 -            this.zipName = zipFileName;
   3.679 -            defFileManager = fileManager;
   3.680 -        }
   3.681 -
   3.682 -        public InputStream openInputStream() throws IOException {
   3.683 -
   3.684 -            if (inputStream == null) {
   3.685 -                inputStream = new ByteArrayInputStream(read());
   3.686 -            }
   3.687 -            return inputStream;
   3.688 -        }
   3.689 -
   3.690 -        protected CharsetDecoder getDecoder(boolean ignoreEncodingErrors) {
   3.691 -            return JavacFileManager.this.getDecoder(getEncodingName(), ignoreEncodingErrors);
   3.692 -        }
   3.693 -
   3.694 -        public OutputStream openOutputStream() throws IOException {
   3.695 -            throw new UnsupportedOperationException();
   3.696 -        }
   3.697 -
   3.698 -        public Writer openWriter() throws IOException {
   3.699 -            throw new UnsupportedOperationException();
   3.700 -        }
   3.701 -
   3.702 -        /** @deprecated see bug 6410637 */
   3.703 -        @Deprecated
   3.704 -        public String getName() {
   3.705 -            return name;
   3.706 -        }
   3.707 -
   3.708 -        public boolean isNameCompatible(String cn, JavaFileObject.Kind k) {
   3.709 -            cn.getClass(); // null check
   3.710 -            if (k == Kind.OTHER && getKind() != k)
   3.711 -                return false;
   3.712 -            return name.equals(cn + k.extension);
   3.713 -        }
   3.714 -
   3.715 -        /** @deprecated see bug 6410637 */
   3.716 -        @Deprecated
   3.717 -        public String getPath() {
   3.718 -            return zipName + "(" + entry.getName() + ")";
   3.719 -        }
   3.720 -
   3.721 -        public long getLastModified() {
   3.722 -            return entry.getLastModified();
   3.723 -        }
   3.724 -
   3.725 -        public boolean delete() {
   3.726 -            throw new UnsupportedOperationException();
   3.727 -        }
   3.728 -
   3.729 -        @Override
   3.730 -        public boolean equals(Object other) {
   3.731 -            if (!(other instanceof ZipFileIndexFileObject))
   3.732 -                return false;
   3.733 -            ZipFileIndexFileObject o = (ZipFileIndexFileObject) other;
   3.734 -            return entry.equals(o.entry);
   3.735 -        }
   3.736 -
   3.737 -        @Override
   3.738 -        public int hashCode() {
   3.739 -            return zipName.hashCode() + (name.hashCode() << 10);
   3.740 -        }
   3.741 -
   3.742 -        public String getZipName() {
   3.743 -            return zipName;
   3.744 -        }
   3.745 -
   3.746 -        public String getZipEntryName() {
   3.747 -            return entry.getName();
   3.748 -        }
   3.749 -
   3.750 -        public URI toUri() {
   3.751 -            String zipName = new File(getZipName()).toURI().normalize().getPath();
   3.752 -            String entryName = getZipEntryName();
   3.753 -            if (File.separatorChar != '/') {
   3.754 -                entryName = entryName.replace(File.separatorChar, '/');
   3.755 -            }
   3.756 -            return URI.create("jar:" + zipName + "!" + entryName);
   3.757 -        }
   3.758 -
   3.759 -        private byte[] read() throws IOException {
   3.760 -            if (entry == null) {
   3.761 -                entry = zfIndex.getZipIndexEntry(name);
   3.762 -                if (entry == null)
   3.763 -                  throw new FileNotFoundException();
   3.764 -            }
   3.765 -            return zfIndex.read(entry);
   3.766 -        }
   3.767 -
   3.768 -        public CharBuffer getCharContent(boolean ignoreEncodingErrors) throws IOException {
   3.769 -            SoftReference<CharBuffer> r = defFileManager.contentCache.get(this);
   3.770 -            CharBuffer cb = (r == null ? null : r.get());
   3.771 -            if (cb == null) {
   3.772 -                InputStream in = new ByteArrayInputStream(zfIndex.read(entry));
   3.773 -                try {
   3.774 -                    ByteBuffer bb = makeByteBuffer(in);
   3.775 -                    JavaFileObject prev = log.useSource(this);
   3.776 -                    try {
   3.777 -                        cb = decode(bb, ignoreEncodingErrors);
   3.778 -                    } finally {
   3.779 -                        log.useSource(prev);
   3.780 -                    }
   3.781 -                    byteBufferCache.put(bb); // save for next time
   3.782 -                    if (!ignoreEncodingErrors)
   3.783 -                        defFileManager.contentCache.put(this, new SoftReference<CharBuffer>(cb));
   3.784 -                } finally {
   3.785 -                    in.close();
   3.786 -                }
   3.787 -            }
   3.788 -            return cb;
   3.789 -        }
   3.790 -    }
   3.791 -
   3.792 -    public class ZipFileIndexArchive implements Archive {
   3.793 -        private final ZipFileIndex zfIndex;
   3.794 -        private JavacFileManager fileManager;
   3.795 -
   3.796 -        public ZipFileIndexArchive(JavacFileManager fileManager, ZipFileIndex zdir) throws IOException {
   3.797 -            this.fileManager = fileManager;
   3.798 -            this.zfIndex = zdir;
   3.799 -        }
   3.800 -
   3.801 -        public boolean contains(String name) {
   3.802 -            return zfIndex.contains(name);
   3.803 -        }
   3.804 -
   3.805 -        public com.sun.tools.javac.util.List<String> getFiles(String subdirectory) {
   3.806 -              return zfIndex.getFiles(((subdirectory.endsWith("/") || subdirectory.endsWith("\\"))? subdirectory.substring(0, subdirectory.length() - 1) : subdirectory));
   3.807 -        }
   3.808 -
   3.809 -        public JavaFileObject getFileObject(String subdirectory, String file) {
   3.810 -            String fullZipFileName = subdirectory + file;
   3.811 -            ZipFileIndexEntry entry = zfIndex.getZipIndexEntry(fullZipFileName);
   3.812 -            JavaFileObject ret = new ZipFileIndexFileObject(fileManager, zfIndex, entry, zfIndex.getZipFile().getPath());
   3.813 -            return ret;
   3.814 -        }
   3.815 -
   3.816 -        public Set<String> getSubdirectories() {
   3.817 -            return zfIndex.getAllDirectories();
   3.818 -        }
   3.819 -
   3.820 -        public void close() throws IOException {
   3.821 -            zfIndex.close();
   3.822 -        }
   3.823 -    }
   3.824  }
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/src/share/classes/com/sun/tools/javac/file/RegularFileObject.java	Wed Jun 25 23:30:55 2008 -0700
     4.3 @@ -0,0 +1,204 @@
     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 java.io.File;
    4.32 +import java.io.FileInputStream;
    4.33 +import java.io.FileOutputStream;
    4.34 +import java.io.IOException;
    4.35 +import java.io.InputStream;
    4.36 +import java.io.OutputStream;
    4.37 +import java.io.OutputStreamWriter;
    4.38 +import java.io.Writer;
    4.39 +import java.net.URI;
    4.40 +import java.net.URISyntaxException;
    4.41 +import java.nio.ByteBuffer;
    4.42 +import java.nio.CharBuffer;
    4.43 +import java.nio.charset.CharsetDecoder;
    4.44 +import javax.tools.JavaFileObject;
    4.45 +
    4.46 +/**
    4.47 + * A subclass of JavaFileObject representing regular files.
    4.48 + */
    4.49 +class RegularFileObject extends BaseFileObject {
    4.50 +
    4.51 +    /** Have the parent directories been created?
    4.52 +     */
    4.53 +    private boolean hasParents = false;
    4.54 +    private String name;
    4.55 +    final File f;
    4.56 +
    4.57 +    public RegularFileObject(JavacFileManager fileManager, File f) {
    4.58 +        this(fileManager, f.getName(), f);
    4.59 +    }
    4.60 +
    4.61 +    public RegularFileObject(JavacFileManager fileManager, String name, File f) {
    4.62 +        super(fileManager);
    4.63 +        if (f.isDirectory()) {
    4.64 +            throw new IllegalArgumentException("directories not supported");
    4.65 +        }
    4.66 +        this.name = name;
    4.67 +        this.f = f;
    4.68 +    }
    4.69 +
    4.70 +    public InputStream openInputStream() throws IOException {
    4.71 +        return new FileInputStream(f);
    4.72 +    }
    4.73 +
    4.74 +    protected CharsetDecoder getDecoder(boolean ignoreEncodingErrors) {
    4.75 +        return fileManager.getDecoder(fileManager.getEncodingName(), ignoreEncodingErrors);
    4.76 +    }
    4.77 +
    4.78 +    public OutputStream openOutputStream() throws IOException {
    4.79 +        ensureParentDirectoriesExist();
    4.80 +        return new FileOutputStream(f);
    4.81 +    }
    4.82 +
    4.83 +    public Writer openWriter() throws IOException {
    4.84 +        ensureParentDirectoriesExist();
    4.85 +        return new OutputStreamWriter(new FileOutputStream(f), fileManager.getEncodingName());
    4.86 +    }
    4.87 +
    4.88 +    @Override
    4.89 +    protected String inferBinaryName(Iterable<? extends File> path) {
    4.90 +        String fPath = f.getPath();
    4.91 +        //System.err.println("RegularFileObject " + file + " " +r.getPath());
    4.92 +        for (File dir: path) {
    4.93 +            //System.err.println("dir: " + dir);
    4.94 +            String dPath = dir.getPath();
    4.95 +            if (!dPath.endsWith(File.separator))
    4.96 +                dPath += File.separator;
    4.97 +            if (fPath.regionMatches(true, 0, dPath, 0, dPath.length())
    4.98 +                && new File(fPath.substring(0, dPath.length())).equals(new File(dPath))) {
    4.99 +                String relativeName = fPath.substring(dPath.length());
   4.100 +                return removeExtension(relativeName).replace(File.separatorChar, '.');
   4.101 +            }
   4.102 +        }
   4.103 +        return null;
   4.104 +    }
   4.105 +
   4.106 +    private void ensureParentDirectoriesExist() throws IOException {
   4.107 +        if (!hasParents) {
   4.108 +            File parent = f.getParentFile();
   4.109 +            if (parent != null && !parent.exists()) {
   4.110 +                if (!parent.mkdirs()) {
   4.111 +                    if (!parent.exists() || !parent.isDirectory()) {
   4.112 +                        throw new IOException("could not create parent directories");
   4.113 +                    }
   4.114 +                }
   4.115 +            }
   4.116 +            hasParents = true;
   4.117 +        }
   4.118 +    }
   4.119 +
   4.120 +    @Deprecated
   4.121 +    public String getName() {
   4.122 +        return name;
   4.123 +    }
   4.124 +
   4.125 +    public boolean isNameCompatible(String cn, JavaFileObject.Kind kind) {
   4.126 +        cn.getClass();
   4.127 +        // null check
   4.128 +        if (kind == Kind.OTHER && getKind() != kind) {
   4.129 +            return false;
   4.130 +        }
   4.131 +        String n = cn + kind.extension;
   4.132 +        if (name.equals(n)) {
   4.133 +            return true;
   4.134 +        }
   4.135 +        if (name.equalsIgnoreCase(n)) {
   4.136 +            try {
   4.137 +                // allow for Windows
   4.138 +                return f.getCanonicalFile().getName().equals(n);
   4.139 +            } catch (IOException e) {
   4.140 +            }
   4.141 +        }
   4.142 +        return false;
   4.143 +    }
   4.144 +
   4.145 +    @Deprecated
   4.146 +    public String getPath() {
   4.147 +        return f.getPath();
   4.148 +    }
   4.149 +
   4.150 +    public long getLastModified() {
   4.151 +        return f.lastModified();
   4.152 +    }
   4.153 +
   4.154 +    public boolean delete() {
   4.155 +        return f.delete();
   4.156 +    }
   4.157 +
   4.158 +    public CharBuffer getCharContent(boolean ignoreEncodingErrors) throws IOException {
   4.159 +        CharBuffer cb = fileManager.getCachedContent(this);
   4.160 +        if (cb == null) {
   4.161 +            InputStream in = new FileInputStream(f);
   4.162 +            try {
   4.163 +                ByteBuffer bb = fileManager.makeByteBuffer(in);
   4.164 +                JavaFileObject prev = fileManager.log.useSource(this);
   4.165 +                try {
   4.166 +                    cb = fileManager.decode(bb, ignoreEncodingErrors);
   4.167 +                } finally {
   4.168 +                    fileManager.log.useSource(prev);
   4.169 +                }
   4.170 +                fileManager.recycleByteBuffer(bb);
   4.171 +                if (!ignoreEncodingErrors) {
   4.172 +                    fileManager.cache(this, cb);
   4.173 +                }
   4.174 +            } finally {
   4.175 +                in.close();
   4.176 +            }
   4.177 +        }
   4.178 +        return cb;
   4.179 +    }
   4.180 +
   4.181 +    @Override
   4.182 +    public boolean equals(Object other) {
   4.183 +        if (!(other instanceof RegularFileObject)) {
   4.184 +            return false;
   4.185 +        }
   4.186 +        RegularFileObject o = (RegularFileObject) other;
   4.187 +        try {
   4.188 +            return f.equals(o.f) || f.getCanonicalFile().equals(o.f.getCanonicalFile());
   4.189 +        } catch (IOException e) {
   4.190 +            return false;
   4.191 +        }
   4.192 +    }
   4.193 +
   4.194 +    @Override
   4.195 +    public int hashCode() {
   4.196 +        return f.hashCode();
   4.197 +    }
   4.198 +
   4.199 +    public URI toUri() {
   4.200 +        try {
   4.201 +            String path = f.getAbsolutePath().replace(File.separatorChar, '/');
   4.202 +            return new URI("file://" + path).normalize();
   4.203 +        } catch (URISyntaxException ex) {
   4.204 +            return f.toURI();
   4.205 +        }
   4.206 +    }
   4.207 +}
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/src/share/classes/com/sun/tools/javac/file/SymbolArchive.java	Wed Jun 25 23:30:55 2008 -0700
     5.3 @@ -0,0 +1,71 @@
     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 com.sun.tools.javac.util.List;
    5.32 +import java.io.File;
    5.33 +import java.io.IOException;
    5.34 +import java.util.zip.ZipEntry;
    5.35 +import java.util.zip.ZipFile;
    5.36 +import javax.tools.JavaFileObject;
    5.37 +
    5.38 +public class SymbolArchive extends ZipArchive {
    5.39 +
    5.40 +    final File origFile;
    5.41 +    final String prefix;
    5.42 +
    5.43 +    public SymbolArchive(JavacFileManager fileManager, File orig, ZipFile zdir, String prefix) throws IOException {
    5.44 +        super(fileManager, zdir);
    5.45 +        this.origFile = orig;
    5.46 +        this.prefix = prefix;
    5.47 +    }
    5.48 +
    5.49 +    @Override
    5.50 +    void addZipEntry(ZipEntry entry) {
    5.51 +        String name = entry.getName();
    5.52 +        if (!name.startsWith(prefix)) {
    5.53 +            return;
    5.54 +        }
    5.55 +        name = name.substring(prefix.length());
    5.56 +        int i = name.lastIndexOf('/');
    5.57 +        String dirname = name.substring(0, i + 1);
    5.58 +        String basename = name.substring(i + 1);
    5.59 +        if (basename.length() == 0) {
    5.60 +            return;
    5.61 +        }
    5.62 +        List<String> list = map.get(dirname);
    5.63 +        if (list == null) {
    5.64 +            list = List.nil();
    5.65 +        }
    5.66 +        list = list.prepend(basename);
    5.67 +        map.put(dirname, list);
    5.68 +    }
    5.69 +
    5.70 +    @Override
    5.71 +    public JavaFileObject getFileObject(String subdirectory, String file) {
    5.72 +        return super.getFileObject(prefix + subdirectory, file);
    5.73 +    }
    5.74 +}
     6.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.2 +++ b/src/share/classes/com/sun/tools/javac/file/ZipArchive.java	Wed Jun 25 23:30:55 2008 -0700
     6.3 @@ -0,0 +1,234 @@
     6.4 +/*
     6.5 + * Copyright 2005-2008 Sun Microsystems, Inc.  All Rights Reserved.
     6.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     6.7 + *
     6.8 + * This code is free software; you can redistribute it and/or modify it
     6.9 + * under the terms of the GNU General Public License version 2 only, as
    6.10 + * published by the Free Software Foundation.  Sun designates this
    6.11 + * particular file as subject to the "Classpath" exception as provided
    6.12 + * by Sun in the LICENSE file that accompanied this code.
    6.13 + *
    6.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
    6.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    6.16 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    6.17 + * version 2 for more details (a copy is included in the LICENSE file that
    6.18 + * accompanied this code).
    6.19 + *
    6.20 + * You should have received a copy of the GNU General Public License version
    6.21 + * 2 along with this work; if not, write to the Free Software Foundation,
    6.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    6.23 + *
    6.24 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
    6.25 + * CA 95054 USA or visit www.sun.com if you need additional information or
    6.26 + * have any questions.
    6.27 + */
    6.28 +
    6.29 +package com.sun.tools.javac.file;
    6.30 +
    6.31 +import java.io.IOException;
    6.32 +import java.util.Enumeration;
    6.33 +import java.util.HashMap;
    6.34 +import java.util.Map;
    6.35 +import java.util.Set;
    6.36 +import java.util.zip.ZipEntry;
    6.37 +import java.util.zip.ZipFile;
    6.38 +import javax.tools.JavaFileObject;
    6.39 +
    6.40 +import com.sun.tools.javac.file.JavacFileManager.Archive;
    6.41 +import com.sun.tools.javac.util.List;
    6.42 +import java.io.File;
    6.43 +import java.io.InputStream;
    6.44 +import java.io.OutputStream;
    6.45 +import java.io.Writer;
    6.46 +import java.net.URI;
    6.47 +import java.nio.ByteBuffer;
    6.48 +import java.nio.CharBuffer;
    6.49 +import java.nio.charset.CharsetDecoder;
    6.50 +
    6.51 +public class ZipArchive implements Archive {
    6.52 +
    6.53 +    public ZipArchive(JavacFileManager fm, ZipFile zdir) throws IOException {
    6.54 +        this.fileManager = fm;
    6.55 +        this.zdir = zdir;
    6.56 +        this.map = new HashMap<String,List<String>>();
    6.57 +        for (Enumeration<? extends ZipEntry> e = zdir.entries(); e.hasMoreElements(); ) {
    6.58 +            ZipEntry entry;
    6.59 +            try {
    6.60 +                entry = e.nextElement();
    6.61 +            } catch (InternalError ex) {
    6.62 +                IOException io = new IOException();
    6.63 +                io.initCause(ex); // convenience constructors added in Mustang :-(
    6.64 +                throw io;
    6.65 +            }
    6.66 +            addZipEntry(entry);
    6.67 +        }
    6.68 +    }
    6.69 +
    6.70 +    void addZipEntry(ZipEntry entry) {
    6.71 +        String name = entry.getName();
    6.72 +        int i = name.lastIndexOf('/');
    6.73 +        String dirname = name.substring(0, i+1);
    6.74 +        String basename = name.substring(i+1);
    6.75 +        if (basename.length() == 0)
    6.76 +            return;
    6.77 +        List<String> list = map.get(dirname);
    6.78 +        if (list == null)
    6.79 +            list = List.nil();
    6.80 +        list = list.prepend(basename);
    6.81 +        map.put(dirname, list);
    6.82 +    }
    6.83 +
    6.84 +    public boolean contains(String name) {
    6.85 +        int i = name.lastIndexOf('/');
    6.86 +        String dirname = name.substring(0, i+1);
    6.87 +        String basename = name.substring(i+1);
    6.88 +        if (basename.length() == 0)
    6.89 +            return false;
    6.90 +        List<String> list = map.get(dirname);
    6.91 +        return (list != null && list.contains(basename));
    6.92 +    }
    6.93 +
    6.94 +    public List<String> getFiles(String subdirectory) {
    6.95 +        return map.get(subdirectory);
    6.96 +    }
    6.97 +
    6.98 +    public JavaFileObject getFileObject(String subdirectory, String file) {
    6.99 +        ZipEntry ze = zdir.getEntry(subdirectory + file);
   6.100 +        return new ZipFileObject(this, file, ze);
   6.101 +    }
   6.102 +
   6.103 +    public Set<String> getSubdirectories() {
   6.104 +        return map.keySet();
   6.105 +    }
   6.106 +
   6.107 +    public void close() throws IOException {
   6.108 +        zdir.close();
   6.109 +    }
   6.110 +
   6.111 +    protected JavacFileManager fileManager;
   6.112 +    protected final Map<String,List<String>> map;
   6.113 +    protected final ZipFile zdir;
   6.114 +
   6.115 +    /**
   6.116 +     * A subclass of JavaFileObject representing zip entries.
   6.117 +     */
   6.118 +    public static class ZipFileObject extends BaseFileObject {
   6.119 +
   6.120 +        private String name;
   6.121 +        ZipArchive zarch;
   6.122 +        ZipEntry entry;
   6.123 +
   6.124 +        public ZipFileObject(ZipArchive zarch, String name, ZipEntry entry) {
   6.125 +            super(zarch.fileManager);
   6.126 +            this.zarch = zarch;
   6.127 +            this.name = name;
   6.128 +            this.entry = entry;
   6.129 +        }
   6.130 +
   6.131 +        public InputStream openInputStream() throws IOException {
   6.132 +            return zarch.zdir.getInputStream(entry);
   6.133 +        }
   6.134 +
   6.135 +        public OutputStream openOutputStream() throws IOException {
   6.136 +            throw new UnsupportedOperationException();
   6.137 +        }
   6.138 +
   6.139 +        protected CharsetDecoder getDecoder(boolean ignoreEncodingErrors) {
   6.140 +            return fileManager.getDecoder(fileManager.getEncodingName(), ignoreEncodingErrors);
   6.141 +        }
   6.142 +
   6.143 +        public Writer openWriter() throws IOException {
   6.144 +            throw new UnsupportedOperationException();
   6.145 +        }
   6.146 +
   6.147 +        @Deprecated
   6.148 +        public String getName() {
   6.149 +            return name;
   6.150 +        }
   6.151 +
   6.152 +        public boolean isNameCompatible(String cn, JavaFileObject.Kind k) {
   6.153 +            cn.getClass();
   6.154 +            // null check
   6.155 +            if (k == Kind.OTHER && getKind() != k) {
   6.156 +                return false;
   6.157 +            }
   6.158 +            return name.equals(cn + k.extension);
   6.159 +        }
   6.160 +
   6.161 +        @Deprecated
   6.162 +        public String getPath() {
   6.163 +            return zarch.zdir.getName() + "(" + entry + ")";
   6.164 +        }
   6.165 +
   6.166 +        public long getLastModified() {
   6.167 +            return entry.getTime();
   6.168 +        }
   6.169 +
   6.170 +        public boolean delete() {
   6.171 +            throw new UnsupportedOperationException();
   6.172 +        }
   6.173 +
   6.174 +        public CharBuffer getCharContent(boolean ignoreEncodingErrors) throws IOException {
   6.175 +            CharBuffer cb = fileManager.getCachedContent(this);
   6.176 +            if (cb == null) {
   6.177 +                InputStream in = zarch.zdir.getInputStream(entry);
   6.178 +                try {
   6.179 +                    ByteBuffer bb = fileManager.makeByteBuffer(in);
   6.180 +                    JavaFileObject prev = fileManager.log.useSource(this);
   6.181 +                    try {
   6.182 +                        cb = fileManager.decode(bb, ignoreEncodingErrors);
   6.183 +                    } finally {
   6.184 +                        fileManager.log.useSource(prev);
   6.185 +                    }
   6.186 +                    fileManager.recycleByteBuffer(bb);
   6.187 +                    if (!ignoreEncodingErrors) {
   6.188 +                        fileManager.cache(this, cb);
   6.189 +                    }
   6.190 +                } finally {
   6.191 +                    in.close();
   6.192 +                }
   6.193 +            }
   6.194 +            return cb;
   6.195 +        }
   6.196 +
   6.197 +        @Override
   6.198 +        public boolean equals(Object other) {
   6.199 +            if (!(other instanceof ZipFileObject)) {
   6.200 +                return false;
   6.201 +            }
   6.202 +            ZipFileObject o = (ZipFileObject) other;
   6.203 +            return zarch.zdir.equals(o.zarch.zdir) || name.equals(o.name);
   6.204 +        }
   6.205 +
   6.206 +        @Override
   6.207 +        public int hashCode() {
   6.208 +            return zarch.zdir.hashCode() + name.hashCode();
   6.209 +        }
   6.210 +
   6.211 +        public String getZipName() {
   6.212 +            return zarch.zdir.getName();
   6.213 +        }
   6.214 +
   6.215 +        public String getZipEntryName() {
   6.216 +            return entry.getName();
   6.217 +        }
   6.218 +
   6.219 +        public URI toUri() {
   6.220 +            String zipName = new File(getZipName()).toURI().normalize().getPath();
   6.221 +            String entryName = getZipEntryName();
   6.222 +            return URI.create("jar:" + zipName + "!" + entryName);
   6.223 +        }
   6.224 +
   6.225 +        @Override
   6.226 +        protected String inferBinaryName(Iterable<? extends File> path) {
   6.227 +            String entryName = getZipEntryName();
   6.228 +            if (zarch instanceof SymbolArchive) {
   6.229 +                String prefix = ((SymbolArchive) zarch).prefix;
   6.230 +                if (entryName.startsWith(prefix))
   6.231 +                    entryName = entryName.substring(prefix.length());
   6.232 +            }
   6.233 +            return removeExtension(entryName).replace('/', '.');
   6.234 +        }
   6.235 +    }
   6.236 +
   6.237 +}
     7.1 --- a/src/share/classes/com/sun/tools/javac/file/ZipFileIndex.java	Fri Jun 20 16:36:18 2008 -0700
     7.2 +++ b/src/share/classes/com/sun/tools/javac/file/ZipFileIndex.java	Wed Jun 25 23:30:55 2008 -0700
     7.3 @@ -81,11 +81,12 @@
     7.4      private File zipFile;
     7.5      private long zipFileLastModified = NOT_MODIFIED;
     7.6      private RandomAccessFile zipRandomFile;
     7.7 -    private ZipFileIndexEntry[] entries;
     7.8 +    private Entry[] entries;
     7.9  
    7.10      private boolean readFromIndex = false;
    7.11      private File zipIndexFile = null;
    7.12      private boolean triedToReadIndex = false;
    7.13 +    final String symbolFilePrefix;
    7.14      private int symbolFilePrefixLength = 0;
    7.15      private boolean hasPopulatedData = false;
    7.16      private long lastReferenceTimeStamp = NOT_MODIFIED;
    7.17 @@ -141,14 +142,14 @@
    7.18          }
    7.19      }
    7.20  
    7.21 -    public static ZipFileIndex getZipFileIndex(File zipFile, int symbolFilePrefixLen, boolean useCache, String cacheLocation, boolean writeIndex) throws IOException {
    7.22 +    public static ZipFileIndex getZipFileIndex(File zipFile, String symbolFilePrefix, boolean useCache, String cacheLocation, boolean writeIndex) throws IOException {
    7.23          ZipFileIndex zi = null;
    7.24          lock.lock();
    7.25          try {
    7.26              zi = getExistingZipIndex(zipFile);
    7.27  
    7.28              if (zi == null || (zi != null && zipFile.lastModified() != zi.zipFileLastModified)) {
    7.29 -                zi = new ZipFileIndex(zipFile, symbolFilePrefixLen, writeIndex,
    7.30 +                zi = new ZipFileIndex(zipFile, symbolFilePrefix, writeIndex,
    7.31                          useCache, cacheLocation);
    7.32                  zipFileIndexCache.put(zipFile, zi);
    7.33              }
    7.34 @@ -229,10 +230,12 @@
    7.35          }
    7.36      }
    7.37  
    7.38 -    private ZipFileIndex(File zipFile, int symbolFilePrefixLen, boolean writeIndex,
    7.39 +    private ZipFileIndex(File zipFile, String symbolFilePrefix, boolean writeIndex,
    7.40              boolean useCache, String cacheLocation) throws IOException {
    7.41          this.zipFile = zipFile;
    7.42 -        this.symbolFilePrefixLength = symbolFilePrefixLen;
    7.43 +        this.symbolFilePrefix = symbolFilePrefix;
    7.44 +        this.symbolFilePrefixLength = (symbolFilePrefix == null ? 0 :
    7.45 +            symbolFilePrefix.getBytes("UTF-8").length);
    7.46          this.writeIndex = writeIndex;
    7.47          this.usePreindexedCache = useCache;
    7.48          this.preindexedCacheLocation = cacheLocation;
    7.49 @@ -312,7 +315,7 @@
    7.50  
    7.51      private void cleanupState() {
    7.52          // Make sure there is a valid but empty index if the file doesn't exist
    7.53 -        entries = ZipFileIndexEntry.EMPTY_ARRAY;
    7.54 +        entries = Entry.EMPTY_ARRAY;
    7.55          directories = Collections.<String, DirectoryEntry>emptyMap();
    7.56          zipFileLastModified = NOT_MODIFIED;
    7.57          allDirs = Collections.<String>emptySet();
    7.58 @@ -342,7 +345,7 @@
    7.59      /**
    7.60       * Returns the ZipFileIndexEntry for an absolute path, if there is one.
    7.61       */
    7.62 -    public ZipFileIndexEntry getZipIndexEntry(String path) {
    7.63 +    Entry getZipIndexEntry(String path) {
    7.64          if (File.separatorChar != '/') {
    7.65              path = path.replace('/', File.separatorChar);
    7.66          }
    7.67 @@ -493,7 +496,7 @@
    7.68      public long getLastModified(String path) throws IOException {
    7.69          lock.lock();
    7.70          try {
    7.71 -            ZipFileIndexEntry entry = getZipIndexEntry(path);
    7.72 +            Entry entry = getZipIndexEntry(path);
    7.73              if (entry == null)
    7.74                  throw new FileNotFoundException();
    7.75              return entry.getLastModified();
    7.76 @@ -506,7 +509,7 @@
    7.77      public int length(String path) throws IOException {
    7.78          lock.lock();
    7.79          try {
    7.80 -            ZipFileIndexEntry entry = getZipIndexEntry(path);
    7.81 +            Entry entry = getZipIndexEntry(path);
    7.82              if (entry == null)
    7.83                  throw new FileNotFoundException();
    7.84  
    7.85 @@ -530,7 +533,7 @@
    7.86      public byte[] read(String path) throws IOException {
    7.87          lock.lock();
    7.88          try {
    7.89 -            ZipFileIndexEntry entry = getZipIndexEntry(path);
    7.90 +            Entry entry = getZipIndexEntry(path);
    7.91              if (entry == null)
    7.92                  throw new FileNotFoundException(MessageFormat.format("Path not found in ZIP: {0}", path));
    7.93              return read(entry);
    7.94 @@ -540,7 +543,7 @@
    7.95          }
    7.96      }
    7.97  
    7.98 -    public byte[] read(ZipFileIndexEntry entry) throws IOException {
    7.99 +    byte[] read(Entry entry) throws IOException {
   7.100          lock.lock();
   7.101          try {
   7.102              openFile();
   7.103 @@ -556,7 +559,7 @@
   7.104      public int read(String path, byte[] buffer) throws IOException {
   7.105          lock.lock();
   7.106          try {
   7.107 -            ZipFileIndexEntry entry = getZipIndexEntry(path);
   7.108 +            Entry entry = getZipIndexEntry(path);
   7.109              if (entry == null)
   7.110                  throw new FileNotFoundException();
   7.111              return read(entry, buffer);
   7.112 @@ -566,7 +569,7 @@
   7.113          }
   7.114      }
   7.115  
   7.116 -    public int read(ZipFileIndexEntry entry, byte[] buffer)
   7.117 +    int read(Entry entry, byte[] buffer)
   7.118              throws IOException {
   7.119          lock.lock();
   7.120          try {
   7.121 @@ -578,7 +581,7 @@
   7.122          }
   7.123      }
   7.124  
   7.125 -    private byte[] readBytes(ZipFileIndexEntry entry) throws IOException {
   7.126 +    private byte[] readBytes(Entry entry) throws IOException {
   7.127          byte[] header = getHeader(entry);
   7.128          int csize = entry.compressedSize;
   7.129          byte[] cbuf = new byte[csize];
   7.130 @@ -600,7 +603,7 @@
   7.131      /**
   7.132       *
   7.133       */
   7.134 -    private int readBytes(ZipFileIndexEntry entry, byte[] buffer) throws IOException {
   7.135 +    private int readBytes(Entry entry, byte[] buffer) throws IOException {
   7.136          byte[] header = getHeader(entry);
   7.137  
   7.138          // entry is not compressed?
   7.139 @@ -633,7 +636,7 @@
   7.140      // Zip utilities
   7.141      //----------------------------------------------------------------------------
   7.142  
   7.143 -    private byte[] getHeader(ZipFileIndexEntry entry) throws IOException {
   7.144 +    private byte[] getHeader(Entry entry) throws IOException {
   7.145          zipRandomFile.seek(entry.offset);
   7.146          byte[] header = new byte[30];
   7.147          zipRandomFile.readFully(header);
   7.148 @@ -746,11 +749,11 @@
   7.149          private void buildIndex() throws IOException {
   7.150              int entryCount = get2ByteLittleEndian(zipDir, 0);
   7.151  
   7.152 -            entries = new ZipFileIndexEntry[entryCount];
   7.153 +            entries = new Entry[entryCount];
   7.154              // Add each of the files
   7.155              if (entryCount > 0) {
   7.156                  directories = new HashMap<String, DirectoryEntry>();
   7.157 -                ArrayList<ZipFileIndexEntry> entryList = new ArrayList<ZipFileIndexEntry>();
   7.158 +                ArrayList<Entry> entryList = new ArrayList<Entry>();
   7.159                  int pos = 2;
   7.160                  for (int i = 0; i < entryCount; i++) {
   7.161                      pos = readEntry(pos, entryList, directories);
   7.162 @@ -759,19 +762,19 @@
   7.163                  // Add the accumulated dirs into the same list
   7.164                  Iterator i = directories.keySet().iterator();
   7.165                  while (i.hasNext()) {
   7.166 -                    ZipFileIndexEntry zipFileIndexEntry = new ZipFileIndexEntry( (String) i.next());
   7.167 +                    Entry zipFileIndexEntry = new Entry( (String) i.next());
   7.168                      zipFileIndexEntry.isDir = true;
   7.169                      entryList.add(zipFileIndexEntry);
   7.170                  }
   7.171  
   7.172 -                entries = entryList.toArray(new ZipFileIndexEntry[entryList.size()]);
   7.173 +                entries = entryList.toArray(new Entry[entryList.size()]);
   7.174                  Arrays.sort(entries);
   7.175              } else {
   7.176                  cleanupState();
   7.177              }
   7.178          }
   7.179  
   7.180 -        private int readEntry(int pos, List<ZipFileIndexEntry> entryList,
   7.181 +        private int readEntry(int pos, List<Entry> entryList,
   7.182                  Map<String, DirectoryEntry> directories) throws IOException {
   7.183              if (get4ByteLittleEndian(zipDir, pos) != 0x02014b50) {
   7.184                  throw new ZipException("cannot read zip file entry");
   7.185 @@ -838,7 +841,7 @@
   7.186  
   7.187              // For each dir create also a file
   7.188              if (fileStart != fileEnd) {
   7.189 -                ZipFileIndexEntry entry = new ZipFileIndexEntry(directory,
   7.190 +                Entry entry = new Entry(directory,
   7.191                          new String(zipDir, fileStart, fileEnd - fileStart, "UTF-8"));
   7.192  
   7.193                  entry.setNativeTime(get4ByteLittleEndian(zipDir, pos + 12));
   7.194 @@ -873,6 +876,7 @@
   7.195      /** ------------------------------------------------------------------------
   7.196       *  DirectoryEntry class
   7.197       * -------------------------------------------------------------------------*/
   7.198 +
   7.199      static class DirectoryEntry {
   7.200          private boolean filesInited;
   7.201          private boolean directoriesInited;
   7.202 @@ -885,9 +889,9 @@
   7.203  
   7.204          private com.sun.tools.javac.util.List<String> zipFileEntriesFiles = com.sun.tools.javac.util.List.<String>nil();
   7.205          private com.sun.tools.javac.util.List<String> zipFileEntriesDirectories = com.sun.tools.javac.util.List.<String>nil();
   7.206 -        private com.sun.tools.javac.util.List<ZipFileIndexEntry>  zipFileEntries = com.sun.tools.javac.util.List.<ZipFileIndexEntry>nil();
   7.207 +        private com.sun.tools.javac.util.List<Entry>  zipFileEntries = com.sun.tools.javac.util.List.<Entry>nil();
   7.208  
   7.209 -        private List<ZipFileIndexEntry> entries = new ArrayList<ZipFileIndexEntry>();
   7.210 +        private List<Entry> entries = new ArrayList<Entry>();
   7.211  
   7.212          private ZipFileIndex zipFileIndex;
   7.213  
   7.214 @@ -916,7 +920,7 @@
   7.215  
   7.216              initEntries();
   7.217  
   7.218 -            for (ZipFileIndexEntry e : entries) {
   7.219 +            for (Entry e : entries) {
   7.220                  if (!e.isDir) {
   7.221                      zipFileEntriesFiles = zipFileEntriesFiles.append(e.name);
   7.222                  }
   7.223 @@ -932,7 +936,7 @@
   7.224  
   7.225              initEntries();
   7.226  
   7.227 -            for (ZipFileIndexEntry e : entries) {
   7.228 +            for (Entry e : entries) {
   7.229                  if (e.isDir) {
   7.230                      zipFileEntriesDirectories = zipFileEntriesDirectories.append(e.name);
   7.231                  }
   7.232 @@ -943,7 +947,7 @@
   7.233              return zipFileEntriesDirectories;
   7.234          }
   7.235  
   7.236 -        private com.sun.tools.javac.util.List<ZipFileIndexEntry> getEntries() {
   7.237 +        private com.sun.tools.javac.util.List<Entry> getEntries() {
   7.238              if (zipFileEntriesInited) {
   7.239                  return zipFileEntries;
   7.240              }
   7.241 @@ -951,7 +955,7 @@
   7.242              initEntries();
   7.243  
   7.244              zipFileEntries = com.sun.tools.javac.util.List.nil();
   7.245 -            for (ZipFileIndexEntry zfie : entries) {
   7.246 +            for (Entry zfie : entries) {
   7.247                  zipFileEntries = zipFileEntries.append(zfie);
   7.248              }
   7.249  
   7.250 @@ -960,9 +964,9 @@
   7.251              return zipFileEntries;
   7.252          }
   7.253  
   7.254 -        private ZipFileIndexEntry getEntry(String rootName) {
   7.255 +        private Entry getEntry(String rootName) {
   7.256              initEntries();
   7.257 -            int index = Collections.binarySearch(entries, new ZipFileIndexEntry(dirName, rootName));
   7.258 +            int index = Collections.binarySearch(entries, new Entry(dirName, rootName));
   7.259              if (index < 0) {
   7.260                  return null;
   7.261              }
   7.262 @@ -977,9 +981,9 @@
   7.263  
   7.264              if (!zipFileIndex.readFromIndex) {
   7.265                  int from = -Arrays.binarySearch(zipFileIndex.entries,
   7.266 -                        new ZipFileIndexEntry(dirName, ZipFileIndex.MIN_CHAR)) - 1;
   7.267 +                        new Entry(dirName, ZipFileIndex.MIN_CHAR)) - 1;
   7.268                  int to = -Arrays.binarySearch(zipFileIndex.entries,
   7.269 -                        new ZipFileIndexEntry(dirName, MAX_CHAR)) - 1;
   7.270 +                        new Entry(dirName, MAX_CHAR)) - 1;
   7.271  
   7.272                  boolean emptyList = false;
   7.273  
   7.274 @@ -1016,7 +1020,7 @@
   7.275                              // Read java time stamp of the file in the real Jar/Zip file
   7.276                              long eJavaTimestamp = raf.readLong();
   7.277  
   7.278 -                            ZipFileIndexEntry rfie = new ZipFileIndexEntry(dirName, eName);
   7.279 +                            Entry rfie = new Entry(dirName, eName);
   7.280                              rfie.isDir = eIsDir;
   7.281                              rfie.offset = eOffset;
   7.282                              rfie.size = eSize;
   7.283 @@ -1041,7 +1045,7 @@
   7.284              entriesInited = true;
   7.285          }
   7.286  
   7.287 -        List<ZipFileIndexEntry> getEntriesAsCollection() {
   7.288 +        List<Entry> getEntriesAsCollection() {
   7.289              initEntries();
   7.290  
   7.291              return entries;
   7.292 @@ -1173,8 +1177,8 @@
   7.293                  raf.seek(currFP);
   7.294  
   7.295                  // Now write each of the files in the DirectoryEntry
   7.296 -                List<ZipFileIndexEntry> entries = de.getEntriesAsCollection();
   7.297 -                for (ZipFileIndexEntry zfie : entries) {
   7.298 +                List<Entry> entries = de.getEntriesAsCollection();
   7.299 +                for (Entry zfie : entries) {
   7.300                      // Write the name bytes
   7.301                      byte [] zfieNameBytes = zfie.name.getBytes("UTF-8");
   7.302                      int zfieNameBytesLen = zfieNameBytes.length;
   7.303 @@ -1245,4 +1249,94 @@
   7.304      public File getZipFile() {
   7.305          return zipFile;
   7.306      }
   7.307 +
   7.308 +
   7.309 +    static class Entry implements Comparable<Entry> {
   7.310 +        public static final Entry[] EMPTY_ARRAY = {};
   7.311 +
   7.312 +        // Directory related
   7.313 +        String dir;
   7.314 +        boolean isDir;
   7.315 +
   7.316 +        // File related
   7.317 +        String name;
   7.318 +
   7.319 +        int offset;
   7.320 +        int size;
   7.321 +        int compressedSize;
   7.322 +        long javatime;
   7.323 +
   7.324 +        private int nativetime;
   7.325 +
   7.326 +        public Entry(String path) {
   7.327 +            int separator = path.lastIndexOf(File.separatorChar);
   7.328 +            if (separator == -1) {
   7.329 +                dir = "".intern();
   7.330 +                name = path;
   7.331 +            } else {
   7.332 +                dir = path.substring(0, separator).intern();
   7.333 +                name = path.substring(separator + 1);
   7.334 +            }
   7.335 +        }
   7.336 +
   7.337 +        public Entry(String directory, String name) {
   7.338 +            this.dir = directory.intern();
   7.339 +            this.name = name;
   7.340 +        }
   7.341 +
   7.342 +        public String getName() {
   7.343 +            if (dir == null || dir.length() == 0) {
   7.344 +                return name;
   7.345 +            }
   7.346 +
   7.347 +            StringBuilder sb = new StringBuilder();
   7.348 +            sb.append(dir);
   7.349 +            sb.append(File.separatorChar);
   7.350 +            sb.append(name);
   7.351 +            return sb.toString();
   7.352 +        }
   7.353 +
   7.354 +        public String getFileName() {
   7.355 +            return name;
   7.356 +        }
   7.357 +
   7.358 +        public long getLastModified() {
   7.359 +            if (javatime == 0) {
   7.360 +                    javatime = dosToJavaTime(nativetime);
   7.361 +            }
   7.362 +            return javatime;
   7.363 +        }
   7.364 +
   7.365 +        // From java.util.zip
   7.366 +        private static long dosToJavaTime(int nativetime) {
   7.367 +            // Bootstrap build problems prevent me from using the code directly
   7.368 +            // Convert the raw/native time to a long for now
   7.369 +            return (long)nativetime;
   7.370 +        }
   7.371 +
   7.372 +        void setNativeTime(int natTime) {
   7.373 +            nativetime = natTime;
   7.374 +        }
   7.375 +
   7.376 +        public boolean isDirectory() {
   7.377 +            return isDir;
   7.378 +        }
   7.379 +
   7.380 +        public int compareTo(Entry other) {
   7.381 +            String otherD = other.dir;
   7.382 +            if (dir != otherD) {
   7.383 +                int c = dir.compareTo(otherD);
   7.384 +                if (c != 0)
   7.385 +                    return c;
   7.386 +            }
   7.387 +            return name.compareTo(other.name);
   7.388 +        }
   7.389 +
   7.390 +
   7.391 +        public String toString() {
   7.392 +            return isDir ? ("Dir:" + dir + " : " + name) :
   7.393 +                (dir + ":" + name);
   7.394 +        }
   7.395 +    }
   7.396 +
   7.397  }
     8.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     8.2 +++ b/src/share/classes/com/sun/tools/javac/file/ZipFileIndexArchive.java	Wed Jun 25 23:30:55 2008 -0700
     8.3 @@ -0,0 +1,233 @@
     8.4 +/*
     8.5 + * Copyright 2005-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.IOException;
    8.32 +import java.util.Set;
    8.33 +import javax.tools.JavaFileObject;
    8.34 +
    8.35 +import com.sun.tools.javac.file.JavacFileManager.Archive;
    8.36 +import com.sun.tools.javac.util.List;
    8.37 +import java.io.ByteArrayInputStream;
    8.38 +import java.io.File;
    8.39 +import java.io.FileNotFoundException;
    8.40 +import java.io.InputStream;
    8.41 +import java.io.OutputStream;
    8.42 +import java.io.Writer;
    8.43 +import java.net.URI;
    8.44 +import java.nio.ByteBuffer;
    8.45 +import java.nio.CharBuffer;
    8.46 +import java.nio.charset.CharsetDecoder;
    8.47 +
    8.48 +public class ZipFileIndexArchive implements Archive {
    8.49 +
    8.50 +    private final ZipFileIndex zfIndex;
    8.51 +    private JavacFileManager fileManager;
    8.52 +
    8.53 +    public ZipFileIndexArchive(JavacFileManager fileManager, ZipFileIndex zdir) throws IOException {
    8.54 +        super();
    8.55 +        this.fileManager = fileManager;
    8.56 +        this.zfIndex = zdir;
    8.57 +    }
    8.58 +
    8.59 +    public boolean contains(String name) {
    8.60 +        return zfIndex.contains(name);
    8.61 +    }
    8.62 +
    8.63 +    public List<String> getFiles(String subdirectory) {
    8.64 +        return zfIndex.getFiles((subdirectory.endsWith("/") || subdirectory.endsWith("\\")) ? subdirectory.substring(0, subdirectory.length() - 1) : subdirectory);
    8.65 +    }
    8.66 +
    8.67 +    public JavaFileObject getFileObject(String subdirectory, String file) {
    8.68 +        String fullZipFileName = subdirectory + file;
    8.69 +        ZipFileIndex.Entry entry = zfIndex.getZipIndexEntry(fullZipFileName);
    8.70 +        JavaFileObject ret = new ZipFileIndexFileObject(fileManager, zfIndex, entry, zfIndex.getZipFile().getPath());
    8.71 +        return ret;
    8.72 +    }
    8.73 +
    8.74 +    public Set<String> getSubdirectories() {
    8.75 +        return zfIndex.getAllDirectories();
    8.76 +    }
    8.77 +
    8.78 +    public void close() throws IOException {
    8.79 +        zfIndex.close();
    8.80 +    }
    8.81 +
    8.82 +    /**
    8.83 +     * A subclass of JavaFileObject representing zip entries using the com.sun.tools.javac.file.ZipFileIndex implementation.
    8.84 +     */
    8.85 +    public static class ZipFileIndexFileObject extends BaseFileObject {
    8.86 +
    8.87 +        /** The entry's name.
    8.88 +         */
    8.89 +        private String name;
    8.90 +
    8.91 +        /** The zipfile containing the entry.
    8.92 +         */
    8.93 +        ZipFileIndex zfIndex;
    8.94 +
    8.95 +        /** The underlying zip entry object.
    8.96 +         */
    8.97 +        ZipFileIndex.Entry entry;
    8.98 +
    8.99 +        /** The InputStream for this zip entry (file.)
   8.100 +         */
   8.101 +        InputStream inputStream = null;
   8.102 +
   8.103 +        /** The name of the zip file where this entry resides.
   8.104 +         */
   8.105 +        String zipName;
   8.106 +
   8.107 +
   8.108 +        ZipFileIndexFileObject(JavacFileManager fileManager, ZipFileIndex zfIndex, ZipFileIndex.Entry entry, String zipFileName) {
   8.109 +            super(fileManager);
   8.110 +            this.name = entry.getFileName();
   8.111 +            this.zfIndex = zfIndex;
   8.112 +            this.entry = entry;
   8.113 +            this.zipName = zipFileName;
   8.114 +        }
   8.115 +
   8.116 +        public InputStream openInputStream() throws IOException {
   8.117 +
   8.118 +            if (inputStream == null) {
   8.119 +                inputStream = new ByteArrayInputStream(read());
   8.120 +            }
   8.121 +            return inputStream;
   8.122 +        }
   8.123 +
   8.124 +        protected CharsetDecoder getDecoder(boolean ignoreEncodingErrors) {
   8.125 +            return fileManager.getDecoder(fileManager.getEncodingName(), ignoreEncodingErrors);
   8.126 +        }
   8.127 +
   8.128 +        public OutputStream openOutputStream() throws IOException {
   8.129 +            throw new UnsupportedOperationException();
   8.130 +        }
   8.131 +
   8.132 +        public Writer openWriter() throws IOException {
   8.133 +            throw new UnsupportedOperationException();
   8.134 +        }
   8.135 +
   8.136 +        /** @deprecated see bug 6410637 */
   8.137 +        @Deprecated
   8.138 +        public String getName() {
   8.139 +            return name;
   8.140 +        }
   8.141 +
   8.142 +        public boolean isNameCompatible(String cn, JavaFileObject.Kind k) {
   8.143 +            cn.getClass(); // null check
   8.144 +            if (k == Kind.OTHER && getKind() != k)
   8.145 +                return false;
   8.146 +            return name.equals(cn + k.extension);
   8.147 +        }
   8.148 +
   8.149 +        /** @deprecated see bug 6410637 */
   8.150 +        @Deprecated
   8.151 +        public String getPath() {
   8.152 +            return zipName + "(" + entry.getName() + ")";
   8.153 +        }
   8.154 +
   8.155 +        public long getLastModified() {
   8.156 +            return entry.getLastModified();
   8.157 +        }
   8.158 +
   8.159 +        public boolean delete() {
   8.160 +            throw new UnsupportedOperationException();
   8.161 +        }
   8.162 +
   8.163 +        @Override
   8.164 +        public boolean equals(Object other) {
   8.165 +            if (!(other instanceof ZipFileIndexFileObject))
   8.166 +                return false;
   8.167 +            ZipFileIndexFileObject o = (ZipFileIndexFileObject) other;
   8.168 +            return entry.equals(o.entry);
   8.169 +        }
   8.170 +
   8.171 +        @Override
   8.172 +        public int hashCode() {
   8.173 +            return zipName.hashCode() + (name.hashCode() << 10);
   8.174 +        }
   8.175 +
   8.176 +        public String getZipName() {
   8.177 +            return zipName;
   8.178 +        }
   8.179 +
   8.180 +        public String getZipEntryName() {
   8.181 +            return entry.getName();
   8.182 +        }
   8.183 +
   8.184 +        public URI toUri() {
   8.185 +            String zipName = new File(getZipName()).toURI().normalize().getPath();
   8.186 +            String entryName = getZipEntryName();
   8.187 +            if (File.separatorChar != '/') {
   8.188 +                entryName = entryName.replace(File.separatorChar, '/');
   8.189 +            }
   8.190 +            return URI.create("jar:" + zipName + "!" + entryName);
   8.191 +        }
   8.192 +
   8.193 +        private byte[] read() throws IOException {
   8.194 +            if (entry == null) {
   8.195 +                entry = zfIndex.getZipIndexEntry(name);
   8.196 +                if (entry == null)
   8.197 +                  throw new FileNotFoundException();
   8.198 +            }
   8.199 +            return zfIndex.read(entry);
   8.200 +        }
   8.201 +
   8.202 +        public CharBuffer getCharContent(boolean ignoreEncodingErrors) throws IOException {
   8.203 +            CharBuffer cb = fileManager.getCachedContent(this);
   8.204 +            if (cb == null) {
   8.205 +                InputStream in = new ByteArrayInputStream(zfIndex.read(entry));
   8.206 +                try {
   8.207 +                    ByteBuffer bb = fileManager.makeByteBuffer(in);
   8.208 +                    JavaFileObject prev = fileManager.log.useSource(this);
   8.209 +                    try {
   8.210 +                        cb = fileManager.decode(bb, ignoreEncodingErrors);
   8.211 +                    } finally {
   8.212 +                        fileManager.log.useSource(prev);
   8.213 +                    }
   8.214 +                    fileManager.recycleByteBuffer(bb); // save for next time
   8.215 +                    if (!ignoreEncodingErrors)
   8.216 +                        fileManager.cache(this, cb);
   8.217 +                } finally {
   8.218 +                    in.close();
   8.219 +                }
   8.220 +            }
   8.221 +            return cb;
   8.222 +        }
   8.223 +
   8.224 +        @Override
   8.225 +        protected String inferBinaryName(Iterable<? extends File> path) {
   8.226 +            String entryName = getZipEntryName();
   8.227 +            if (zfIndex.symbolFilePrefix != null) {
   8.228 +                String prefix = zfIndex.symbolFilePrefix;
   8.229 +                if (entryName.startsWith(prefix))
   8.230 +                    entryName = entryName.substring(prefix.length());
   8.231 +            }
   8.232 +            return removeExtension(entryName).replace(File.separatorChar, '.');
   8.233 +        }
   8.234 +    }
   8.235 +
   8.236 +}
     9.1 --- a/src/share/classes/com/sun/tools/javac/file/ZipFileIndexEntry.java	Fri Jun 20 16:36:18 2008 -0700
     9.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     9.3 @@ -1,116 +0,0 @@
     9.4 -/*
     9.5 - * Copyright 2007-2008 Sun Microsystems, Inc.  All Rights Reserved.
     9.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     9.7 - *
     9.8 - * This code is free software; you can redistribute it and/or modify it
     9.9 - * under the terms of the GNU General Public License version 2 only, as
    9.10 - * published by the Free Software Foundation.  Sun designates this
    9.11 - * particular file as subject to the "Classpath" exception as provided
    9.12 - * by Sun in the LICENSE file that accompanied this code.
    9.13 - *
    9.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
    9.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    9.16 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    9.17 - * version 2 for more details (a copy is included in the LICENSE file that
    9.18 - * accompanied this code).
    9.19 - *
    9.20 - * You should have received a copy of the GNU General Public License version
    9.21 - * 2 along with this work; if not, write to the Free Software Foundation,
    9.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    9.23 - *
    9.24 - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
    9.25 - * CA 95054 USA or visit www.sun.com if you need additional information or
    9.26 - * have any questions.
    9.27 - */
    9.28 -
    9.29 -package com.sun.tools.javac.file;
    9.30 -
    9.31 -import java.io.File;
    9.32 -
    9.33 -public final class ZipFileIndexEntry implements Comparable<ZipFileIndexEntry> {
    9.34 -    public static final ZipFileIndexEntry[] EMPTY_ARRAY = {};
    9.35 -
    9.36 -    // Directory related
    9.37 -    String dir;
    9.38 -    boolean isDir;
    9.39 -
    9.40 -    // File related
    9.41 -    String name;
    9.42 -
    9.43 -    int offset;
    9.44 -    int size;
    9.45 -    int compressedSize;
    9.46 -    long javatime;
    9.47 -
    9.48 -    private int nativetime;
    9.49 -
    9.50 -    public ZipFileIndexEntry(String path) {
    9.51 -        int separator = path.lastIndexOf(File.separatorChar);
    9.52 -        if (separator == -1) {
    9.53 -            dir = "".intern();
    9.54 -            name = path;
    9.55 -        } else {
    9.56 -            dir = path.substring(0, separator).intern();
    9.57 -            name = path.substring(separator + 1);
    9.58 -        }
    9.59 -    }
    9.60 -
    9.61 -    public ZipFileIndexEntry(String directory, String name) {
    9.62 -        this.dir = directory.intern();
    9.63 -        this.name = name;
    9.64 -    }
    9.65 -
    9.66 -    public String getName() {
    9.67 -        if (dir == null || dir.length() == 0) {
    9.68 -            return name;
    9.69 -        }
    9.70 -
    9.71 -        StringBuilder sb = new StringBuilder();
    9.72 -        sb.append(dir);
    9.73 -        sb.append(File.separatorChar);
    9.74 -        sb.append(name);
    9.75 -        return sb.toString();
    9.76 -    }
    9.77 -
    9.78 -    public String getFileName() {
    9.79 -        return name;
    9.80 -    }
    9.81 -
    9.82 -    public long getLastModified() {
    9.83 -        if (javatime == 0) {
    9.84 -                javatime = dosToJavaTime(nativetime);
    9.85 -        }
    9.86 -        return javatime;
    9.87 -    }
    9.88 -
    9.89 -    // From java.util.zip
    9.90 -    private static long dosToJavaTime(int nativetime) {
    9.91 -        // Bootstrap build problems prevent me from using the code directly
    9.92 -        // Convert the raw/native time to a long for now
    9.93 -        return (long)nativetime;
    9.94 -    }
    9.95 -
    9.96 -    void setNativeTime(int natTime) {
    9.97 -        nativetime = natTime;
    9.98 -    }
    9.99 -
   9.100 -    public boolean isDirectory() {
   9.101 -        return isDir;
   9.102 -    }
   9.103 -
   9.104 -    public int compareTo(ZipFileIndexEntry other) {
   9.105 -        String otherD = other.dir;
   9.106 -        if (dir != otherD) {
   9.107 -            int c = dir.compareTo(otherD);
   9.108 -            if (c != 0)
   9.109 -                return c;
   9.110 -        }
   9.111 -        return name.compareTo(other.name);
   9.112 -    }
   9.113 -
   9.114 -
   9.115 -    public String toString() {
   9.116 -        return isDir ? ("Dir:" + dir + " : " + name) :
   9.117 -            (dir + ":" + name);
   9.118 -    }
   9.119 -}
    10.1 --- a/src/share/classes/com/sun/tools/javac/jvm/ClassReader.java	Fri Jun 20 16:36:18 2008 -0700
    10.2 +++ b/src/share/classes/com/sun/tools/javac/jvm/ClassReader.java	Wed Jun 25 23:30:55 2008 -0700
    10.3 @@ -1056,7 +1056,7 @@
    10.4      void readClassAttr(ClassSymbol c, Name attrName, int attrLen) {
    10.5          if (attrName == names.SourceFile) {
    10.6              Name n = readName(nextChar());
    10.7 -            c.sourcefile = new SourceFileObject(n);
    10.8 +            c.sourcefile = new SourceFileObject(n, c.flatname);
    10.9          } else if (attrName == names.InnerClasses) {
   10.10              readInnerClasses(c);
   10.11          } else if (allowGenerics && attrName == names.Signature) {
   10.12 @@ -2221,9 +2221,12 @@
   10.13          /** The file's name.
   10.14           */
   10.15          private Name name;
   10.16 +        private Name flatname;
   10.17  
   10.18 -        public SourceFileObject(Name name) {
   10.19 +        public SourceFileObject(Name name, Name flatname) {
   10.20 +            super(null); // no file manager; never referenced for this file object
   10.21              this.name = name;
   10.22 +            this.flatname = flatname;
   10.23          }
   10.24  
   10.25          public InputStream openInputStream() {
   10.26 @@ -2285,5 +2288,9 @@
   10.27              throw new UnsupportedOperationException();
   10.28          }
   10.29  
   10.30 +        @Override
   10.31 +        protected String inferBinaryName(Iterable<? extends File> path) {
   10.32 +            return flatname.toString();
   10.33 +        }
   10.34      }
   10.35  }
    11.1 --- a/src/share/classes/com/sun/tools/javac/util/Log.java	Fri Jun 20 16:36:18 2008 -0700
    11.2 +++ b/src/share/classes/com/sun/tools/javac/util/Log.java	Wed Jun 25 23:30:55 2008 -0700
    11.3 @@ -34,7 +34,6 @@
    11.4  import javax.tools.DiagnosticListener;
    11.5  import javax.tools.JavaFileObject;
    11.6  
    11.7 -import com.sun.tools.javac.code.Source;
    11.8  import com.sun.tools.javac.file.JavacFileManager;
    11.9  import com.sun.tools.javac.tree.JCTree;
   11.10  import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition;
   11.11 @@ -86,10 +85,6 @@
   11.12       */
   11.13      public boolean emitWarnings;
   11.14  
   11.15 -    /** Enforce mandatory warnings.
   11.16 -     */
   11.17 -    private boolean enforceMandatoryWarnings;
   11.18 -
   11.19      /** Print stack trace on errors?
   11.20       */
   11.21      public boolean dumpOnError;
   11.22 @@ -138,9 +133,6 @@
   11.23          DiagnosticListener<? super JavaFileObject> diagListener =
   11.24              context.get(DiagnosticListener.class);
   11.25          this.diagListener = diagListener;
   11.26 -
   11.27 -        Source source = Source.instance(context);
   11.28 -        this.enforceMandatoryWarnings = source.enforceMandatoryWarnings();
   11.29      }
   11.30      // where
   11.31          private int getIntOption(Options options, String optionName, int defaultValue) {
   11.32 @@ -473,10 +465,7 @@
   11.33       *  @param args   Fields of the warning message.
   11.34       */
   11.35      public void mandatoryWarning(DiagnosticPosition pos, String key, Object ... args) {
   11.36 -        if (enforceMandatoryWarnings)
   11.37 -            report(diags.mandatoryWarning(source, pos, key, args));
   11.38 -        else
   11.39 -            report(diags.warning(source, pos, key, args));
   11.40 +        report(diags.mandatoryWarning(source, pos, key, args));
   11.41      }
   11.42  
   11.43      /** Report a warning that cannot be suppressed.
   11.44 @@ -514,34 +503,43 @@
   11.45      }
   11.46  
   11.47      /** Provide a non-fatal notification, unless suppressed by the -nowarn option.
   11.48 +     *  @param file   The file to which the note applies.
   11.49 +     *  @param key    The key for the localized notification message.
   11.50 +     *  @param args   Fields of the notification message.
   11.51 +     */
   11.52 +    public void note(JavaFileObject file, String key, Object ... args) {
   11.53 +        report(diags.note(wrap(file), null, key, args));
   11.54 +    }
   11.55 +
   11.56 +    /** Provide a non-fatal notification, unless suppressed by the -nowarn option.
   11.57       *  @param key    The key for the localized notification message.
   11.58       *  @param args   Fields of the notification message.
   11.59       */
   11.60      public void mandatoryNote(final JavaFileObject file, String key, Object ... args) {
   11.61 -        JCDiagnostic.DiagnosticSource wrapper = null;
   11.62 -        if (file != null) {
   11.63 -            wrapper = new JCDiagnostic.DiagnosticSource() {
   11.64 -                    public JavaFileObject getFile() {
   11.65 -                        return file;
   11.66 -                    }
   11.67 -                    public CharSequence getName() {
   11.68 -                        return JavacFileManager.getJavacBaseFileName(getFile());
   11.69 -                    }
   11.70 -                    public int getLineNumber(int pos) {
   11.71 -                        return Log.this.getLineNumber(pos);
   11.72 -                    }
   11.73 -                    public int getColumnNumber(int pos) {
   11.74 -                        return Log.this.getColumnNumber(pos);
   11.75 -                    }
   11.76 -                    public Map<JCTree, Integer> getEndPosTable() {
   11.77 -                        return (endPosTables == null ? null : endPosTables.get(file));
   11.78 -                    }
   11.79 -                };
   11.80 +        report(diags.mandatoryNote(wrap(file), key, args));
   11.81 +    }
   11.82 +
   11.83 +    private JCDiagnostic.DiagnosticSource wrap(final JavaFileObject file) {
   11.84 +        if (file == null) {
   11.85 +            return null;
   11.86          }
   11.87 -        if (enforceMandatoryWarnings)
   11.88 -            report(diags.mandatoryNote(wrapper, key, args));
   11.89 -        else
   11.90 -            report(diags.note(wrapper, null, key, args));
   11.91 +        return new JCDiagnostic.DiagnosticSource() {
   11.92 +            public JavaFileObject getFile() {
   11.93 +                return file;
   11.94 +            }
   11.95 +            public CharSequence getName() {
   11.96 +                return JavacFileManager.getJavacBaseFileName(getFile());
   11.97 +            }
   11.98 +            public int getLineNumber(int pos) {
   11.99 +                return Log.this.getLineNumber(pos);
  11.100 +            }
  11.101 +            public int getColumnNumber(int pos) {
  11.102 +                return Log.this.getColumnNumber(pos);
  11.103 +            }
  11.104 +            public Map<JCTree, Integer> getEndPosTable() {
  11.105 +                return (endPosTables == null ? null : endPosTables.get(file));
  11.106 +            }
  11.107 +        };
  11.108      }
  11.109  
  11.110      private DiagnosticPosition wrap(int pos) {
    12.1 --- a/src/share/classes/com/sun/tools/javac/util/MandatoryWarningHandler.java	Fri Jun 20 16:36:18 2008 -0700
    12.2 +++ b/src/share/classes/com/sun/tools/javac/util/MandatoryWarningHandler.java	Wed Jun 25 23:30:55 2008 -0700
    12.3 @@ -101,13 +101,17 @@
    12.4       *                individual instances should be given, or whether an aggregate
    12.5       *                message should be generated at the end of the compilation.
    12.6       *                Typically set via  -Xlint:option.
    12.7 +     * @param enforceMandatory
    12.8 +     *                True if mandatory warnings and notes are being enforced.
    12.9       * @param prefix  A common prefix for the set of message keys for
   12.10       *                the messages that may be generated.
   12.11       */
   12.12 -    public MandatoryWarningHandler(Log log, boolean verbose, String prefix) {
   12.13 +    public MandatoryWarningHandler(Log log, boolean verbose,
   12.14 +                                   boolean enforceMandatory, String prefix) {
   12.15          this.log = log;
   12.16          this.verbose = verbose;
   12.17          this.prefix = prefix;
   12.18 +        this.enforceMandatory = enforceMandatory;
   12.19      }
   12.20  
   12.21      /**
   12.22 @@ -122,7 +126,7 @@
   12.23  
   12.24              if (log.nwarnings < log.MaxWarnings) {
   12.25                  // generate message and remember the source file
   12.26 -                log.mandatoryWarning(pos, msg, args);
   12.27 +                logMandatoryWarning(pos, msg, args);
   12.28                  sourcesWithReportedWarnings.add(currentSource);
   12.29              } else if (deferredDiagnosticKind == null) {
   12.30                  // set up deferred message
   12.31 @@ -163,12 +167,12 @@
   12.32      public void reportDeferredDiagnostic() {
   12.33          if (deferredDiagnosticKind != null) {
   12.34              if (deferredDiagnosticArg == null)
   12.35 -                log.mandatoryNote(deferredDiagnosticSource, deferredDiagnosticKind.getKey(prefix));
   12.36 +                logMandatoryNote(deferredDiagnosticSource, deferredDiagnosticKind.getKey(prefix));
   12.37              else
   12.38 -                log.mandatoryNote(deferredDiagnosticSource, deferredDiagnosticKind.getKey(prefix), deferredDiagnosticArg);
   12.39 +                logMandatoryNote(deferredDiagnosticSource, deferredDiagnosticKind.getKey(prefix), deferredDiagnosticArg);
   12.40  
   12.41              if (!verbose)
   12.42 -                log.mandatoryNote(deferredDiagnosticSource, prefix + ".recompile");
   12.43 +                logMandatoryNote(deferredDiagnosticSource, prefix + ".recompile");
   12.44          }
   12.45      }
   12.46  
   12.47 @@ -224,4 +228,32 @@
   12.48       * deferredDiagnosticKind is updated.
   12.49       */
   12.50      private Object deferredDiagnosticArg;
   12.51 +
   12.52 +    /**
   12.53 +     * True if mandatory warnings and notes are being enforced.
   12.54 +     */
   12.55 +    private final boolean enforceMandatory;
   12.56 +
   12.57 +    /**
   12.58 +     * Reports a mandatory warning to the log.  If mandatory warnings
   12.59 +     * are not being enforced, treat this as an ordinary warning.
   12.60 +     */
   12.61 +    private void logMandatoryWarning(DiagnosticPosition pos, String msg,
   12.62 +                                     Object... args) {
   12.63 +        if (enforceMandatory)
   12.64 +            log.mandatoryWarning(pos, msg, args);
   12.65 +        else
   12.66 +            log.warning(pos, msg, args);
   12.67 +    }
   12.68 +
   12.69 +    /**
   12.70 +     * Reports a mandatory note to the log.  If mandatory notes are
   12.71 +     * not being enforced, treat this as an ordinary note.
   12.72 +     */
   12.73 +    private void logMandatoryNote(JavaFileObject file, String msg, Object... args) {
   12.74 +        if (enforceMandatory)
   12.75 +            log.mandatoryNote(file, msg, args);
   12.76 +        else
   12.77 +            log.note(file, msg, args);
   12.78 +    }
   12.79  }
    13.1 --- a/src/share/classes/com/sun/tools/javadoc/JavadocClassReader.java	Fri Jun 20 16:36:18 2008 -0700
    13.2 +++ b/src/share/classes/com/sun/tools/javadoc/JavadocClassReader.java	Wed Jun 25 23:30:55 2008 -0700
    13.3 @@ -27,7 +27,9 @@
    13.4  
    13.5  import com.sun.tools.javac.code.Symbol.PackageSymbol;
    13.6  import com.sun.tools.javac.file.JavacFileManager;
    13.7 +import com.sun.tools.javac.file.ZipArchive.ZipFileObject;
    13.8  import com.sun.tools.javac.file.Old199;
    13.9 +import com.sun.tools.javac.file.ZipFileIndexArchive;
   13.10  import com.sun.tools.javac.jvm.ClassReader;
   13.11  import com.sun.tools.javac.util.Context;
   13.12  
   13.13 @@ -82,16 +84,16 @@
   13.14      protected void extraFileActions(PackageSymbol pack, JavaFileObject fo) {
   13.15          CharSequence fileName = Old199.getName(fo);
   13.16          if (docenv != null && fileName.equals("package.html")) {
   13.17 -            if (fo instanceof JavacFileManager.ZipFileObject) {
   13.18 -                JavacFileManager.ZipFileObject zfo = (JavacFileManager.ZipFileObject) fo;
   13.19 +            if (fo instanceof ZipFileObject) {
   13.20 +                ZipFileObject zfo = (ZipFileObject) fo;
   13.21                  String zipName = zfo.getZipName();
   13.22                  String entryName = zfo.getZipEntryName();
   13.23                  int lastSep = entryName.lastIndexOf("/");
   13.24                  String classPathName = entryName.substring(0, lastSep + 1);
   13.25                  docenv.getPackageDoc(pack).setDocPath(zipName, classPathName);
   13.26              }
   13.27 -            else if (fo instanceof JavacFileManager.ZipFileIndexFileObject) {
   13.28 -                JavacFileManager.ZipFileIndexFileObject zfo = (JavacFileManager.ZipFileIndexFileObject) fo;
   13.29 +            else if (fo instanceof ZipFileIndexArchive.ZipFileIndexFileObject) {
   13.30 +                ZipFileIndexArchive.ZipFileIndexFileObject zfo = (ZipFileIndexArchive.ZipFileIndexFileObject) fo;
   13.31                  String zipName = zfo.getZipName();
   13.32                  String entryName = zfo.getZipEntryName();
   13.33                  if (File.separatorChar != '/') {
    14.1 --- a/src/share/classes/com/sun/tools/javap/JavapFileManager.java	Fri Jun 20 16:36:18 2008 -0700
    14.2 +++ b/src/share/classes/com/sun/tools/javap/JavapFileManager.java	Wed Jun 25 23:30:55 2008 -0700
    14.3 @@ -25,16 +25,13 @@
    14.4  
    14.5  package com.sun.tools.javap;
    14.6  
    14.7 -import java.io.File;
    14.8  import java.io.PrintWriter;
    14.9  import java.nio.charset.Charset;
   14.10 -import javax.tools.Diagnostic;
   14.11  import javax.tools.DiagnosticListener;
   14.12  import javax.tools.JavaFileObject;
   14.13  
   14.14  import com.sun.tools.javac.file.JavacFileManager;
   14.15  import com.sun.tools.javac.util.Context;
   14.16 -import com.sun.tools.javac.util.JCDiagnostic;
   14.17  
   14.18  /**
   14.19   *  javap's implementation of JavaFileManager.
   14.20 @@ -52,29 +49,8 @@
   14.21      static JavapFileManager create(final DiagnosticListener<? super JavaFileObject> dl, PrintWriter log, Options options) {
   14.22          Context javac_context = new Context();
   14.23  
   14.24 -        if (dl != null) {
   14.25 -            // Workaround bug 6625520: javac handles missing entries on classpath badly
   14.26 -            // Ignore spurious errors for missing files
   14.27 -            DiagnosticListener<JavaFileObject> wrapper = new DiagnosticListener<JavaFileObject>() {
   14.28 -                public void report(Diagnostic<? extends JavaFileObject> diagnostic) {
   14.29 -                    if (diagnostic instanceof JCDiagnostic) {
   14.30 -                        JCDiagnostic jcd = (JCDiagnostic) diagnostic;
   14.31 -                        if (jcd.getCode().equals("compiler.err.error.reading.file")) {
   14.32 -                            Object[] args = jcd.getArgs();
   14.33 -                            if (args.length > 0 && args[0] != null && args[0].toString().length() > 0) {
   14.34 -                                File f = new File(args[0].toString());
   14.35 -                                if (!f.exists())
   14.36 -                                    return;
   14.37 -                            }
   14.38 -                        }
   14.39 -
   14.40 -                    }
   14.41 -                    dl.report(diagnostic);
   14.42 -                }
   14.43 -            };
   14.44 -            javac_context.put(DiagnosticListener.class, wrapper);
   14.45 -        }
   14.46 -
   14.47 +        if (dl != null)
   14.48 +            javac_context.put(DiagnosticListener.class, dl);
   14.49          javac_context.put(com.sun.tools.javac.util.Log.outKey, log);
   14.50  
   14.51          return new JavapFileManager(javac_context, null);
    15.1 --- a/test/tools/javac/T6358024.java	Fri Jun 20 16:36:18 2008 -0700
    15.2 +++ b/test/tools/javac/T6358024.java	Wed Jun 25 23:30:55 2008 -0700
    15.3 @@ -36,6 +36,7 @@
    15.4  import com.sun.source.util.*;
    15.5  import com.sun.tools.javac.api.*;
    15.6  import com.sun.tools.javac.file.*;
    15.7 +import com.sun.tools.javac.file.JavacFileManager;
    15.8  import com.sun.tools.javac.main.*;
    15.9  import com.sun.tools.javac.util.*;
   15.10  
    16.1 --- a/test/tools/javac/T6358166.java	Fri Jun 20 16:36:18 2008 -0700
    16.2 +++ b/test/tools/javac/T6358166.java	Wed Jun 25 23:30:55 2008 -0700
    16.3 @@ -33,6 +33,7 @@
    16.4  import javax.lang.model.element.*;
    16.5  import javax.tools.*;
    16.6  import com.sun.tools.javac.file.*;
    16.7 +import com.sun.tools.javac.file.JavacFileManager; // disambiguate
    16.8  import com.sun.tools.javac.main.JavaCompiler;
    16.9  import com.sun.tools.javac.main.*;
   16.10  import com.sun.tools.javac.util.*;
    17.1 --- a/test/tools/javac/T6358168.java	Fri Jun 20 16:36:18 2008 -0700
    17.2 +++ b/test/tools/javac/T6358168.java	Wed Jun 25 23:30:55 2008 -0700
    17.3 @@ -34,6 +34,7 @@
    17.4  import javax.lang.model.element.*;
    17.5  import javax.tools.*;
    17.6  import com.sun.tools.javac.file.*;
    17.7 +import com.sun.tools.javac.file.JavacFileManager;
    17.8  import com.sun.tools.javac.main.JavaCompiler;
    17.9  import com.sun.tools.javac.main.*;
   17.10  import com.sun.tools.javac.util.*;
    18.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    18.2 +++ b/test/tools/javac/T6625520.java	Wed Jun 25 23:30:55 2008 -0700
    18.3 @@ -0,0 +1,55 @@
    18.4 +/*
    18.5 + * Copyright 2008 Sun Microsystems, Inc.  All Rights Reserved.
    18.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    18.7 + *
    18.8 + * This code is free software; you can redistribute it and/or modify it
    18.9 + * under the terms of the GNU General Public License version 2 only, as
   18.10 + * published by the Free Software Foundation.
   18.11 + *
   18.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   18.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   18.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   18.15 + * version 2 for more details (a copy is included in the LICENSE file that
   18.16 + * accompanied this code).
   18.17 + *
   18.18 + * You should have received a copy of the GNU General Public License version
   18.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   18.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   18.21 + *
   18.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
   18.23 + * CA 95054 USA or visit www.sun.com if you need additional information or
   18.24 + * have any questions.
   18.25 + */
   18.26 +
   18.27 +import java.io.*;
   18.28 +import java.util.*;
   18.29 +import javax.tools.*;
   18.30 +import com.sun.tools.javac.file.*;
   18.31 +import com.sun.tools.javac.file.JavacFileManager;
   18.32 +import com.sun.tools.javac.util.*;
   18.33 +
   18.34 +/*
   18.35 + * @test
   18.36 + * @bug 6625520
   18.37 + * @summary javac handles missing entries on classpath badly
   18.38 + */
   18.39 +public class T6625520 {
   18.40 +    public static void main(String[] args) throws Exception {
   18.41 +        new T6625520().run();
   18.42 +    }
   18.43 +
   18.44 +    void run() throws Exception {
   18.45 +        Context c = new Context();
   18.46 +        DiagnosticCollector<JavaFileObject> dc =
   18.47 +            new DiagnosticCollector<JavaFileObject>();
   18.48 +        c.put(DiagnosticListener.class, dc);
   18.49 +        StandardJavaFileManager fm = new JavacFileManager(c, false, null);
   18.50 +        fm.setLocation(StandardLocation.CLASS_PATH,
   18.51 +                       Arrays.asList(new File("DOES_NOT_EXIST.jar")));
   18.52 +        FileObject fo = fm.getFileForInput(StandardLocation.CLASS_PATH,
   18.53 +                                           "p", "C.java");
   18.54 +        System.err.println(fo + "\n" + dc.getDiagnostics());
   18.55 +        if (dc.getDiagnostics().size() > 0)
   18.56 +            throw new Exception("unexpected diagnostics found");
   18.57 +    }
   18.58 +}
    19.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    19.2 +++ b/test/tools/javac/generics/6294779/T6294779a.java	Wed Jun 25 23:30:55 2008 -0700
    19.3 @@ -0,0 +1,49 @@
    19.4 +/*
    19.5 + * Copyright 2008 Sun Microsystems, Inc.  All Rights Reserved.
    19.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    19.7 + *
    19.8 + * This code is free software; you can redistribute it and/or modify it
    19.9 + * under the terms of the GNU General Public License version 2 only, as
   19.10 + * published by the Free Software Foundation.
   19.11 + *
   19.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   19.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   19.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   19.15 + * version 2 for more details (a copy is included in the LICENSE file that
   19.16 + * accompanied this code).
   19.17 + *
   19.18 + * You should have received a copy of the GNU General Public License version
   19.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   19.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   19.21 + *
   19.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
   19.23 + * CA 95054 USA or visit www.sun.com if you need additional information or
   19.24 + * have any questions.
   19.25 + */
   19.26 +
   19.27 +/*
   19.28 + * @test
   19.29 + * @bug     6294779
   19.30 + * @summary Problem with interface inheritance and covariant return types
   19.31 + * @author  Maurizio Cimadamore
   19.32 + * @compile T6294779a.java
   19.33 + */
   19.34 +
   19.35 +public class T6294779a {
   19.36 +
   19.37 +    interface A {
   19.38 +        A m();
   19.39 +    }
   19.40 +
   19.41 +    interface B extends A {
   19.42 +        B m();
   19.43 +    }
   19.44 +
   19.45 +    interface C extends A {
   19.46 +        C m();
   19.47 +    }
   19.48 +
   19.49 +    interface D extends B, C {
   19.50 +        D m();
   19.51 +    }
   19.52 +}
    20.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    20.2 +++ b/test/tools/javac/generics/6294779/T6294779b.java	Wed Jun 25 23:30:55 2008 -0700
    20.3 @@ -0,0 +1,49 @@
    20.4 +/*
    20.5 + * Copyright 2008 Sun Microsystems, Inc.  All Rights Reserved.
    20.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    20.7 + *
    20.8 + * This code is free software; you can redistribute it and/or modify it
    20.9 + * under the terms of the GNU General Public License version 2 only, as
   20.10 + * published by the Free Software Foundation.
   20.11 + *
   20.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   20.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   20.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   20.15 + * version 2 for more details (a copy is included in the LICENSE file that
   20.16 + * accompanied this code).
   20.17 + *
   20.18 + * You should have received a copy of the GNU General Public License version
   20.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   20.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   20.21 + *
   20.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
   20.23 + * CA 95054 USA or visit www.sun.com if you need additional information or
   20.24 + * have any questions.
   20.25 + */
   20.26 +
   20.27 +/*
   20.28 + * @test
   20.29 + * @bug     6294779
   20.30 + * @summary Problem with interface inheritance and covariant return types
   20.31 + * @author  Maurizio Cimadamore
   20.32 + * @compile T6294779b.java
   20.33 + */
   20.34 +
   20.35 +import java.util.*;
   20.36 +
   20.37 +class T6294779b {
   20.38 +
   20.39 +    interface I1<E> {
   20.40 +        List<E> m();
   20.41 +    }
   20.42 +
   20.43 +    interface I2<E> {
   20.44 +        Queue<E> m();
   20.45 +    }
   20.46 +
   20.47 +    interface I3<E> {
   20.48 +        LinkedList<E> m();
   20.49 +    }
   20.50 +
   20.51 +    interface I4<E> extends I1<E>, I2<E>, I3<E> {}
   20.52 +}
    21.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    21.2 +++ b/test/tools/javac/generics/6294779/T6294779c.java	Wed Jun 25 23:30:55 2008 -0700
    21.3 @@ -0,0 +1,53 @@
    21.4 +/*
    21.5 + * Copyright 2008 Sun Microsystems, Inc.  All Rights Reserved.
    21.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    21.7 + *
    21.8 + * This code is free software; you can redistribute it and/or modify it
    21.9 + * under the terms of the GNU General Public License version 2 only, as
   21.10 + * published by the Free Software Foundation.
   21.11 + *
   21.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   21.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   21.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   21.15 + * version 2 for more details (a copy is included in the LICENSE file that
   21.16 + * accompanied this code).
   21.17 + *
   21.18 + * You should have received a copy of the GNU General Public License version
   21.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   21.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   21.21 + *
   21.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
   21.23 + * CA 95054 USA or visit www.sun.com if you need additional information or
   21.24 + * have any questions.
   21.25 + */
   21.26 +
   21.27 +/*
   21.28 + * @test
   21.29 + * @bug     6294779
   21.30 + * @summary Problem with interface inheritance and covariant return types
   21.31 + * @author  Maurizio Cimadamore
   21.32 + * @compile/fail T6294779c.java
   21.33 + */
   21.34 +
   21.35 +public class T6294779c<X> {
   21.36 +
   21.37 +    interface A {}
   21.38 +
   21.39 +    interface B {}
   21.40 +
   21.41 +    interface C {}
   21.42 +
   21.43 +    interface I1 {
   21.44 +        T6294779c<? extends A> get();
   21.45 +    }
   21.46 +
   21.47 +    interface I2 {
   21.48 +        T6294779c<? extends B> get();
   21.49 +    }
   21.50 +
   21.51 +    interface I3 {
   21.52 +        T6294779c<? extends C> get();
   21.53 +    }
   21.54 +
   21.55 +    interface I4 extends I1, I2, I3 {}
   21.56 +}
    22.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    22.2 +++ b/test/tools/javadoc/sourceOption/SourceOption.java	Wed Jun 25 23:30:55 2008 -0700
    22.3 @@ -0,0 +1,47 @@
    22.4 +/*
    22.5 + * Copyright 2006 Sun Microsystems, Inc.  All Rights Reserved.
    22.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    22.7 + *
    22.8 + * This code is free software; you can redistribute it and/or modify it
    22.9 + * under the terms of the GNU General Public License version 2 only, as
   22.10 + * published by the Free Software Foundation.
   22.11 + *
   22.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   22.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   22.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   22.15 + * version 2 for more details (a copy is included in the LICENSE file that
   22.16 + * accompanied this code).
   22.17 + *
   22.18 + * You should have received a copy of the GNU General Public License version
   22.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   22.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   22.21 + *
   22.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
   22.23 + * CA 95054 USA or visit www.sun.com if you need additional information or
   22.24 + * have any questions.
   22.25 + */
   22.26 +
   22.27 +/*
   22.28 + * @test
   22.29 + * @bug     6507179
   22.30 + * @summary Ensure that "-source" option isn't ignored.
   22.31 + * @author  Scott Seligman
   22.32 + */
   22.33 +
   22.34 +import com.sun.javadoc.*;
   22.35 +
   22.36 +public class SourceOption extends Doclet {
   22.37 +
   22.38 +    public static void main(String[] args) {
   22.39 +        if (com.sun.tools.javadoc.Main.execute(
   22.40 +                "javadoc",
   22.41 +                "SourceOption",
   22.42 +                new String[] {"-source", "1.3", "p"}) != 0)
   22.43 +            throw new Error("Javadoc encountered warnings or errors.");
   22.44 +    }
   22.45 +
   22.46 +    public static boolean start(RootDoc root) {
   22.47 +        root.classes();         // force parser into action
   22.48 +        return true;
   22.49 +    }
   22.50 +}
    23.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    23.2 +++ b/test/tools/javadoc/sourceOption/p/A.java	Wed Jun 25 23:30:55 2008 -0700
    23.3 @@ -0,0 +1,29 @@
    23.4 +/*
    23.5 + * Copyright 2004 Sun Microsystems, Inc.  All Rights Reserved.
    23.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    23.7 + *
    23.8 + * This code is free software; you can redistribute it and/or modify it
    23.9 + * under the terms of the GNU General Public License version 2 only, as
   23.10 + * published by the Free Software Foundation.
   23.11 + *
   23.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   23.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   23.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   23.15 + * version 2 for more details (a copy is included in the LICENSE file that
   23.16 + * accompanied this code).
   23.17 + *
   23.18 + * You should have received a copy of the GNU General Public License version
   23.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   23.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   23.21 + *
   23.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
   23.23 + * CA 95054 USA or visit www.sun.com if you need additional information or
   23.24 + * have any questions.
   23.25 + */
   23.26 +
   23.27 +package p;
   23.28 +
   23.29 +public class A {
   23.30 +    boolean assert;     // illegal since 1.4
   23.31 +    boolean enum;       // illegal since 5
   23.32 +}

mercurial