changeset 449:d1e62f78c48b

Merge
author tbell
date Thu, 15 Oct 2009 22:48:34 -0700
parents 79c13af9217e b8936a7930fe
children 6ba399eff2cb
files
diffstat 17 files changed, 568 insertions(+), 50 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/com/sun/tools/classfile/ConstantPool.java	Thu Oct 15 16:40:44 2009 -0700
+++ b/src/share/classes/com/sun/tools/classfile/ConstantPool.java	Thu Oct 15 22:48:34 2009 -0700
@@ -369,14 +369,33 @@
             return 3;
         }
 
+        /**
+         * Get the raw value of the class referenced by this constant pool entry.
+         * This will either be the name of the class, in internal form, or a
+         * descriptor for an array class.
+         * @return the raw value of the class
+         */
         public String getName() throws ConstantPoolException {
             return cp.getUTF8Value(name_index);
         }
 
+        /**
+         * If this constant pool entry identifies either a class or interface type,
+         * or a possibly multi-dimensional array of a class of interface type,
+         * return the name of the class or interface in internal form. Otherwise,
+         * (i.e. if this is a possibly multi-dimensional array of a primitive type),
+         * return null.
+         * @return the base class or interface name
+         */
         public String getBaseName() throws ConstantPoolException {
             String name = getName();
-            int index = name.indexOf("[L") + 1;
-            return name.substring(index);
+            if (name.startsWith("[")) {
+                int index = name.indexOf("[L");
+                if (index == -1)
+                    return null;
+                return name.substring(index + 2, name.length() - 1);
+            } else
+                return name;
         }
 
         public int getDimensionCount() throws ConstantPoolException {
--- a/src/share/classes/com/sun/tools/javac/file/BaseFileObject.java	Thu Oct 15 16:40:44 2009 -0700
+++ b/src/share/classes/com/sun/tools/javac/file/BaseFileObject.java	Thu Oct 15 22:48:34 2009 -0700
@@ -120,6 +120,14 @@
 
     }
 
+    // force subtypes to define equals
+    @Override
+    public abstract boolean equals(Object other);
+
+    // force subtypes to define hashCode
+    @Override
+    public abstract int hashCode();
+
     /** The file manager that created this JavaFileObject. */
     protected final JavacFileManager fileManager;
 }
--- a/src/share/classes/com/sun/tools/javac/file/JavacFileManager.java	Thu Oct 15 16:40:44 2009 -0700
+++ b/src/share/classes/com/sun/tools/javac/file/JavacFileManager.java	Thu Oct 15 22:48:34 2009 -0700
@@ -968,7 +968,7 @@
             } else {
                 File siblingDir = null;
                 if (sibling != null && sibling instanceof RegularFileObject) {
-                    siblingDir = ((RegularFileObject)sibling).f.getParentFile();
+                    siblingDir = ((RegularFileObject)sibling).file.getParentFile();
                 }
                 return new RegularFileObject(this, new File(siblingDir, fileName.basename()));
             }
--- a/src/share/classes/com/sun/tools/javac/file/RegularFileObject.java	Thu Oct 15 16:40:44 2009 -0700
+++ b/src/share/classes/com/sun/tools/javac/file/RegularFileObject.java	Thu Oct 15 22:48:34 2009 -0700
@@ -33,6 +33,8 @@
 import java.io.OutputStream;
 import java.io.OutputStreamWriter;
 import java.io.Writer;
+import java.lang.ref.Reference;
+import java.lang.ref.SoftReference;
 import java.net.URI;
 import java.nio.ByteBuffer;
 import java.nio.CharBuffer;
@@ -53,7 +55,8 @@
      */
     private boolean hasParents = false;
     private String name;
-    final File f;
+    final File file;
+    private Reference<File> absFileRef;
 
     public RegularFileObject(JavacFileManager fileManager, File f) {
         this(fileManager, f.getName(), f);
@@ -65,17 +68,17 @@
             throw new IllegalArgumentException("directories not supported");
         }
         this.name = name;
-        this.f = f;
+        this.file = f;
     }
 
     @Override
     public URI toUri() {
-        return f.toURI().normalize();
+        return file.toURI().normalize();
     }
 
     @Override
     public String getName() {
-        return f.getPath();
+        return file.getPath();
     }
 
     @Override
@@ -90,20 +93,20 @@
 
     @Override
     public InputStream openInputStream() throws IOException {
-        return new FileInputStream(f);
+        return new FileInputStream(file);
     }
 
     @Override
     public OutputStream openOutputStream() throws IOException {
         ensureParentDirectoriesExist();
-        return new FileOutputStream(f);
+        return new FileOutputStream(file);
     }
 
     @Override
     public CharBuffer getCharContent(boolean ignoreEncodingErrors) throws IOException {
         CharBuffer cb = fileManager.getCachedContent(this);
         if (cb == null) {
-            InputStream in = new FileInputStream(f);
+            InputStream in = new FileInputStream(file);
             try {
                 ByteBuffer bb = fileManager.makeByteBuffer(in);
                 JavaFileObject prev = fileManager.log.useSource(this);
@@ -126,17 +129,17 @@
     @Override
     public Writer openWriter() throws IOException {
         ensureParentDirectoriesExist();
-        return new OutputStreamWriter(new FileOutputStream(f), fileManager.getEncodingName());
+        return new OutputStreamWriter(new FileOutputStream(file), fileManager.getEncodingName());
     }
 
     @Override
     public long getLastModified() {
-        return f.lastModified();
+        return file.lastModified();
     }
 
     @Override
     public boolean delete() {
-        return f.delete();
+        return file.delete();
     }
 
     @Override
@@ -146,7 +149,7 @@
 
     @Override
     protected String inferBinaryName(Iterable<? extends File> path) {
-        String fPath = f.getPath();
+        String fPath = file.getPath();
         //System.err.println("RegularFileObject " + file + " " +r.getPath());
         for (File dir: path) {
             //System.err.println("dir: " + dir);
@@ -178,7 +181,7 @@
         if (name.equalsIgnoreCase(n)) {
             try {
                 // allow for Windows
-                return f.getCanonicalFile().getName().equals(n);
+                return file.getCanonicalFile().getName().equals(n);
             } catch (IOException e) {
             }
         }
@@ -187,7 +190,7 @@
 
     private void ensureParentDirectoriesExist() throws IOException {
         if (!hasParents) {
-            File parent = f.getParentFile();
+            File parent = file.getParentFile();
             if (parent != null && !parent.exists()) {
                 if (!parent.mkdirs()) {
                     if (!parent.exists() || !parent.isDirectory()) {
@@ -199,21 +202,34 @@
         }
     }
 
+    /**
+     * Check if two file objects are equal.
+     * Two RegularFileObjects are equal if the absolute paths of the underlying
+     * files are equal.
+     */
     @Override
     public boolean equals(Object other) {
-        if (!(other instanceof RegularFileObject)) {
+        if (this == other)
+            return true;
+
+        if (!(other instanceof RegularFileObject))
             return false;
-        }
+
         RegularFileObject o = (RegularFileObject) other;
-        try {
-            return f.equals(o.f) || f.getCanonicalFile().equals(o.f.getCanonicalFile());
-        } catch (IOException e) {
-            return false;
-        }
+        return getAbsoluteFile().equals(o.getAbsoluteFile());
     }
 
     @Override
     public int hashCode() {
-        return f.hashCode();
+        return getAbsoluteFile().hashCode();
+    }
+
+    private File getAbsoluteFile() {
+        File absFile = (absFileRef == null ? null : absFileRef.get());
+        if (absFile == null) {
+            absFile = file.getAbsoluteFile();
+            absFileRef = new SoftReference<File>(absFile);
+        }
+        return absFile;
     }
 }
--- a/src/share/classes/com/sun/tools/javac/file/SymbolArchive.java	Thu Oct 15 16:40:44 2009 -0700
+++ b/src/share/classes/com/sun/tools/javac/file/SymbolArchive.java	Thu Oct 15 22:48:34 2009 -0700
@@ -76,13 +76,13 @@
     @Override
     public JavaFileObject getFileObject(RelativeDirectory subdirectory, String file) {
         RelativeDirectory prefix_subdir = new RelativeDirectory(prefix, subdirectory.path);
-        ZipEntry ze = new RelativeFile(prefix_subdir, file).getZipEntry(zdir);
+        ZipEntry ze = new RelativeFile(prefix_subdir, file).getZipEntry(zfile);
         return new SymbolFileObject(this, file, ze);
     }
 
     @Override
     public String toString() {
-        return "SymbolArchive[" + zdir.getName() + "]";
+        return "SymbolArchive[" + zfile.getName() + "]";
     }
 
     /**
--- a/src/share/classes/com/sun/tools/javac/file/ZipArchive.java	Thu Oct 15 16:40:44 2009 -0700
+++ b/src/share/classes/com/sun/tools/javac/file/ZipArchive.java	Thu Oct 15 22:48:34 2009 -0700
@@ -47,6 +47,8 @@
 import com.sun.tools.javac.file.RelativePath.RelativeDirectory;
 import com.sun.tools.javac.file.RelativePath.RelativeFile;
 import com.sun.tools.javac.util.List;
+import java.lang.ref.Reference;
+import java.lang.ref.SoftReference;
 
 /**
  * <p><b>This is NOT part of any API supported by Sun Microsystems.
@@ -56,20 +58,20 @@
  */
 public class ZipArchive implements Archive {
 
-    public ZipArchive(JavacFileManager fm, ZipFile zdir) throws IOException {
-        this(fm, zdir, true);
+    public ZipArchive(JavacFileManager fm, ZipFile zfile) throws IOException {
+        this(fm, zfile, true);
     }
 
-    protected ZipArchive(JavacFileManager fm, ZipFile zdir, boolean initMap) throws IOException {
+    protected ZipArchive(JavacFileManager fm, ZipFile zfile, boolean initMap) throws IOException {
         this.fileManager = fm;
-        this.zdir = zdir;
+        this.zfile = zfile;
         this.map = new HashMap<RelativeDirectory,List<String>>();
         if (initMap)
             initMap();
     }
 
     protected void initMap() throws IOException {
-        for (Enumeration<? extends ZipEntry> e = zdir.entries(); e.hasMoreElements(); ) {
+        for (Enumeration<? extends ZipEntry> e = zfile.entries(); e.hasMoreElements(); ) {
             ZipEntry entry;
             try {
                 entry = e.nextElement();
@@ -110,7 +112,7 @@
     }
 
     public JavaFileObject getFileObject(RelativeDirectory subdirectory, String file) {
-        ZipEntry ze = new RelativeFile(subdirectory, file).getZipEntry(zdir);
+        ZipEntry ze = new RelativeFile(subdirectory, file).getZipEntry(zfile);
         return new ZipFileObject(this, file, ze);
     }
 
@@ -119,17 +121,39 @@
     }
 
     public void close() throws IOException {
-        zdir.close();
+        zfile.close();
     }
 
     @Override
     public String toString() {
-        return "ZipArchive[" + zdir.getName() + "]";
+        return "ZipArchive[" + zfile.getName() + "]";
     }
 
+    private File getAbsoluteFile() {
+        File absFile = (absFileRef == null ? null : absFileRef.get());
+        if (absFile == null) {
+            absFile = new File(zfile.getName()).getAbsoluteFile();
+            absFileRef = new SoftReference<File>(absFile);
+        }
+        return absFile;
+    }
+
+    /**
+     * The file manager that created this archive.
+     */
     protected JavacFileManager fileManager;
+    /**
+     * The index for the contents of this archive.
+     */
     protected final Map<RelativeDirectory,List<String>> map;
-    protected final ZipFile zdir;
+    /**
+     * The zip file for the archive.
+     */
+    protected final ZipFile zfile;
+    /**
+     * A reference to the absolute filename for the zip file for the archive.
+     */
+    protected Reference<File> absFileRef;
 
     /**
      * A subclass of JavaFileObject representing zip entries.
@@ -148,18 +172,18 @@
         }
 
         public URI toUri() {
-            File zipFile = new File(zarch.zdir.getName());
+            File zipFile = new File(zarch.zfile.getName());
             return createJarUri(zipFile, entry.getName());
         }
 
         @Override
         public String getName() {
-            return zarch.zdir.getName() + "(" + entry.getName() + ")";
+            return zarch.zfile.getName() + "(" + entry.getName() + ")";
         }
 
         @Override
         public String getShortName() {
-            return new File(zarch.zdir.getName()).getName() + "(" + entry + ")";
+            return new File(zarch.zfile.getName()).getName() + "(" + entry + ")";
         }
 
         @Override
@@ -169,7 +193,7 @@
 
         @Override
         public InputStream openInputStream() throws IOException {
-            return zarch.zdir.getInputStream(entry);
+            return zarch.zfile.getInputStream(entry);
         }
 
         @Override
@@ -181,7 +205,7 @@
         public CharBuffer getCharContent(boolean ignoreEncodingErrors) throws IOException {
             CharBuffer cb = fileManager.getCachedContent(this);
             if (cb == null) {
-                InputStream in = zarch.zdir.getInputStream(entry);
+                InputStream in = zarch.zfile.getInputStream(entry);
                 try {
                     ByteBuffer bb = fileManager.makeByteBuffer(in);
                     JavaFileObject prev = fileManager.log.useSource(this);
@@ -237,18 +261,27 @@
             return name.equals(cn + k.extension);
         }
 
+        /**
+         * Check if two file objects are equal.
+         * Two ZipFileObjects are equal if the absolute paths of the underlying
+         * zip files are equal and if the paths within those zip files are equal.
+         */
         @Override
         public boolean equals(Object other) {
-            if (!(other instanceof ZipFileObject)) {
+            if (this == other)
+                return true;
+
+            if (!(other instanceof ZipFileObject))
                 return false;
-            }
+
             ZipFileObject o = (ZipFileObject) other;
-            return zarch.zdir.equals(o.zarch.zdir) || name.equals(o.name);
+            return zarch.getAbsoluteFile().equals(o.zarch.getAbsoluteFile())
+                    && name.equals(o.name);
         }
 
         @Override
         public int hashCode() {
-            return zarch.zdir.hashCode() + name.hashCode();
+            return zarch.getAbsoluteFile().hashCode() + name.hashCode();
         }
     }
 
--- a/src/share/classes/com/sun/tools/javac/file/ZipFileIndex.java	Thu Oct 15 16:40:44 2009 -0700
+++ b/src/share/classes/com/sun/tools/javac/file/ZipFileIndex.java	Thu Oct 15 22:48:34 2009 -0700
@@ -30,6 +30,7 @@
 import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.io.RandomAccessFile;
+import java.lang.ref.Reference;
 import java.lang.ref.SoftReference;
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -89,6 +90,7 @@
 
     // ZipFileIndex data entries
     private File zipFile;
+    private Reference<File> absFileRef;
     private long zipFileLastModified = NOT_MODIFIED;
     private RandomAccessFile zipRandomFile;
     private Entry[] entries;
@@ -1215,6 +1217,15 @@
         return zipFile;
     }
 
+    File getAbsoluteFile() {
+        File absFile = (absFileRef == null ? null : absFileRef.get());
+        if (absFile == null) {
+            absFile = zipFile.getAbsoluteFile();
+            absFileRef = new SoftReference<File>(absFile);
+        }
+        return absFile;
+    }
+
     private RelativeDirectory getRelativeDirectory(String path) {
         RelativeDirectory rd;
         SoftReference<RelativeDirectory> ref = relativeDirectoryCache.get(path);
--- a/src/share/classes/com/sun/tools/javac/file/ZipFileIndexArchive.java	Thu Oct 15 16:40:44 2009 -0700
+++ b/src/share/classes/com/sun/tools/javac/file/ZipFileIndexArchive.java	Thu Oct 15 22:48:34 2009 -0700
@@ -219,17 +219,27 @@
             return name.equals(cn + k.extension);
         }
 
+        /**
+         * Check if two file objects are equal.
+         * Two ZipFileIndexFileObjects are equal if the absolute paths of the underlying
+         * zip files are equal and if the paths within those zip files are equal.
+         */
         @Override
         public boolean equals(Object other) {
+            if (this == other)
+                return true;
+
             if (!(other instanceof ZipFileIndexFileObject))
                 return false;
+
             ZipFileIndexFileObject o = (ZipFileIndexFileObject) other;
-            return entry.equals(o.entry);
+            return zfIndex.getAbsoluteFile().equals(o.zfIndex.getAbsoluteFile())
+                    && name.equals(o.name);
         }
 
         @Override
         public int hashCode() {
-            return zipName.hashCode() + (name.hashCode() << 10);
+            return zfIndex.getAbsoluteFile().hashCode() + name.hashCode();
         }
 
         private String getPrefixedEntryName() {
--- a/src/share/classes/com/sun/tools/javac/jvm/ClassReader.java	Thu Oct 15 16:40:44 2009 -0700
+++ b/src/share/classes/com/sun/tools/javac/jvm/ClassReader.java	Thu Oct 15 22:48:34 2009 -0700
@@ -2632,10 +2632,20 @@
             return true; // fail-safe mode
         }
 
+        /**
+         * Check if two file objects are equal.
+         * SourceFileObjects are just placeholder objects for the value of a
+         * SourceFile attribute, and do not directly represent specific files.
+         * Two SourceFileObjects are equal if their names are equal.
+         */
         @Override
         public boolean equals(Object other) {
+            if (this == other)
+                return true;
+
             if (!(other instanceof SourceFileObject))
                 return false;
+
             SourceFileObject o = (SourceFileObject) other;
             return name.equals(o.name);
         }
--- a/src/share/classes/com/sun/tools/javac/parser/Scanner.java	Thu Oct 15 16:40:44 2009 -0700
+++ b/src/share/classes/com/sun/tools/javac/parser/Scanner.java	Thu Oct 15 22:48:34 2009 -0700
@@ -876,7 +876,11 @@
                         }
                         scanChar();
                         skipIllegalUnderscores();
-                        scanNumber(2);
+                        if (digit(2) < 0) {
+                            lexError("invalid.binary.number");
+                        } else {
+                            scanNumber(2);
+                        }
                     } else {
                         putChar('0');
                         if (ch == '_') {
--- a/src/share/classes/com/sun/tools/javac/resources/compiler.properties	Thu Oct 15 16:40:44 2009 -0700
+++ b/src/share/classes/com/sun/tools/javac/resources/compiler.properties	Thu Oct 15 22:48:34 2009 -0700
@@ -252,6 +252,8 @@
     interface methods cannot have body
 compiler.err.invalid.annotation.member.type=\
     invalid type for annotation member
+compiler.err.invalid.binary.number=\
+    binary numbers must contain at least one binary digit
 compiler.err.invalid.hex.number=\
     hexadecimal numbers must contain at least one hexadecimal digit
 compiler.err.invalid.meth.decl.ret.type.req=\
--- a/src/share/classes/javax/lang/model/util/Elements.java	Thu Oct 15 16:40:44 2009 -0700
+++ b/src/share/classes/javax/lang/model/util/Elements.java	Thu Oct 15 22:48:34 2009 -0700
@@ -77,9 +77,25 @@
      * Returns the text of the documentation (&quot;Javadoc&quot;)
      * comment of an element.
      *
+     * <p> A documentation comment of an element is a comment that
+     * begins with "{@code /**}" , ends with a separate
+     * "<code>*&#47</code>", and immediately precedes the element,
+     * ignoring white space.  Therefore, a documentation comment
+     * contains at least three"{@code *}" characters.  The text
+     * returned for the documentation comment is a processed form of
+     * the comment as it appears in source code.  The leading "{@code
+     * /**}" and trailing "<code>*&#47</code>" are removed.  For lines
+     * of the comment starting after the initial "{@code /**}",
+     * leading white space characters are discarded as are any
+     * consecutive "{@code *}" characters appearing after the white
+     * space or starting the line.  The processed lines are then
+     * concatenated together (including line terminators) and
+     * returned.
+     *
      * @param e  the element being examined
      * @return the documentation comment of the element, or {@code null}
      *          if there is none
+     * @jls3 3.6 White Space
      */
     String getDocComment(Element e);
 
--- a/test/tools/javac/api/6440528/T6440528.java	Thu Oct 15 16:40:44 2009 -0700
+++ b/test/tools/javac/api/6440528/T6440528.java	Thu Oct 15 22:48:34 2009 -0700
@@ -59,9 +59,9 @@
     }
 
     private File getUnderlyingFile(Object o) throws Exception {
-        Field f = o.getClass().getDeclaredField("f");
-        f.setAccessible(true);
-        return (File)f.get(o);
+        Field file = o.getClass().getDeclaredField("file");
+        file.setAccessible(true);
+        return (File)file.get(o);
     }
 
     public static void main(String... args) throws Exception {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/api/T6838467.java	Thu Oct 15 22:48:34 2009 -0700
@@ -0,0 +1,249 @@
+/*
+ * Copyright 2009 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/*
+ * @test
+ * @bug 6838467
+ * @summary JSR199 FileObjects don't obey general contract of equals.
+ */
+
+import java.io.*;
+import java.util.*;
+import java.util.zip.*;
+import javax.tools.*;
+import com.sun.tools.javac.file.JavacFileManager;
+import com.sun.tools.javac.util.Context;
+
+public class T6838467 {
+    boolean fileSystemIsCaseSignificant = !new File("a").equals(new File("A"));
+
+    enum FileKind {
+        DIR("dir"),
+        ZIP("zip"),
+        ZIPFILEINDEX("zip");
+        FileKind(String path) {
+            file = new File(path);
+        }
+        final File file;
+    };
+
+    enum CompareKind {
+        SAME {
+            File other(File f) { return f; }
+        },
+        ABSOLUTE {
+            File other(File f) { return f.getAbsoluteFile(); }
+        },
+        DIFFERENT {
+            File other(File f) { return new File("not_" + f.getPath()); }
+        },
+        CASEEQUIV {
+            File other(File f) { return new File(f.getPath().toUpperCase()); }
+        };
+        abstract File other(File f);
+    };
+
+    String[] paths = { "p/A.java", "p/B.java", "p/C.java" };
+
+    public static void main(String... args) throws Exception {
+        new T6838467().run();
+    }
+
+    void run() throws Exception {
+        // on Windows, verify file system is not case significant
+        if (System.getProperty("os.name").toLowerCase().startsWith("windows")
+                && fileSystemIsCaseSignificant) {
+            error("fileSystemIsCaseSignificant is set on Windows.");
+        }
+
+        // create a set of directories and zip files to compare
+        createTestDir(new File("dir"), paths);
+        createTestDir(new File("not_dir"), paths);
+        createTestZip(new File("zip"), paths);
+        createTestZip(new File("not_zip"), paths);
+        if (fileSystemIsCaseSignificant) {
+            createTestDir(new File("DIR"), paths);
+            createTestZip(new File("ZIP"), paths);
+        }
+
+        // test the various sorts of file objects that can be obtained from
+        // the file manager, and for various values that may or may not match.
+        for (FileKind fk: FileKind.values()) {
+            for (CompareKind ck: CompareKind.values()) {
+                test(fk, ck);
+            }
+        }
+
+        // verify that the various different types of file object were all
+        // tested
+        Set<String> expectClasses = new HashSet<String>(Arrays.asList(
+                "RegularFileObject", "ZipFileObject", "ZipFileIndexFileObject" ));
+        if (!foundClasses.equals(expectClasses)) {
+            error("expected fileobject classes not found\n"
+                    + "expected: " + expectClasses + "\n"
+                    + "found: " + foundClasses);
+        }
+
+        if (errors > 0)
+            throw new Exception(errors + " errors");
+    }
+
+    void test(FileKind fk, CompareKind ck) throws IOException {
+        File f1 = fk.file;
+        JavaFileManager fm1 = createFileManager(fk, f1);
+
+        File f2 = ck.other(fk.file);
+        JavaFileManager fm2 = createFileManager(fk, f2);
+
+        try {
+            // If the directories or zip files match, we expect "n" matches in
+            // the "n-squared" comparisons to come, where "n" is the number of
+            // entries in the the directories or zip files.
+            // If the directories or zip files don't themselves match,
+            // we obviously don't expect any of their contents to match either.
+            int expect = (f1.getAbsoluteFile().equals(f2.getAbsoluteFile()) ? paths.length : 0);
+
+            System.err.println("test " + (++count) + " " + fk + " " + ck + " " + f1 + " " + f2);
+            test(fm1, fm2, expect);
+
+        } finally {
+            fm1.close();
+            fm2.close();
+        }
+    }
+
+    // For a pair of file managers that may or may not have similar entries
+    // on the classpath, compare all files returned from one against all files
+    // returned from the other.  For each pair of files, verify that if they
+    // are equal, the hashcode is equal as well, and finally verify that the
+    // expected number of matches was found.
+    void test(JavaFileManager fm1, JavaFileManager fm2, int expectEqualCount) throws IOException {
+        boolean foundFiles1 = false;
+        boolean foundFiles2 = false;
+        int foundEqualCount = 0;
+        Set<JavaFileObject.Kind> kinds =  EnumSet.allOf(JavaFileObject.Kind.class);
+        for (FileObject fo1: fm1.list(StandardLocation.CLASS_PATH, "p", kinds, false)) {
+            foundFiles1 = true;
+            foundClasses.add(fo1.getClass().getSimpleName());
+            for (FileObject fo2: fm2.list(StandardLocation.CLASS_PATH, "p", kinds, false)) {
+                foundFiles2 = true;
+                foundClasses.add(fo1.getClass().getSimpleName());
+                System.err.println("compare " + fo1 + " " + fo2);
+                if (fo1.equals(fo2)) {
+                    foundEqualCount++;
+                    int hash1 = fo1.hashCode();
+                    int hash2 = fo2.hashCode();
+                    if (hash1 != hash2)
+                        error("hashCode error: " + fo1 + " [" + hash1 + "] "
+                                + fo2 + " [" + hash2 + "]");
+                }
+            }
+        }
+        if (!foundFiles1)
+            error("no files found for file manager 1");
+        if (!foundFiles2)
+            error("no files found for file manager 2");
+        // verify the expected number of matches were found
+        if (foundEqualCount != expectEqualCount)
+            error("expected matches not found: expected " + expectEqualCount + ", found " + foundEqualCount);
+    }
+
+    // create a file manager to test a FileKind, with a given directory
+    // or zip file placed on the classpath
+    JavaFileManager createFileManager(FileKind fk, File classpath) throws IOException {
+        StandardJavaFileManager fm = createFileManager(fk == FileKind.ZIP);
+        fm.setLocation(StandardLocation.CLASS_PATH, Arrays.asList(classpath));
+        return fm;
+    }
+
+    JavacFileManager createFileManager(boolean useJavaUtilZip) {
+        // javac should really not be using system properties like this
+        // -- it should really be using (hidden) options -- but until then
+        // take care to leave system properties as we find them, so as not
+        // to adversely affect other tests that might follow.
+        String prev = System.getProperty("useJavaUtilZip");
+        boolean resetProperties = false;
+        try {
+            if (useJavaUtilZip) {
+                System.setProperty("useJavaUtilZip", "true");
+                resetProperties = true;
+            } else if (System.getProperty("useJavaUtilZip") != null) {
+                System.getProperties().remove("useJavaUtilZip");
+                resetProperties = true;
+            }
+
+            Context c = new Context();
+            return new JavacFileManager(c, false, null);
+        } finally {
+            if (resetProperties) {
+                if (prev == null) {
+                    System.getProperties().remove("useJavaUtilZip");
+                } else {
+                    System.setProperty("useJavaUtilZip", prev);
+                }
+            }
+        }
+    }
+
+    // create a directory containing a given set of paths
+    void createTestDir(File dir, String[] paths) throws IOException {
+        for (String p: paths) {
+            File file = new File(dir, p);
+            file.getParentFile().mkdirs();
+            FileWriter out = new FileWriter(file);
+            try {
+                out.write(p);
+            } finally {
+                out.close();
+            }
+        }
+    }
+
+    // create a sip file containing a given set of entries
+    void createTestZip(File zip, String[] paths) throws IOException {
+        if (zip.getParentFile() != null)
+            zip.getParentFile().mkdirs();
+        ZipOutputStream zos = new ZipOutputStream(new FileOutputStream(zip));
+        try {
+            for (String p: paths) {
+                ZipEntry ze = new ZipEntry(p);
+                zos.putNextEntry(ze);
+                byte[] bytes = p.getBytes();
+                zos.write(bytes, 0, bytes.length);
+                zos.closeEntry();
+            }
+        } finally {
+            zos.close();
+        }
+    }
+
+    void error(String msg) {
+        System.err.println("Error: " + msg);
+        errors++;
+    }
+
+    int count;
+    int errors;
+    Set<String> foundClasses = new HashSet<String>();
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/literals/T6891079.java	Thu Oct 15 22:48:34 2009 -0700
@@ -0,0 +1,12 @@
+/* @test /nodynamiccopyright/
+ * @bug 6891079
+ * @summary Compiler allows invalid binary literals 0b and oBL
+ * @compile/fail/ref=T6891079.out -XDrawDiagnostics T6891079.java
+ */
+
+class Test {
+    int bi = 0B;
+    long bl = 0BL;
+    int xi = 0X;
+    long xl = 0XL;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/literals/T6891079.out	Thu Oct 15 22:48:34 2009 -0700
@@ -0,0 +1,7 @@
+T6891079.java:8:14: compiler.err.invalid.binary.number
+T6891079.java:9:15: compiler.err.invalid.binary.number
+T6891079.java:9:18: compiler.err.expected: token.identifier
+T6891079.java:10:14: compiler.err.invalid.hex.number
+T6891079.java:11:15: compiler.err.invalid.hex.number
+T6891079.java:11:18: compiler.err.expected: token.identifier
+6 errors
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javap/classfile/T6887895.java	Thu Oct 15 22:48:34 2009 -0700
@@ -0,0 +1,121 @@
+/*
+ * Copyright 2009 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/*
+ * @test
+ * @bug 6887895
+ * @summary CONSTANT_Class_info getBaseName does not handle arrays of primitives correctly
+ */
+
+import java.io.*;
+import java.net.*;
+import java.util.*;
+import com.sun.tools.classfile.*;
+import com.sun.tools.classfile.ConstantPool.*;
+
+public class T6887895 {
+    public static void main(String[] args) throws Exception {
+        new T6887895().run();
+    }
+
+    void run() throws Exception {
+        Set<String> found = new TreeSet<String>();
+
+        ClassFile cf = getClassFile("T6887895$Test.class");
+        for (CPInfo cpInfo: cf.constant_pool.entries()) {
+            if (cpInfo instanceof CONSTANT_Class_info) {
+                CONSTANT_Class_info info = (CONSTANT_Class_info) cpInfo;
+                String name = info.getName();
+                String baseName = info.getBaseName();
+                System.out.println("found: " + name + " " + baseName);
+                if (baseName != null)
+                    found.add(baseName);
+            }
+        }
+
+        String[] expectNames = {
+            "java/lang/Object",
+            "java/lang/String",
+            "T6887895",
+            "T6887895$Test"
+        };
+
+        Set<String> expect = new TreeSet<String>(Arrays.asList(expectNames));
+        if (!found.equals(expect)) {
+            System.err.println("found: " + found);
+            System.err.println("expect: " + expect);
+            throw new Exception("unexpected values found");
+        }
+    }
+
+    ClassFile getClassFile(String name) throws IOException, ConstantPoolException {
+        URL url = getClass().getResource(name);
+        InputStream in = url.openStream();
+        try {
+            return ClassFile.read(in);
+        } finally {
+            in.close();
+        }
+    }
+
+    class Test {
+        void m() {
+            boolean[] az = new boolean[0];
+            boolean[][] aaz = new boolean[0][];
+            boolean[][][] aaaz = new boolean[0][][];
+
+            byte[] ab = new byte[0];
+            byte[][] aab = new byte[0][];
+            byte[][][] aaab = new byte[0][][];
+
+            char[] ac = new char[0];
+            char[][] aac = new char[0][];
+            char[][][] aaac = new char[0][][];
+
+            double[] ad = new double[0];
+            double[][] aad = new double[0][];
+            double[][][] aaad = new double[0][][];
+
+            float[] af = new float[0];
+            float[][] aaf = new float[0][];
+            float[][][] aaaf = new float[0][][];
+
+            int[] ai = new int[0];
+            int[][] aai = new int[0][];
+            int[][][] aaai = new int[0][][];
+
+            long[] al = new long[0];
+            long[][] aal = new long[0][];
+            long[][][] aaal = new long[0][][];
+
+            short[] as = new short[0];
+            short[][] aas = new short[0][];
+            short[][][] aaas = new short[0][][];
+
+            String[] aS = new String[0];
+            String[][] aaS = new String[0][];
+            String[][][] aaaS = new String[0][][];
+        }
+    }
+}
+