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