Merge

Thu, 15 Oct 2009 22:48:34 -0700

author
tbell
date
Thu, 15 Oct 2009 22:48:34 -0700
changeset 426
d1e62f78c48b
parent 421
79c13af9217e
parent 425
b8936a7930fe
child 427
6ba399eff2cb

Merge

     1.1 --- a/src/share/classes/com/sun/tools/classfile/ConstantPool.java	Thu Oct 15 16:40:44 2009 -0700
     1.2 +++ b/src/share/classes/com/sun/tools/classfile/ConstantPool.java	Thu Oct 15 22:48:34 2009 -0700
     1.3 @@ -369,14 +369,33 @@
     1.4              return 3;
     1.5          }
     1.6  
     1.7 +        /**
     1.8 +         * Get the raw value of the class referenced by this constant pool entry.
     1.9 +         * This will either be the name of the class, in internal form, or a
    1.10 +         * descriptor for an array class.
    1.11 +         * @return the raw value of the class
    1.12 +         */
    1.13          public String getName() throws ConstantPoolException {
    1.14              return cp.getUTF8Value(name_index);
    1.15          }
    1.16  
    1.17 +        /**
    1.18 +         * If this constant pool entry identifies either a class or interface type,
    1.19 +         * or a possibly multi-dimensional array of a class of interface type,
    1.20 +         * return the name of the class or interface in internal form. Otherwise,
    1.21 +         * (i.e. if this is a possibly multi-dimensional array of a primitive type),
    1.22 +         * return null.
    1.23 +         * @return the base class or interface name
    1.24 +         */
    1.25          public String getBaseName() throws ConstantPoolException {
    1.26              String name = getName();
    1.27 -            int index = name.indexOf("[L") + 1;
    1.28 -            return name.substring(index);
    1.29 +            if (name.startsWith("[")) {
    1.30 +                int index = name.indexOf("[L");
    1.31 +                if (index == -1)
    1.32 +                    return null;
    1.33 +                return name.substring(index + 2, name.length() - 1);
    1.34 +            } else
    1.35 +                return name;
    1.36          }
    1.37  
    1.38          public int getDimensionCount() throws ConstantPoolException {
     2.1 --- a/src/share/classes/com/sun/tools/javac/file/BaseFileObject.java	Thu Oct 15 16:40:44 2009 -0700
     2.2 +++ b/src/share/classes/com/sun/tools/javac/file/BaseFileObject.java	Thu Oct 15 22:48:34 2009 -0700
     2.3 @@ -120,6 +120,14 @@
     2.4  
     2.5      }
     2.6  
     2.7 +    // force subtypes to define equals
     2.8 +    @Override
     2.9 +    public abstract boolean equals(Object other);
    2.10 +
    2.11 +    // force subtypes to define hashCode
    2.12 +    @Override
    2.13 +    public abstract int hashCode();
    2.14 +
    2.15      /** The file manager that created this JavaFileObject. */
    2.16      protected final JavacFileManager fileManager;
    2.17  }
     3.1 --- a/src/share/classes/com/sun/tools/javac/file/JavacFileManager.java	Thu Oct 15 16:40:44 2009 -0700
     3.2 +++ b/src/share/classes/com/sun/tools/javac/file/JavacFileManager.java	Thu Oct 15 22:48:34 2009 -0700
     3.3 @@ -968,7 +968,7 @@
     3.4              } else {
     3.5                  File siblingDir = null;
     3.6                  if (sibling != null && sibling instanceof RegularFileObject) {
     3.7 -                    siblingDir = ((RegularFileObject)sibling).f.getParentFile();
     3.8 +                    siblingDir = ((RegularFileObject)sibling).file.getParentFile();
     3.9                  }
    3.10                  return new RegularFileObject(this, new File(siblingDir, fileName.basename()));
    3.11              }
     4.1 --- a/src/share/classes/com/sun/tools/javac/file/RegularFileObject.java	Thu Oct 15 16:40:44 2009 -0700
     4.2 +++ b/src/share/classes/com/sun/tools/javac/file/RegularFileObject.java	Thu Oct 15 22:48:34 2009 -0700
     4.3 @@ -33,6 +33,8 @@
     4.4  import java.io.OutputStream;
     4.5  import java.io.OutputStreamWriter;
     4.6  import java.io.Writer;
     4.7 +import java.lang.ref.Reference;
     4.8 +import java.lang.ref.SoftReference;
     4.9  import java.net.URI;
    4.10  import java.nio.ByteBuffer;
    4.11  import java.nio.CharBuffer;
    4.12 @@ -53,7 +55,8 @@
    4.13       */
    4.14      private boolean hasParents = false;
    4.15      private String name;
    4.16 -    final File f;
    4.17 +    final File file;
    4.18 +    private Reference<File> absFileRef;
    4.19  
    4.20      public RegularFileObject(JavacFileManager fileManager, File f) {
    4.21          this(fileManager, f.getName(), f);
    4.22 @@ -65,17 +68,17 @@
    4.23              throw new IllegalArgumentException("directories not supported");
    4.24          }
    4.25          this.name = name;
    4.26 -        this.f = f;
    4.27 +        this.file = f;
    4.28      }
    4.29  
    4.30      @Override
    4.31      public URI toUri() {
    4.32 -        return f.toURI().normalize();
    4.33 +        return file.toURI().normalize();
    4.34      }
    4.35  
    4.36      @Override
    4.37      public String getName() {
    4.38 -        return f.getPath();
    4.39 +        return file.getPath();
    4.40      }
    4.41  
    4.42      @Override
    4.43 @@ -90,20 +93,20 @@
    4.44  
    4.45      @Override
    4.46      public InputStream openInputStream() throws IOException {
    4.47 -        return new FileInputStream(f);
    4.48 +        return new FileInputStream(file);
    4.49      }
    4.50  
    4.51      @Override
    4.52      public OutputStream openOutputStream() throws IOException {
    4.53          ensureParentDirectoriesExist();
    4.54 -        return new FileOutputStream(f);
    4.55 +        return new FileOutputStream(file);
    4.56      }
    4.57  
    4.58      @Override
    4.59      public CharBuffer getCharContent(boolean ignoreEncodingErrors) throws IOException {
    4.60          CharBuffer cb = fileManager.getCachedContent(this);
    4.61          if (cb == null) {
    4.62 -            InputStream in = new FileInputStream(f);
    4.63 +            InputStream in = new FileInputStream(file);
    4.64              try {
    4.65                  ByteBuffer bb = fileManager.makeByteBuffer(in);
    4.66                  JavaFileObject prev = fileManager.log.useSource(this);
    4.67 @@ -126,17 +129,17 @@
    4.68      @Override
    4.69      public Writer openWriter() throws IOException {
    4.70          ensureParentDirectoriesExist();
    4.71 -        return new OutputStreamWriter(new FileOutputStream(f), fileManager.getEncodingName());
    4.72 +        return new OutputStreamWriter(new FileOutputStream(file), fileManager.getEncodingName());
    4.73      }
    4.74  
    4.75      @Override
    4.76      public long getLastModified() {
    4.77 -        return f.lastModified();
    4.78 +        return file.lastModified();
    4.79      }
    4.80  
    4.81      @Override
    4.82      public boolean delete() {
    4.83 -        return f.delete();
    4.84 +        return file.delete();
    4.85      }
    4.86  
    4.87      @Override
    4.88 @@ -146,7 +149,7 @@
    4.89  
    4.90      @Override
    4.91      protected String inferBinaryName(Iterable<? extends File> path) {
    4.92 -        String fPath = f.getPath();
    4.93 +        String fPath = file.getPath();
    4.94          //System.err.println("RegularFileObject " + file + " " +r.getPath());
    4.95          for (File dir: path) {
    4.96              //System.err.println("dir: " + dir);
    4.97 @@ -178,7 +181,7 @@
    4.98          if (name.equalsIgnoreCase(n)) {
    4.99              try {
   4.100                  // allow for Windows
   4.101 -                return f.getCanonicalFile().getName().equals(n);
   4.102 +                return file.getCanonicalFile().getName().equals(n);
   4.103              } catch (IOException e) {
   4.104              }
   4.105          }
   4.106 @@ -187,7 +190,7 @@
   4.107  
   4.108      private void ensureParentDirectoriesExist() throws IOException {
   4.109          if (!hasParents) {
   4.110 -            File parent = f.getParentFile();
   4.111 +            File parent = file.getParentFile();
   4.112              if (parent != null && !parent.exists()) {
   4.113                  if (!parent.mkdirs()) {
   4.114                      if (!parent.exists() || !parent.isDirectory()) {
   4.115 @@ -199,21 +202,34 @@
   4.116          }
   4.117      }
   4.118  
   4.119 +    /**
   4.120 +     * Check if two file objects are equal.
   4.121 +     * Two RegularFileObjects are equal if the absolute paths of the underlying
   4.122 +     * files are equal.
   4.123 +     */
   4.124      @Override
   4.125      public boolean equals(Object other) {
   4.126 -        if (!(other instanceof RegularFileObject)) {
   4.127 +        if (this == other)
   4.128 +            return true;
   4.129 +
   4.130 +        if (!(other instanceof RegularFileObject))
   4.131              return false;
   4.132 -        }
   4.133 +
   4.134          RegularFileObject o = (RegularFileObject) other;
   4.135 -        try {
   4.136 -            return f.equals(o.f) || f.getCanonicalFile().equals(o.f.getCanonicalFile());
   4.137 -        } catch (IOException e) {
   4.138 -            return false;
   4.139 -        }
   4.140 +        return getAbsoluteFile().equals(o.getAbsoluteFile());
   4.141      }
   4.142  
   4.143      @Override
   4.144      public int hashCode() {
   4.145 -        return f.hashCode();
   4.146 +        return getAbsoluteFile().hashCode();
   4.147 +    }
   4.148 +
   4.149 +    private File getAbsoluteFile() {
   4.150 +        File absFile = (absFileRef == null ? null : absFileRef.get());
   4.151 +        if (absFile == null) {
   4.152 +            absFile = file.getAbsoluteFile();
   4.153 +            absFileRef = new SoftReference<File>(absFile);
   4.154 +        }
   4.155 +        return absFile;
   4.156      }
   4.157  }
     5.1 --- a/src/share/classes/com/sun/tools/javac/file/SymbolArchive.java	Thu Oct 15 16:40:44 2009 -0700
     5.2 +++ b/src/share/classes/com/sun/tools/javac/file/SymbolArchive.java	Thu Oct 15 22:48:34 2009 -0700
     5.3 @@ -76,13 +76,13 @@
     5.4      @Override
     5.5      public JavaFileObject getFileObject(RelativeDirectory subdirectory, String file) {
     5.6          RelativeDirectory prefix_subdir = new RelativeDirectory(prefix, subdirectory.path);
     5.7 -        ZipEntry ze = new RelativeFile(prefix_subdir, file).getZipEntry(zdir);
     5.8 +        ZipEntry ze = new RelativeFile(prefix_subdir, file).getZipEntry(zfile);
     5.9          return new SymbolFileObject(this, file, ze);
    5.10      }
    5.11  
    5.12      @Override
    5.13      public String toString() {
    5.14 -        return "SymbolArchive[" + zdir.getName() + "]";
    5.15 +        return "SymbolArchive[" + zfile.getName() + "]";
    5.16      }
    5.17  
    5.18      /**
     6.1 --- a/src/share/classes/com/sun/tools/javac/file/ZipArchive.java	Thu Oct 15 16:40:44 2009 -0700
     6.2 +++ b/src/share/classes/com/sun/tools/javac/file/ZipArchive.java	Thu Oct 15 22:48:34 2009 -0700
     6.3 @@ -47,6 +47,8 @@
     6.4  import com.sun.tools.javac.file.RelativePath.RelativeDirectory;
     6.5  import com.sun.tools.javac.file.RelativePath.RelativeFile;
     6.6  import com.sun.tools.javac.util.List;
     6.7 +import java.lang.ref.Reference;
     6.8 +import java.lang.ref.SoftReference;
     6.9  
    6.10  /**
    6.11   * <p><b>This is NOT part of any API supported by Sun Microsystems.
    6.12 @@ -56,20 +58,20 @@
    6.13   */
    6.14  public class ZipArchive implements Archive {
    6.15  
    6.16 -    public ZipArchive(JavacFileManager fm, ZipFile zdir) throws IOException {
    6.17 -        this(fm, zdir, true);
    6.18 +    public ZipArchive(JavacFileManager fm, ZipFile zfile) throws IOException {
    6.19 +        this(fm, zfile, true);
    6.20      }
    6.21  
    6.22 -    protected ZipArchive(JavacFileManager fm, ZipFile zdir, boolean initMap) throws IOException {
    6.23 +    protected ZipArchive(JavacFileManager fm, ZipFile zfile, boolean initMap) throws IOException {
    6.24          this.fileManager = fm;
    6.25 -        this.zdir = zdir;
    6.26 +        this.zfile = zfile;
    6.27          this.map = new HashMap<RelativeDirectory,List<String>>();
    6.28          if (initMap)
    6.29              initMap();
    6.30      }
    6.31  
    6.32      protected void initMap() throws IOException {
    6.33 -        for (Enumeration<? extends ZipEntry> e = zdir.entries(); e.hasMoreElements(); ) {
    6.34 +        for (Enumeration<? extends ZipEntry> e = zfile.entries(); e.hasMoreElements(); ) {
    6.35              ZipEntry entry;
    6.36              try {
    6.37                  entry = e.nextElement();
    6.38 @@ -110,7 +112,7 @@
    6.39      }
    6.40  
    6.41      public JavaFileObject getFileObject(RelativeDirectory subdirectory, String file) {
    6.42 -        ZipEntry ze = new RelativeFile(subdirectory, file).getZipEntry(zdir);
    6.43 +        ZipEntry ze = new RelativeFile(subdirectory, file).getZipEntry(zfile);
    6.44          return new ZipFileObject(this, file, ze);
    6.45      }
    6.46  
    6.47 @@ -119,17 +121,39 @@
    6.48      }
    6.49  
    6.50      public void close() throws IOException {
    6.51 -        zdir.close();
    6.52 +        zfile.close();
    6.53      }
    6.54  
    6.55      @Override
    6.56      public String toString() {
    6.57 -        return "ZipArchive[" + zdir.getName() + "]";
    6.58 +        return "ZipArchive[" + zfile.getName() + "]";
    6.59      }
    6.60  
    6.61 +    private File getAbsoluteFile() {
    6.62 +        File absFile = (absFileRef == null ? null : absFileRef.get());
    6.63 +        if (absFile == null) {
    6.64 +            absFile = new File(zfile.getName()).getAbsoluteFile();
    6.65 +            absFileRef = new SoftReference<File>(absFile);
    6.66 +        }
    6.67 +        return absFile;
    6.68 +    }
    6.69 +
    6.70 +    /**
    6.71 +     * The file manager that created this archive.
    6.72 +     */
    6.73      protected JavacFileManager fileManager;
    6.74 +    /**
    6.75 +     * The index for the contents of this archive.
    6.76 +     */
    6.77      protected final Map<RelativeDirectory,List<String>> map;
    6.78 -    protected final ZipFile zdir;
    6.79 +    /**
    6.80 +     * The zip file for the archive.
    6.81 +     */
    6.82 +    protected final ZipFile zfile;
    6.83 +    /**
    6.84 +     * A reference to the absolute filename for the zip file for the archive.
    6.85 +     */
    6.86 +    protected Reference<File> absFileRef;
    6.87  
    6.88      /**
    6.89       * A subclass of JavaFileObject representing zip entries.
    6.90 @@ -148,18 +172,18 @@
    6.91          }
    6.92  
    6.93          public URI toUri() {
    6.94 -            File zipFile = new File(zarch.zdir.getName());
    6.95 +            File zipFile = new File(zarch.zfile.getName());
    6.96              return createJarUri(zipFile, entry.getName());
    6.97          }
    6.98  
    6.99          @Override
   6.100          public String getName() {
   6.101 -            return zarch.zdir.getName() + "(" + entry.getName() + ")";
   6.102 +            return zarch.zfile.getName() + "(" + entry.getName() + ")";
   6.103          }
   6.104  
   6.105          @Override
   6.106          public String getShortName() {
   6.107 -            return new File(zarch.zdir.getName()).getName() + "(" + entry + ")";
   6.108 +            return new File(zarch.zfile.getName()).getName() + "(" + entry + ")";
   6.109          }
   6.110  
   6.111          @Override
   6.112 @@ -169,7 +193,7 @@
   6.113  
   6.114          @Override
   6.115          public InputStream openInputStream() throws IOException {
   6.116 -            return zarch.zdir.getInputStream(entry);
   6.117 +            return zarch.zfile.getInputStream(entry);
   6.118          }
   6.119  
   6.120          @Override
   6.121 @@ -181,7 +205,7 @@
   6.122          public CharBuffer getCharContent(boolean ignoreEncodingErrors) throws IOException {
   6.123              CharBuffer cb = fileManager.getCachedContent(this);
   6.124              if (cb == null) {
   6.125 -                InputStream in = zarch.zdir.getInputStream(entry);
   6.126 +                InputStream in = zarch.zfile.getInputStream(entry);
   6.127                  try {
   6.128                      ByteBuffer bb = fileManager.makeByteBuffer(in);
   6.129                      JavaFileObject prev = fileManager.log.useSource(this);
   6.130 @@ -237,18 +261,27 @@
   6.131              return name.equals(cn + k.extension);
   6.132          }
   6.133  
   6.134 +        /**
   6.135 +         * Check if two file objects are equal.
   6.136 +         * Two ZipFileObjects are equal if the absolute paths of the underlying
   6.137 +         * zip files are equal and if the paths within those zip files are equal.
   6.138 +         */
   6.139          @Override
   6.140          public boolean equals(Object other) {
   6.141 -            if (!(other instanceof ZipFileObject)) {
   6.142 +            if (this == other)
   6.143 +                return true;
   6.144 +
   6.145 +            if (!(other instanceof ZipFileObject))
   6.146                  return false;
   6.147 -            }
   6.148 +
   6.149              ZipFileObject o = (ZipFileObject) other;
   6.150 -            return zarch.zdir.equals(o.zarch.zdir) || name.equals(o.name);
   6.151 +            return zarch.getAbsoluteFile().equals(o.zarch.getAbsoluteFile())
   6.152 +                    && name.equals(o.name);
   6.153          }
   6.154  
   6.155          @Override
   6.156          public int hashCode() {
   6.157 -            return zarch.zdir.hashCode() + name.hashCode();
   6.158 +            return zarch.getAbsoluteFile().hashCode() + name.hashCode();
   6.159          }
   6.160      }
   6.161  
     7.1 --- a/src/share/classes/com/sun/tools/javac/file/ZipFileIndex.java	Thu Oct 15 16:40:44 2009 -0700
     7.2 +++ b/src/share/classes/com/sun/tools/javac/file/ZipFileIndex.java	Thu Oct 15 22:48:34 2009 -0700
     7.3 @@ -30,6 +30,7 @@
     7.4  import java.io.FileNotFoundException;
     7.5  import java.io.IOException;
     7.6  import java.io.RandomAccessFile;
     7.7 +import java.lang.ref.Reference;
     7.8  import java.lang.ref.SoftReference;
     7.9  import java.util.ArrayList;
    7.10  import java.util.Arrays;
    7.11 @@ -89,6 +90,7 @@
    7.12  
    7.13      // ZipFileIndex data entries
    7.14      private File zipFile;
    7.15 +    private Reference<File> absFileRef;
    7.16      private long zipFileLastModified = NOT_MODIFIED;
    7.17      private RandomAccessFile zipRandomFile;
    7.18      private Entry[] entries;
    7.19 @@ -1215,6 +1217,15 @@
    7.20          return zipFile;
    7.21      }
    7.22  
    7.23 +    File getAbsoluteFile() {
    7.24 +        File absFile = (absFileRef == null ? null : absFileRef.get());
    7.25 +        if (absFile == null) {
    7.26 +            absFile = zipFile.getAbsoluteFile();
    7.27 +            absFileRef = new SoftReference<File>(absFile);
    7.28 +        }
    7.29 +        return absFile;
    7.30 +    }
    7.31 +
    7.32      private RelativeDirectory getRelativeDirectory(String path) {
    7.33          RelativeDirectory rd;
    7.34          SoftReference<RelativeDirectory> ref = relativeDirectoryCache.get(path);
     8.1 --- a/src/share/classes/com/sun/tools/javac/file/ZipFileIndexArchive.java	Thu Oct 15 16:40:44 2009 -0700
     8.2 +++ b/src/share/classes/com/sun/tools/javac/file/ZipFileIndexArchive.java	Thu Oct 15 22:48:34 2009 -0700
     8.3 @@ -219,17 +219,27 @@
     8.4              return name.equals(cn + k.extension);
     8.5          }
     8.6  
     8.7 +        /**
     8.8 +         * Check if two file objects are equal.
     8.9 +         * Two ZipFileIndexFileObjects are equal if the absolute paths of the underlying
    8.10 +         * zip files are equal and if the paths within those zip files are equal.
    8.11 +         */
    8.12          @Override
    8.13          public boolean equals(Object other) {
    8.14 +            if (this == other)
    8.15 +                return true;
    8.16 +
    8.17              if (!(other instanceof ZipFileIndexFileObject))
    8.18                  return false;
    8.19 +
    8.20              ZipFileIndexFileObject o = (ZipFileIndexFileObject) other;
    8.21 -            return entry.equals(o.entry);
    8.22 +            return zfIndex.getAbsoluteFile().equals(o.zfIndex.getAbsoluteFile())
    8.23 +                    && name.equals(o.name);
    8.24          }
    8.25  
    8.26          @Override
    8.27          public int hashCode() {
    8.28 -            return zipName.hashCode() + (name.hashCode() << 10);
    8.29 +            return zfIndex.getAbsoluteFile().hashCode() + name.hashCode();
    8.30          }
    8.31  
    8.32          private String getPrefixedEntryName() {
     9.1 --- a/src/share/classes/com/sun/tools/javac/jvm/ClassReader.java	Thu Oct 15 16:40:44 2009 -0700
     9.2 +++ b/src/share/classes/com/sun/tools/javac/jvm/ClassReader.java	Thu Oct 15 22:48:34 2009 -0700
     9.3 @@ -2632,10 +2632,20 @@
     9.4              return true; // fail-safe mode
     9.5          }
     9.6  
     9.7 +        /**
     9.8 +         * Check if two file objects are equal.
     9.9 +         * SourceFileObjects are just placeholder objects for the value of a
    9.10 +         * SourceFile attribute, and do not directly represent specific files.
    9.11 +         * Two SourceFileObjects are equal if their names are equal.
    9.12 +         */
    9.13          @Override
    9.14          public boolean equals(Object other) {
    9.15 +            if (this == other)
    9.16 +                return true;
    9.17 +
    9.18              if (!(other instanceof SourceFileObject))
    9.19                  return false;
    9.20 +
    9.21              SourceFileObject o = (SourceFileObject) other;
    9.22              return name.equals(o.name);
    9.23          }
    10.1 --- a/src/share/classes/com/sun/tools/javac/parser/Scanner.java	Thu Oct 15 16:40:44 2009 -0700
    10.2 +++ b/src/share/classes/com/sun/tools/javac/parser/Scanner.java	Thu Oct 15 22:48:34 2009 -0700
    10.3 @@ -876,7 +876,11 @@
    10.4                          }
    10.5                          scanChar();
    10.6                          skipIllegalUnderscores();
    10.7 -                        scanNumber(2);
    10.8 +                        if (digit(2) < 0) {
    10.9 +                            lexError("invalid.binary.number");
   10.10 +                        } else {
   10.11 +                            scanNumber(2);
   10.12 +                        }
   10.13                      } else {
   10.14                          putChar('0');
   10.15                          if (ch == '_') {
    11.1 --- a/src/share/classes/com/sun/tools/javac/resources/compiler.properties	Thu Oct 15 16:40:44 2009 -0700
    11.2 +++ b/src/share/classes/com/sun/tools/javac/resources/compiler.properties	Thu Oct 15 22:48:34 2009 -0700
    11.3 @@ -252,6 +252,8 @@
    11.4      interface methods cannot have body
    11.5  compiler.err.invalid.annotation.member.type=\
    11.6      invalid type for annotation member
    11.7 +compiler.err.invalid.binary.number=\
    11.8 +    binary numbers must contain at least one binary digit
    11.9  compiler.err.invalid.hex.number=\
   11.10      hexadecimal numbers must contain at least one hexadecimal digit
   11.11  compiler.err.invalid.meth.decl.ret.type.req=\
    12.1 --- a/src/share/classes/javax/lang/model/util/Elements.java	Thu Oct 15 16:40:44 2009 -0700
    12.2 +++ b/src/share/classes/javax/lang/model/util/Elements.java	Thu Oct 15 22:48:34 2009 -0700
    12.3 @@ -77,9 +77,25 @@
    12.4       * Returns the text of the documentation (&quot;Javadoc&quot;)
    12.5       * comment of an element.
    12.6       *
    12.7 +     * <p> A documentation comment of an element is a comment that
    12.8 +     * begins with "{@code /**}" , ends with a separate
    12.9 +     * "<code>*&#47</code>", and immediately precedes the element,
   12.10 +     * ignoring white space.  Therefore, a documentation comment
   12.11 +     * contains at least three"{@code *}" characters.  The text
   12.12 +     * returned for the documentation comment is a processed form of
   12.13 +     * the comment as it appears in source code.  The leading "{@code
   12.14 +     * /**}" and trailing "<code>*&#47</code>" are removed.  For lines
   12.15 +     * of the comment starting after the initial "{@code /**}",
   12.16 +     * leading white space characters are discarded as are any
   12.17 +     * consecutive "{@code *}" characters appearing after the white
   12.18 +     * space or starting the line.  The processed lines are then
   12.19 +     * concatenated together (including line terminators) and
   12.20 +     * returned.
   12.21 +     *
   12.22       * @param e  the element being examined
   12.23       * @return the documentation comment of the element, or {@code null}
   12.24       *          if there is none
   12.25 +     * @jls3 3.6 White Space
   12.26       */
   12.27      String getDocComment(Element e);
   12.28  
    13.1 --- a/test/tools/javac/api/6440528/T6440528.java	Thu Oct 15 16:40:44 2009 -0700
    13.2 +++ b/test/tools/javac/api/6440528/T6440528.java	Thu Oct 15 22:48:34 2009 -0700
    13.3 @@ -59,9 +59,9 @@
    13.4      }
    13.5  
    13.6      private File getUnderlyingFile(Object o) throws Exception {
    13.7 -        Field f = o.getClass().getDeclaredField("f");
    13.8 -        f.setAccessible(true);
    13.9 -        return (File)f.get(o);
   13.10 +        Field file = o.getClass().getDeclaredField("file");
   13.11 +        file.setAccessible(true);
   13.12 +        return (File)file.get(o);
   13.13      }
   13.14  
   13.15      public static void main(String... args) throws Exception {
    14.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    14.2 +++ b/test/tools/javac/api/T6838467.java	Thu Oct 15 22:48:34 2009 -0700
    14.3 @@ -0,0 +1,249 @@
    14.4 +/*
    14.5 + * Copyright 2009 Sun Microsystems, Inc.  All Rights Reserved.
    14.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    14.7 + *
    14.8 + * This code is free software; you can redistribute it and/or modify it
    14.9 + * under the terms of the GNU General Public License version 2 only, as
   14.10 + * published by the Free Software Foundation.
   14.11 + *
   14.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   14.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   14.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   14.15 + * version 2 for more details (a copy is included in the LICENSE file that
   14.16 + * accompanied this code).
   14.17 + *
   14.18 + * You should have received a copy of the GNU General Public License version
   14.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   14.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   14.21 + *
   14.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
   14.23 + * CA 95054 USA or visit www.sun.com if you need additional information or
   14.24 + * have any questions.
   14.25 + */
   14.26 +
   14.27 +/*
   14.28 + * @test
   14.29 + * @bug 6838467
   14.30 + * @summary JSR199 FileObjects don't obey general contract of equals.
   14.31 + */
   14.32 +
   14.33 +import java.io.*;
   14.34 +import java.util.*;
   14.35 +import java.util.zip.*;
   14.36 +import javax.tools.*;
   14.37 +import com.sun.tools.javac.file.JavacFileManager;
   14.38 +import com.sun.tools.javac.util.Context;
   14.39 +
   14.40 +public class T6838467 {
   14.41 +    boolean fileSystemIsCaseSignificant = !new File("a").equals(new File("A"));
   14.42 +
   14.43 +    enum FileKind {
   14.44 +        DIR("dir"),
   14.45 +        ZIP("zip"),
   14.46 +        ZIPFILEINDEX("zip");
   14.47 +        FileKind(String path) {
   14.48 +            file = new File(path);
   14.49 +        }
   14.50 +        final File file;
   14.51 +    };
   14.52 +
   14.53 +    enum CompareKind {
   14.54 +        SAME {
   14.55 +            File other(File f) { return f; }
   14.56 +        },
   14.57 +        ABSOLUTE {
   14.58 +            File other(File f) { return f.getAbsoluteFile(); }
   14.59 +        },
   14.60 +        DIFFERENT {
   14.61 +            File other(File f) { return new File("not_" + f.getPath()); }
   14.62 +        },
   14.63 +        CASEEQUIV {
   14.64 +            File other(File f) { return new File(f.getPath().toUpperCase()); }
   14.65 +        };
   14.66 +        abstract File other(File f);
   14.67 +    };
   14.68 +
   14.69 +    String[] paths = { "p/A.java", "p/B.java", "p/C.java" };
   14.70 +
   14.71 +    public static void main(String... args) throws Exception {
   14.72 +        new T6838467().run();
   14.73 +    }
   14.74 +
   14.75 +    void run() throws Exception {
   14.76 +        // on Windows, verify file system is not case significant
   14.77 +        if (System.getProperty("os.name").toLowerCase().startsWith("windows")
   14.78 +                && fileSystemIsCaseSignificant) {
   14.79 +            error("fileSystemIsCaseSignificant is set on Windows.");
   14.80 +        }
   14.81 +
   14.82 +        // create a set of directories and zip files to compare
   14.83 +        createTestDir(new File("dir"), paths);
   14.84 +        createTestDir(new File("not_dir"), paths);
   14.85 +        createTestZip(new File("zip"), paths);
   14.86 +        createTestZip(new File("not_zip"), paths);
   14.87 +        if (fileSystemIsCaseSignificant) {
   14.88 +            createTestDir(new File("DIR"), paths);
   14.89 +            createTestZip(new File("ZIP"), paths);
   14.90 +        }
   14.91 +
   14.92 +        // test the various sorts of file objects that can be obtained from
   14.93 +        // the file manager, and for various values that may or may not match.
   14.94 +        for (FileKind fk: FileKind.values()) {
   14.95 +            for (CompareKind ck: CompareKind.values()) {
   14.96 +                test(fk, ck);
   14.97 +            }
   14.98 +        }
   14.99 +
  14.100 +        // verify that the various different types of file object were all
  14.101 +        // tested
  14.102 +        Set<String> expectClasses = new HashSet<String>(Arrays.asList(
  14.103 +                "RegularFileObject", "ZipFileObject", "ZipFileIndexFileObject" ));
  14.104 +        if (!foundClasses.equals(expectClasses)) {
  14.105 +            error("expected fileobject classes not found\n"
  14.106 +                    + "expected: " + expectClasses + "\n"
  14.107 +                    + "found: " + foundClasses);
  14.108 +        }
  14.109 +
  14.110 +        if (errors > 0)
  14.111 +            throw new Exception(errors + " errors");
  14.112 +    }
  14.113 +
  14.114 +    void test(FileKind fk, CompareKind ck) throws IOException {
  14.115 +        File f1 = fk.file;
  14.116 +        JavaFileManager fm1 = createFileManager(fk, f1);
  14.117 +
  14.118 +        File f2 = ck.other(fk.file);
  14.119 +        JavaFileManager fm2 = createFileManager(fk, f2);
  14.120 +
  14.121 +        try {
  14.122 +            // If the directories or zip files match, we expect "n" matches in
  14.123 +            // the "n-squared" comparisons to come, where "n" is the number of
  14.124 +            // entries in the the directories or zip files.
  14.125 +            // If the directories or zip files don't themselves match,
  14.126 +            // we obviously don't expect any of their contents to match either.
  14.127 +            int expect = (f1.getAbsoluteFile().equals(f2.getAbsoluteFile()) ? paths.length : 0);
  14.128 +
  14.129 +            System.err.println("test " + (++count) + " " + fk + " " + ck + " " + f1 + " " + f2);
  14.130 +            test(fm1, fm2, expect);
  14.131 +
  14.132 +        } finally {
  14.133 +            fm1.close();
  14.134 +            fm2.close();
  14.135 +        }
  14.136 +    }
  14.137 +
  14.138 +    // For a pair of file managers that may or may not have similar entries
  14.139 +    // on the classpath, compare all files returned from one against all files
  14.140 +    // returned from the other.  For each pair of files, verify that if they
  14.141 +    // are equal, the hashcode is equal as well, and finally verify that the
  14.142 +    // expected number of matches was found.
  14.143 +    void test(JavaFileManager fm1, JavaFileManager fm2, int expectEqualCount) throws IOException {
  14.144 +        boolean foundFiles1 = false;
  14.145 +        boolean foundFiles2 = false;
  14.146 +        int foundEqualCount = 0;
  14.147 +        Set<JavaFileObject.Kind> kinds =  EnumSet.allOf(JavaFileObject.Kind.class);
  14.148 +        for (FileObject fo1: fm1.list(StandardLocation.CLASS_PATH, "p", kinds, false)) {
  14.149 +            foundFiles1 = true;
  14.150 +            foundClasses.add(fo1.getClass().getSimpleName());
  14.151 +            for (FileObject fo2: fm2.list(StandardLocation.CLASS_PATH, "p", kinds, false)) {
  14.152 +                foundFiles2 = true;
  14.153 +                foundClasses.add(fo1.getClass().getSimpleName());
  14.154 +                System.err.println("compare " + fo1 + " " + fo2);
  14.155 +                if (fo1.equals(fo2)) {
  14.156 +                    foundEqualCount++;
  14.157 +                    int hash1 = fo1.hashCode();
  14.158 +                    int hash2 = fo2.hashCode();
  14.159 +                    if (hash1 != hash2)
  14.160 +                        error("hashCode error: " + fo1 + " [" + hash1 + "] "
  14.161 +                                + fo2 + " [" + hash2 + "]");
  14.162 +                }
  14.163 +            }
  14.164 +        }
  14.165 +        if (!foundFiles1)
  14.166 +            error("no files found for file manager 1");
  14.167 +        if (!foundFiles2)
  14.168 +            error("no files found for file manager 2");
  14.169 +        // verify the expected number of matches were found
  14.170 +        if (foundEqualCount != expectEqualCount)
  14.171 +            error("expected matches not found: expected " + expectEqualCount + ", found " + foundEqualCount);
  14.172 +    }
  14.173 +
  14.174 +    // create a file manager to test a FileKind, with a given directory
  14.175 +    // or zip file placed on the classpath
  14.176 +    JavaFileManager createFileManager(FileKind fk, File classpath) throws IOException {
  14.177 +        StandardJavaFileManager fm = createFileManager(fk == FileKind.ZIP);
  14.178 +        fm.setLocation(StandardLocation.CLASS_PATH, Arrays.asList(classpath));
  14.179 +        return fm;
  14.180 +    }
  14.181 +
  14.182 +    JavacFileManager createFileManager(boolean useJavaUtilZip) {
  14.183 +        // javac should really not be using system properties like this
  14.184 +        // -- it should really be using (hidden) options -- but until then
  14.185 +        // take care to leave system properties as we find them, so as not
  14.186 +        // to adversely affect other tests that might follow.
  14.187 +        String prev = System.getProperty("useJavaUtilZip");
  14.188 +        boolean resetProperties = false;
  14.189 +        try {
  14.190 +            if (useJavaUtilZip) {
  14.191 +                System.setProperty("useJavaUtilZip", "true");
  14.192 +                resetProperties = true;
  14.193 +            } else if (System.getProperty("useJavaUtilZip") != null) {
  14.194 +                System.getProperties().remove("useJavaUtilZip");
  14.195 +                resetProperties = true;
  14.196 +            }
  14.197 +
  14.198 +            Context c = new Context();
  14.199 +            return new JavacFileManager(c, false, null);
  14.200 +        } finally {
  14.201 +            if (resetProperties) {
  14.202 +                if (prev == null) {
  14.203 +                    System.getProperties().remove("useJavaUtilZip");
  14.204 +                } else {
  14.205 +                    System.setProperty("useJavaUtilZip", prev);
  14.206 +                }
  14.207 +            }
  14.208 +        }
  14.209 +    }
  14.210 +
  14.211 +    // create a directory containing a given set of paths
  14.212 +    void createTestDir(File dir, String[] paths) throws IOException {
  14.213 +        for (String p: paths) {
  14.214 +            File file = new File(dir, p);
  14.215 +            file.getParentFile().mkdirs();
  14.216 +            FileWriter out = new FileWriter(file);
  14.217 +            try {
  14.218 +                out.write(p);
  14.219 +            } finally {
  14.220 +                out.close();
  14.221 +            }
  14.222 +        }
  14.223 +    }
  14.224 +
  14.225 +    // create a sip file containing a given set of entries
  14.226 +    void createTestZip(File zip, String[] paths) throws IOException {
  14.227 +        if (zip.getParentFile() != null)
  14.228 +            zip.getParentFile().mkdirs();
  14.229 +        ZipOutputStream zos = new ZipOutputStream(new FileOutputStream(zip));
  14.230 +        try {
  14.231 +            for (String p: paths) {
  14.232 +                ZipEntry ze = new ZipEntry(p);
  14.233 +                zos.putNextEntry(ze);
  14.234 +                byte[] bytes = p.getBytes();
  14.235 +                zos.write(bytes, 0, bytes.length);
  14.236 +                zos.closeEntry();
  14.237 +            }
  14.238 +        } finally {
  14.239 +            zos.close();
  14.240 +        }
  14.241 +    }
  14.242 +
  14.243 +    void error(String msg) {
  14.244 +        System.err.println("Error: " + msg);
  14.245 +        errors++;
  14.246 +    }
  14.247 +
  14.248 +    int count;
  14.249 +    int errors;
  14.250 +    Set<String> foundClasses = new HashSet<String>();
  14.251 +}
  14.252 +
    15.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    15.2 +++ b/test/tools/javac/literals/T6891079.java	Thu Oct 15 22:48:34 2009 -0700
    15.3 @@ -0,0 +1,12 @@
    15.4 +/* @test /nodynamiccopyright/
    15.5 + * @bug 6891079
    15.6 + * @summary Compiler allows invalid binary literals 0b and oBL
    15.7 + * @compile/fail/ref=T6891079.out -XDrawDiagnostics T6891079.java
    15.8 + */
    15.9 +
   15.10 +class Test {
   15.11 +    int bi = 0B;
   15.12 +    long bl = 0BL;
   15.13 +    int xi = 0X;
   15.14 +    long xl = 0XL;
   15.15 +}
    16.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    16.2 +++ b/test/tools/javac/literals/T6891079.out	Thu Oct 15 22:48:34 2009 -0700
    16.3 @@ -0,0 +1,7 @@
    16.4 +T6891079.java:8:14: compiler.err.invalid.binary.number
    16.5 +T6891079.java:9:15: compiler.err.invalid.binary.number
    16.6 +T6891079.java:9:18: compiler.err.expected: token.identifier
    16.7 +T6891079.java:10:14: compiler.err.invalid.hex.number
    16.8 +T6891079.java:11:15: compiler.err.invalid.hex.number
    16.9 +T6891079.java:11:18: compiler.err.expected: token.identifier
   16.10 +6 errors
    17.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    17.2 +++ b/test/tools/javap/classfile/T6887895.java	Thu Oct 15 22:48:34 2009 -0700
    17.3 @@ -0,0 +1,121 @@
    17.4 +/*
    17.5 + * Copyright 2009 Sun Microsystems, Inc.  All Rights Reserved.
    17.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    17.7 + *
    17.8 + * This code is free software; you can redistribute it and/or modify it
    17.9 + * under the terms of the GNU General Public License version 2 only, as
   17.10 + * published by the Free Software Foundation.
   17.11 + *
   17.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   17.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   17.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   17.15 + * version 2 for more details (a copy is included in the LICENSE file that
   17.16 + * accompanied this code).
   17.17 + *
   17.18 + * You should have received a copy of the GNU General Public License version
   17.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   17.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   17.21 + *
   17.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
   17.23 + * CA 95054 USA or visit www.sun.com if you need additional information or
   17.24 + * have any questions.
   17.25 + */
   17.26 +
   17.27 +/*
   17.28 + * @test
   17.29 + * @bug 6887895
   17.30 + * @summary CONSTANT_Class_info getBaseName does not handle arrays of primitives correctly
   17.31 + */
   17.32 +
   17.33 +import java.io.*;
   17.34 +import java.net.*;
   17.35 +import java.util.*;
   17.36 +import com.sun.tools.classfile.*;
   17.37 +import com.sun.tools.classfile.ConstantPool.*;
   17.38 +
   17.39 +public class T6887895 {
   17.40 +    public static void main(String[] args) throws Exception {
   17.41 +        new T6887895().run();
   17.42 +    }
   17.43 +
   17.44 +    void run() throws Exception {
   17.45 +        Set<String> found = new TreeSet<String>();
   17.46 +
   17.47 +        ClassFile cf = getClassFile("T6887895$Test.class");
   17.48 +        for (CPInfo cpInfo: cf.constant_pool.entries()) {
   17.49 +            if (cpInfo instanceof CONSTANT_Class_info) {
   17.50 +                CONSTANT_Class_info info = (CONSTANT_Class_info) cpInfo;
   17.51 +                String name = info.getName();
   17.52 +                String baseName = info.getBaseName();
   17.53 +                System.out.println("found: " + name + " " + baseName);
   17.54 +                if (baseName != null)
   17.55 +                    found.add(baseName);
   17.56 +            }
   17.57 +        }
   17.58 +
   17.59 +        String[] expectNames = {
   17.60 +            "java/lang/Object",
   17.61 +            "java/lang/String",
   17.62 +            "T6887895",
   17.63 +            "T6887895$Test"
   17.64 +        };
   17.65 +
   17.66 +        Set<String> expect = new TreeSet<String>(Arrays.asList(expectNames));
   17.67 +        if (!found.equals(expect)) {
   17.68 +            System.err.println("found: " + found);
   17.69 +            System.err.println("expect: " + expect);
   17.70 +            throw new Exception("unexpected values found");
   17.71 +        }
   17.72 +    }
   17.73 +
   17.74 +    ClassFile getClassFile(String name) throws IOException, ConstantPoolException {
   17.75 +        URL url = getClass().getResource(name);
   17.76 +        InputStream in = url.openStream();
   17.77 +        try {
   17.78 +            return ClassFile.read(in);
   17.79 +        } finally {
   17.80 +            in.close();
   17.81 +        }
   17.82 +    }
   17.83 +
   17.84 +    class Test {
   17.85 +        void m() {
   17.86 +            boolean[] az = new boolean[0];
   17.87 +            boolean[][] aaz = new boolean[0][];
   17.88 +            boolean[][][] aaaz = new boolean[0][][];
   17.89 +
   17.90 +            byte[] ab = new byte[0];
   17.91 +            byte[][] aab = new byte[0][];
   17.92 +            byte[][][] aaab = new byte[0][][];
   17.93 +
   17.94 +            char[] ac = new char[0];
   17.95 +            char[][] aac = new char[0][];
   17.96 +            char[][][] aaac = new char[0][][];
   17.97 +
   17.98 +            double[] ad = new double[0];
   17.99 +            double[][] aad = new double[0][];
  17.100 +            double[][][] aaad = new double[0][][];
  17.101 +
  17.102 +            float[] af = new float[0];
  17.103 +            float[][] aaf = new float[0][];
  17.104 +            float[][][] aaaf = new float[0][][];
  17.105 +
  17.106 +            int[] ai = new int[0];
  17.107 +            int[][] aai = new int[0][];
  17.108 +            int[][][] aaai = new int[0][][];
  17.109 +
  17.110 +            long[] al = new long[0];
  17.111 +            long[][] aal = new long[0][];
  17.112 +            long[][][] aaal = new long[0][][];
  17.113 +
  17.114 +            short[] as = new short[0];
  17.115 +            short[][] aas = new short[0][];
  17.116 +            short[][][] aaas = new short[0][][];
  17.117 +
  17.118 +            String[] aS = new String[0];
  17.119 +            String[][] aaS = new String[0][];
  17.120 +            String[][][] aaaS = new String[0][][];
  17.121 +        }
  17.122 +    }
  17.123 +}
  17.124 +

mercurial