6705935: javac reports path name of entry in ZipFileIndex incorectly

Thu, 22 May 2008 17:40:53 -0700

author
jjg
date
Thu, 22 May 2008 17:40:53 -0700
changeset 38
65a447c75d4b
parent 37
b8c8259e0d2b
child 39
ff3d4fdf9c63
child 40
8852d96b593b

6705935: javac reports path name of entry in ZipFileIndex incorectly
Reviewed-by: darcy

src/share/classes/com/sun/tools/javac/util/JavacFileManager.java file | annotate | diff | comparison | revisions
test/tools/javac/6589361/T6589361.java file | annotate | diff | comparison | revisions
test/tools/javac/T6705935.java file | annotate | diff | comparison | revisions
     1.1 --- a/src/share/classes/com/sun/tools/javac/util/JavacFileManager.java	Thu May 22 16:06:00 2008 -0700
     1.2 +++ b/src/share/classes/com/sun/tools/javac/util/JavacFileManager.java	Thu May 22 17:40:53 2008 -0700
     1.3 @@ -1606,7 +1606,7 @@
     1.4          /** @deprecated see bug 6410637 */
     1.5          @Deprecated
     1.6          public String getPath() {
     1.7 -            return entry.getName() + "(" + entry + ")";
     1.8 +            return zipName + "(" + entry.getName() + ")";
     1.9          }
    1.10  
    1.11          public long getLastModified() {
     2.1 --- a/test/tools/javac/6589361/T6589361.java	Thu May 22 16:06:00 2008 -0700
     2.2 +++ b/test/tools/javac/6589361/T6589361.java	Thu May 22 17:40:53 2008 -0700
     2.3 @@ -24,7 +24,7 @@
     2.4              Iterable<JavaFileObject> files = fm.list(StandardLocation.PLATFORM_CLASS_PATH, "java.lang", set, false);
     2.5              for (JavaFileObject file : files) {
     2.6  
     2.7 -                if (file.toString().startsWith("java" + File.separator + "lang" + File.separator + "Object.class")) {
     2.8 +                if (file.toString().contains("java" + File.separator + "lang" + File.separator + "Object.class")) {
     2.9                      String str = fm.inferBinaryName(StandardLocation.CLASS_PATH, file);
    2.10                      if (!str.equals("java.lang.Object")) {
    2.11                          throw new AssertionError("Error in JavacFileManager.inferBinaryName method!");
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/test/tools/javac/T6705935.java	Thu May 22 17:40:53 2008 -0700
     3.3 @@ -0,0 +1,65 @@
     3.4 +/*
     3.5 + * Copyright 2008 Sun Microsystems, Inc.  All Rights Reserved.
     3.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3.7 + *
     3.8 + * This code is free software; you can redistribute it and/or modify it
     3.9 + * under the terms of the GNU General Public License version 2 only, as
    3.10 + * published by the Free Software Foundation.
    3.11 + *
    3.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
    3.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    3.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    3.15 + * version 2 for more details (a copy is included in the LICENSE file that
    3.16 + * accompanied this code).
    3.17 + *
    3.18 + * You should have received a copy of the GNU General Public License version
    3.19 + * 2 along with this work; if not, write to the Free Software Foundation,
    3.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    3.21 + *
    3.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
    3.23 + * CA 95054 USA or visit www.sun.com if you need additional information or
    3.24 + * have any questions.
    3.25 + */
    3.26 +
    3.27 +/*
    3.28 + * @test
    3.29 + * @bug 6705935
    3.30 + * @summary javac reports path name of entry in ZipFileIndex incorectly
    3.31 + */
    3.32 +
    3.33 +import java.io.*;
    3.34 +import java.util.*;
    3.35 +import javax.tools.*;
    3.36 +import com.sun.tools.javac.util.*;
    3.37 +
    3.38 +public class T6705935 {
    3.39 +    public static void main(String... args) throws Exception {
    3.40 +        new T6705935().run();
    3.41 +    }
    3.42 +
    3.43 +    public void run() throws Exception {
    3.44 +        File java_home = new File(System.getProperty("java.home"));
    3.45 +        if (java_home.getName().equals("jre"))
    3.46 +            java_home = java_home.getParentFile();
    3.47 +
    3.48 +        JavaCompiler c = ToolProvider.getSystemJavaCompiler();
    3.49 +        JavaFileManager fm = c.getStandardFileManager(null, null, null);
    3.50 +        for (JavaFileObject fo: fm.list(StandardLocation.PLATFORM_CLASS_PATH,
    3.51 +                                        "java.lang",
    3.52 +                                        Collections.singleton(JavaFileObject.Kind.CLASS),
    3.53 +                                        false)) {
    3.54 +            String p = ((BaseFileObject)fo).getPath();
    3.55 +            int bra = p.indexOf("(");
    3.56 +            int ket = p.indexOf(")");
    3.57 +            //System.err.println(bra + "," + ket + "," + p.length());
    3.58 +            if (bra == -1 || ket != p.length() -1)
    3.59 +                throw new Exception("unexpected path: " + p + "[" + bra + "," + ket + "," + p.length());
    3.60 +            String part1 = p.substring(0, bra);
    3.61 +            String part2 = p.substring(bra + 1, ket);
    3.62 +            //System.err.println("[" + part1 + "|" + part2 + "]" + " " + java_home);
    3.63 +            if (part1.equals(part2) || !part1.startsWith(java_home.getPath()))
    3.64 +                throw new Exception("bad path: " + p);
    3.65 +
    3.66 +        }
    3.67 +    }
    3.68 +}

mercurial