test/tools/javac/T6705935.java

Fri, 21 Aug 2009 14:58:21 -0700

author
jjg
date
Fri, 21 Aug 2009 14:58:21 -0700
changeset 377
d9febdd5ae21
parent 50
b9bcea8bbe24
child 415
49359d0e6a9c
permissions
-rw-r--r--

6873845: refine access to symbol file
Reviewed-by: darcy

jjg@38 1 /*
jjg@38 2 * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved.
jjg@38 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
jjg@38 4 *
jjg@38 5 * This code is free software; you can redistribute it and/or modify it
jjg@38 6 * under the terms of the GNU General Public License version 2 only, as
jjg@38 7 * published by the Free Software Foundation.
jjg@38 8 *
jjg@38 9 * This code is distributed in the hope that it will be useful, but WITHOUT
jjg@38 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
jjg@38 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
jjg@38 12 * version 2 for more details (a copy is included in the LICENSE file that
jjg@38 13 * accompanied this code).
jjg@38 14 *
jjg@38 15 * You should have received a copy of the GNU General Public License version
jjg@38 16 * 2 along with this work; if not, write to the Free Software Foundation,
jjg@38 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
jjg@38 18 *
jjg@38 19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
jjg@38 20 * CA 95054 USA or visit www.sun.com if you need additional information or
jjg@38 21 * have any questions.
jjg@38 22 */
jjg@38 23
jjg@38 24 /*
jjg@38 25 * @test
jjg@38 26 * @bug 6705935
jjg@38 27 * @summary javac reports path name of entry in ZipFileIndex incorectly
jjg@38 28 */
jjg@38 29
jjg@38 30 import java.io.*;
jjg@38 31 import java.util.*;
jjg@38 32 import javax.tools.*;
jjg@50 33 import com.sun.tools.javac.file.*;
jjg@38 34
jjg@38 35 public class T6705935 {
jjg@38 36 public static void main(String... args) throws Exception {
jjg@38 37 new T6705935().run();
jjg@38 38 }
jjg@38 39
jjg@38 40 public void run() throws Exception {
jjg@38 41 File java_home = new File(System.getProperty("java.home"));
jjg@38 42 if (java_home.getName().equals("jre"))
jjg@38 43 java_home = java_home.getParentFile();
jjg@38 44
jjg@38 45 JavaCompiler c = ToolProvider.getSystemJavaCompiler();
jjg@38 46 JavaFileManager fm = c.getStandardFileManager(null, null, null);
jjg@38 47 for (JavaFileObject fo: fm.list(StandardLocation.PLATFORM_CLASS_PATH,
jjg@38 48 "java.lang",
jjg@38 49 Collections.singleton(JavaFileObject.Kind.CLASS),
jjg@38 50 false)) {
jjg@38 51 String p = ((BaseFileObject)fo).getPath();
jjg@38 52 int bra = p.indexOf("(");
jjg@38 53 int ket = p.indexOf(")");
jjg@38 54 //System.err.println(bra + "," + ket + "," + p.length());
jjg@38 55 if (bra == -1 || ket != p.length() -1)
jjg@38 56 throw new Exception("unexpected path: " + p + "[" + bra + "," + ket + "," + p.length());
jjg@38 57 String part1 = p.substring(0, bra);
jjg@38 58 String part2 = p.substring(bra + 1, ket);
jjg@38 59 //System.err.println("[" + part1 + "|" + part2 + "]" + " " + java_home);
jjg@38 60 if (part1.equals(part2) || !part1.startsWith(java_home.getPath()))
jjg@38 61 throw new Exception("bad path: " + p);
jjg@38 62
jjg@38 63 }
jjg@38 64 }
jjg@38 65 }

mercurial