author | mchung |
Wed, 27 May 2015 13:25:18 -0700 | |
changeset 30846 | 2b3f379840f0 |
parent 30730 | d3ce7619db2c |
permissions | -rw-r--r-- |
4071
10c876d2de66
6887895: CONSTANT_Class_info getBaseName does not handle arrays of primitives correctly
jjg
parents:
diff
changeset
|
1 |
/* |
30730
d3ce7619db2c
8076543: Add @modules as needed to the langtools tests
akulyakh
parents:
5520
diff
changeset
|
2 |
* Copyright (c) 2009, 2015, Oracle and/or its affiliates. All rights reserved. |
4071
10c876d2de66
6887895: CONSTANT_Class_info getBaseName does not handle arrays of primitives correctly
jjg
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
10c876d2de66
6887895: CONSTANT_Class_info getBaseName does not handle arrays of primitives correctly
jjg
parents:
diff
changeset
|
4 |
* |
10c876d2de66
6887895: CONSTANT_Class_info getBaseName does not handle arrays of primitives correctly
jjg
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
10c876d2de66
6887895: CONSTANT_Class_info getBaseName does not handle arrays of primitives correctly
jjg
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
10c876d2de66
6887895: CONSTANT_Class_info getBaseName does not handle arrays of primitives correctly
jjg
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
10c876d2de66
6887895: CONSTANT_Class_info getBaseName does not handle arrays of primitives correctly
jjg
parents:
diff
changeset
|
8 |
* |
10c876d2de66
6887895: CONSTANT_Class_info getBaseName does not handle arrays of primitives correctly
jjg
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
10c876d2de66
6887895: CONSTANT_Class_info getBaseName does not handle arrays of primitives correctly
jjg
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
10c876d2de66
6887895: CONSTANT_Class_info getBaseName does not handle arrays of primitives correctly
jjg
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
10c876d2de66
6887895: CONSTANT_Class_info getBaseName does not handle arrays of primitives correctly
jjg
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
10c876d2de66
6887895: CONSTANT_Class_info getBaseName does not handle arrays of primitives correctly
jjg
parents:
diff
changeset
|
13 |
* accompanied this code). |
10c876d2de66
6887895: CONSTANT_Class_info getBaseName does not handle arrays of primitives correctly
jjg
parents:
diff
changeset
|
14 |
* |
10c876d2de66
6887895: CONSTANT_Class_info getBaseName does not handle arrays of primitives correctly
jjg
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
10c876d2de66
6887895: CONSTANT_Class_info getBaseName does not handle arrays of primitives correctly
jjg
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
10c876d2de66
6887895: CONSTANT_Class_info getBaseName does not handle arrays of primitives correctly
jjg
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
10c876d2de66
6887895: CONSTANT_Class_info getBaseName does not handle arrays of primitives correctly
jjg
parents:
diff
changeset
|
18 |
* |
5520 | 19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
20 |
* or visit www.oracle.com if you need additional information or have any |
|
21 |
* questions. |
|
4071
10c876d2de66
6887895: CONSTANT_Class_info getBaseName does not handle arrays of primitives correctly
jjg
parents:
diff
changeset
|
22 |
*/ |
10c876d2de66
6887895: CONSTANT_Class_info getBaseName does not handle arrays of primitives correctly
jjg
parents:
diff
changeset
|
23 |
|
10c876d2de66
6887895: CONSTANT_Class_info getBaseName does not handle arrays of primitives correctly
jjg
parents:
diff
changeset
|
24 |
/* |
10c876d2de66
6887895: CONSTANT_Class_info getBaseName does not handle arrays of primitives correctly
jjg
parents:
diff
changeset
|
25 |
* @test |
10c876d2de66
6887895: CONSTANT_Class_info getBaseName does not handle arrays of primitives correctly
jjg
parents:
diff
changeset
|
26 |
* @bug 6887895 |
10c876d2de66
6887895: CONSTANT_Class_info getBaseName does not handle arrays of primitives correctly
jjg
parents:
diff
changeset
|
27 |
* @summary CONSTANT_Class_info getBaseName does not handle arrays of primitives correctly |
30846 | 28 |
* @modules jdk.jdeps/com.sun.tools.classfile |
4071
10c876d2de66
6887895: CONSTANT_Class_info getBaseName does not handle arrays of primitives correctly
jjg
parents:
diff
changeset
|
29 |
*/ |
10c876d2de66
6887895: CONSTANT_Class_info getBaseName does not handle arrays of primitives correctly
jjg
parents:
diff
changeset
|
30 |
|
10c876d2de66
6887895: CONSTANT_Class_info getBaseName does not handle arrays of primitives correctly
jjg
parents:
diff
changeset
|
31 |
import java.io.*; |
10c876d2de66
6887895: CONSTANT_Class_info getBaseName does not handle arrays of primitives correctly
jjg
parents:
diff
changeset
|
32 |
import java.net.*; |
10c876d2de66
6887895: CONSTANT_Class_info getBaseName does not handle arrays of primitives correctly
jjg
parents:
diff
changeset
|
33 |
import java.util.*; |
10c876d2de66
6887895: CONSTANT_Class_info getBaseName does not handle arrays of primitives correctly
jjg
parents:
diff
changeset
|
34 |
import com.sun.tools.classfile.*; |
10c876d2de66
6887895: CONSTANT_Class_info getBaseName does not handle arrays of primitives correctly
jjg
parents:
diff
changeset
|
35 |
import com.sun.tools.classfile.ConstantPool.*; |
10c876d2de66
6887895: CONSTANT_Class_info getBaseName does not handle arrays of primitives correctly
jjg
parents:
diff
changeset
|
36 |
|
10c876d2de66
6887895: CONSTANT_Class_info getBaseName does not handle arrays of primitives correctly
jjg
parents:
diff
changeset
|
37 |
public class T6887895 { |
10c876d2de66
6887895: CONSTANT_Class_info getBaseName does not handle arrays of primitives correctly
jjg
parents:
diff
changeset
|
38 |
public static void main(String[] args) throws Exception { |
10c876d2de66
6887895: CONSTANT_Class_info getBaseName does not handle arrays of primitives correctly
jjg
parents:
diff
changeset
|
39 |
new T6887895().run(); |
10c876d2de66
6887895: CONSTANT_Class_info getBaseName does not handle arrays of primitives correctly
jjg
parents:
diff
changeset
|
40 |
} |
10c876d2de66
6887895: CONSTANT_Class_info getBaseName does not handle arrays of primitives correctly
jjg
parents:
diff
changeset
|
41 |
|
10c876d2de66
6887895: CONSTANT_Class_info getBaseName does not handle arrays of primitives correctly
jjg
parents:
diff
changeset
|
42 |
void run() throws Exception { |
10c876d2de66
6887895: CONSTANT_Class_info getBaseName does not handle arrays of primitives correctly
jjg
parents:
diff
changeset
|
43 |
Set<String> found = new TreeSet<String>(); |
10c876d2de66
6887895: CONSTANT_Class_info getBaseName does not handle arrays of primitives correctly
jjg
parents:
diff
changeset
|
44 |
|
10c876d2de66
6887895: CONSTANT_Class_info getBaseName does not handle arrays of primitives correctly
jjg
parents:
diff
changeset
|
45 |
ClassFile cf = getClassFile("T6887895$Test.class"); |
10c876d2de66
6887895: CONSTANT_Class_info getBaseName does not handle arrays of primitives correctly
jjg
parents:
diff
changeset
|
46 |
for (CPInfo cpInfo: cf.constant_pool.entries()) { |
10c876d2de66
6887895: CONSTANT_Class_info getBaseName does not handle arrays of primitives correctly
jjg
parents:
diff
changeset
|
47 |
if (cpInfo instanceof CONSTANT_Class_info) { |
10c876d2de66
6887895: CONSTANT_Class_info getBaseName does not handle arrays of primitives correctly
jjg
parents:
diff
changeset
|
48 |
CONSTANT_Class_info info = (CONSTANT_Class_info) cpInfo; |
10c876d2de66
6887895: CONSTANT_Class_info getBaseName does not handle arrays of primitives correctly
jjg
parents:
diff
changeset
|
49 |
String name = info.getName(); |
10c876d2de66
6887895: CONSTANT_Class_info getBaseName does not handle arrays of primitives correctly
jjg
parents:
diff
changeset
|
50 |
String baseName = info.getBaseName(); |
10c876d2de66
6887895: CONSTANT_Class_info getBaseName does not handle arrays of primitives correctly
jjg
parents:
diff
changeset
|
51 |
System.out.println("found: " + name + " " + baseName); |
10c876d2de66
6887895: CONSTANT_Class_info getBaseName does not handle arrays of primitives correctly
jjg
parents:
diff
changeset
|
52 |
if (baseName != null) |
10c876d2de66
6887895: CONSTANT_Class_info getBaseName does not handle arrays of primitives correctly
jjg
parents:
diff
changeset
|
53 |
found.add(baseName); |
10c876d2de66
6887895: CONSTANT_Class_info getBaseName does not handle arrays of primitives correctly
jjg
parents:
diff
changeset
|
54 |
} |
10c876d2de66
6887895: CONSTANT_Class_info getBaseName does not handle arrays of primitives correctly
jjg
parents:
diff
changeset
|
55 |
} |
10c876d2de66
6887895: CONSTANT_Class_info getBaseName does not handle arrays of primitives correctly
jjg
parents:
diff
changeset
|
56 |
|
10c876d2de66
6887895: CONSTANT_Class_info getBaseName does not handle arrays of primitives correctly
jjg
parents:
diff
changeset
|
57 |
String[] expectNames = { |
10c876d2de66
6887895: CONSTANT_Class_info getBaseName does not handle arrays of primitives correctly
jjg
parents:
diff
changeset
|
58 |
"java/lang/Object", |
10c876d2de66
6887895: CONSTANT_Class_info getBaseName does not handle arrays of primitives correctly
jjg
parents:
diff
changeset
|
59 |
"java/lang/String", |
10c876d2de66
6887895: CONSTANT_Class_info getBaseName does not handle arrays of primitives correctly
jjg
parents:
diff
changeset
|
60 |
"T6887895", |
10c876d2de66
6887895: CONSTANT_Class_info getBaseName does not handle arrays of primitives correctly
jjg
parents:
diff
changeset
|
61 |
"T6887895$Test" |
10c876d2de66
6887895: CONSTANT_Class_info getBaseName does not handle arrays of primitives correctly
jjg
parents:
diff
changeset
|
62 |
}; |
10c876d2de66
6887895: CONSTANT_Class_info getBaseName does not handle arrays of primitives correctly
jjg
parents:
diff
changeset
|
63 |
|
10c876d2de66
6887895: CONSTANT_Class_info getBaseName does not handle arrays of primitives correctly
jjg
parents:
diff
changeset
|
64 |
Set<String> expect = new TreeSet<String>(Arrays.asList(expectNames)); |
10c876d2de66
6887895: CONSTANT_Class_info getBaseName does not handle arrays of primitives correctly
jjg
parents:
diff
changeset
|
65 |
if (!found.equals(expect)) { |
10c876d2de66
6887895: CONSTANT_Class_info getBaseName does not handle arrays of primitives correctly
jjg
parents:
diff
changeset
|
66 |
System.err.println("found: " + found); |
10c876d2de66
6887895: CONSTANT_Class_info getBaseName does not handle arrays of primitives correctly
jjg
parents:
diff
changeset
|
67 |
System.err.println("expect: " + expect); |
10c876d2de66
6887895: CONSTANT_Class_info getBaseName does not handle arrays of primitives correctly
jjg
parents:
diff
changeset
|
68 |
throw new Exception("unexpected values found"); |
10c876d2de66
6887895: CONSTANT_Class_info getBaseName does not handle arrays of primitives correctly
jjg
parents:
diff
changeset
|
69 |
} |
10c876d2de66
6887895: CONSTANT_Class_info getBaseName does not handle arrays of primitives correctly
jjg
parents:
diff
changeset
|
70 |
} |
10c876d2de66
6887895: CONSTANT_Class_info getBaseName does not handle arrays of primitives correctly
jjg
parents:
diff
changeset
|
71 |
|
10c876d2de66
6887895: CONSTANT_Class_info getBaseName does not handle arrays of primitives correctly
jjg
parents:
diff
changeset
|
72 |
ClassFile getClassFile(String name) throws IOException, ConstantPoolException { |
10c876d2de66
6887895: CONSTANT_Class_info getBaseName does not handle arrays of primitives correctly
jjg
parents:
diff
changeset
|
73 |
URL url = getClass().getResource(name); |
10c876d2de66
6887895: CONSTANT_Class_info getBaseName does not handle arrays of primitives correctly
jjg
parents:
diff
changeset
|
74 |
InputStream in = url.openStream(); |
10c876d2de66
6887895: CONSTANT_Class_info getBaseName does not handle arrays of primitives correctly
jjg
parents:
diff
changeset
|
75 |
try { |
10c876d2de66
6887895: CONSTANT_Class_info getBaseName does not handle arrays of primitives correctly
jjg
parents:
diff
changeset
|
76 |
return ClassFile.read(in); |
10c876d2de66
6887895: CONSTANT_Class_info getBaseName does not handle arrays of primitives correctly
jjg
parents:
diff
changeset
|
77 |
} finally { |
10c876d2de66
6887895: CONSTANT_Class_info getBaseName does not handle arrays of primitives correctly
jjg
parents:
diff
changeset
|
78 |
in.close(); |
10c876d2de66
6887895: CONSTANT_Class_info getBaseName does not handle arrays of primitives correctly
jjg
parents:
diff
changeset
|
79 |
} |
10c876d2de66
6887895: CONSTANT_Class_info getBaseName does not handle arrays of primitives correctly
jjg
parents:
diff
changeset
|
80 |
} |
10c876d2de66
6887895: CONSTANT_Class_info getBaseName does not handle arrays of primitives correctly
jjg
parents:
diff
changeset
|
81 |
|
10c876d2de66
6887895: CONSTANT_Class_info getBaseName does not handle arrays of primitives correctly
jjg
parents:
diff
changeset
|
82 |
class Test { |
10c876d2de66
6887895: CONSTANT_Class_info getBaseName does not handle arrays of primitives correctly
jjg
parents:
diff
changeset
|
83 |
void m() { |
10c876d2de66
6887895: CONSTANT_Class_info getBaseName does not handle arrays of primitives correctly
jjg
parents:
diff
changeset
|
84 |
boolean[] az = new boolean[0]; |
10c876d2de66
6887895: CONSTANT_Class_info getBaseName does not handle arrays of primitives correctly
jjg
parents:
diff
changeset
|
85 |
boolean[][] aaz = new boolean[0][]; |
10c876d2de66
6887895: CONSTANT_Class_info getBaseName does not handle arrays of primitives correctly
jjg
parents:
diff
changeset
|
86 |
boolean[][][] aaaz = new boolean[0][][]; |
10c876d2de66
6887895: CONSTANT_Class_info getBaseName does not handle arrays of primitives correctly
jjg
parents:
diff
changeset
|
87 |
|
10c876d2de66
6887895: CONSTANT_Class_info getBaseName does not handle arrays of primitives correctly
jjg
parents:
diff
changeset
|
88 |
byte[] ab = new byte[0]; |
10c876d2de66
6887895: CONSTANT_Class_info getBaseName does not handle arrays of primitives correctly
jjg
parents:
diff
changeset
|
89 |
byte[][] aab = new byte[0][]; |
10c876d2de66
6887895: CONSTANT_Class_info getBaseName does not handle arrays of primitives correctly
jjg
parents:
diff
changeset
|
90 |
byte[][][] aaab = new byte[0][][]; |
10c876d2de66
6887895: CONSTANT_Class_info getBaseName does not handle arrays of primitives correctly
jjg
parents:
diff
changeset
|
91 |
|
10c876d2de66
6887895: CONSTANT_Class_info getBaseName does not handle arrays of primitives correctly
jjg
parents:
diff
changeset
|
92 |
char[] ac = new char[0]; |
10c876d2de66
6887895: CONSTANT_Class_info getBaseName does not handle arrays of primitives correctly
jjg
parents:
diff
changeset
|
93 |
char[][] aac = new char[0][]; |
10c876d2de66
6887895: CONSTANT_Class_info getBaseName does not handle arrays of primitives correctly
jjg
parents:
diff
changeset
|
94 |
char[][][] aaac = new char[0][][]; |
10c876d2de66
6887895: CONSTANT_Class_info getBaseName does not handle arrays of primitives correctly
jjg
parents:
diff
changeset
|
95 |
|
10c876d2de66
6887895: CONSTANT_Class_info getBaseName does not handle arrays of primitives correctly
jjg
parents:
diff
changeset
|
96 |
double[] ad = new double[0]; |
10c876d2de66
6887895: CONSTANT_Class_info getBaseName does not handle arrays of primitives correctly
jjg
parents:
diff
changeset
|
97 |
double[][] aad = new double[0][]; |
10c876d2de66
6887895: CONSTANT_Class_info getBaseName does not handle arrays of primitives correctly
jjg
parents:
diff
changeset
|
98 |
double[][][] aaad = new double[0][][]; |
10c876d2de66
6887895: CONSTANT_Class_info getBaseName does not handle arrays of primitives correctly
jjg
parents:
diff
changeset
|
99 |
|
10c876d2de66
6887895: CONSTANT_Class_info getBaseName does not handle arrays of primitives correctly
jjg
parents:
diff
changeset
|
100 |
float[] af = new float[0]; |
10c876d2de66
6887895: CONSTANT_Class_info getBaseName does not handle arrays of primitives correctly
jjg
parents:
diff
changeset
|
101 |
float[][] aaf = new float[0][]; |
10c876d2de66
6887895: CONSTANT_Class_info getBaseName does not handle arrays of primitives correctly
jjg
parents:
diff
changeset
|
102 |
float[][][] aaaf = new float[0][][]; |
10c876d2de66
6887895: CONSTANT_Class_info getBaseName does not handle arrays of primitives correctly
jjg
parents:
diff
changeset
|
103 |
|
10c876d2de66
6887895: CONSTANT_Class_info getBaseName does not handle arrays of primitives correctly
jjg
parents:
diff
changeset
|
104 |
int[] ai = new int[0]; |
10c876d2de66
6887895: CONSTANT_Class_info getBaseName does not handle arrays of primitives correctly
jjg
parents:
diff
changeset
|
105 |
int[][] aai = new int[0][]; |
10c876d2de66
6887895: CONSTANT_Class_info getBaseName does not handle arrays of primitives correctly
jjg
parents:
diff
changeset
|
106 |
int[][][] aaai = new int[0][][]; |
10c876d2de66
6887895: CONSTANT_Class_info getBaseName does not handle arrays of primitives correctly
jjg
parents:
diff
changeset
|
107 |
|
10c876d2de66
6887895: CONSTANT_Class_info getBaseName does not handle arrays of primitives correctly
jjg
parents:
diff
changeset
|
108 |
long[] al = new long[0]; |
10c876d2de66
6887895: CONSTANT_Class_info getBaseName does not handle arrays of primitives correctly
jjg
parents:
diff
changeset
|
109 |
long[][] aal = new long[0][]; |
10c876d2de66
6887895: CONSTANT_Class_info getBaseName does not handle arrays of primitives correctly
jjg
parents:
diff
changeset
|
110 |
long[][][] aaal = new long[0][][]; |
10c876d2de66
6887895: CONSTANT_Class_info getBaseName does not handle arrays of primitives correctly
jjg
parents:
diff
changeset
|
111 |
|
10c876d2de66
6887895: CONSTANT_Class_info getBaseName does not handle arrays of primitives correctly
jjg
parents:
diff
changeset
|
112 |
short[] as = new short[0]; |
10c876d2de66
6887895: CONSTANT_Class_info getBaseName does not handle arrays of primitives correctly
jjg
parents:
diff
changeset
|
113 |
short[][] aas = new short[0][]; |
10c876d2de66
6887895: CONSTANT_Class_info getBaseName does not handle arrays of primitives correctly
jjg
parents:
diff
changeset
|
114 |
short[][][] aaas = new short[0][][]; |
10c876d2de66
6887895: CONSTANT_Class_info getBaseName does not handle arrays of primitives correctly
jjg
parents:
diff
changeset
|
115 |
|
10c876d2de66
6887895: CONSTANT_Class_info getBaseName does not handle arrays of primitives correctly
jjg
parents:
diff
changeset
|
116 |
String[] aS = new String[0]; |
10c876d2de66
6887895: CONSTANT_Class_info getBaseName does not handle arrays of primitives correctly
jjg
parents:
diff
changeset
|
117 |
String[][] aaS = new String[0][]; |
10c876d2de66
6887895: CONSTANT_Class_info getBaseName does not handle arrays of primitives correctly
jjg
parents:
diff
changeset
|
118 |
String[][][] aaaS = new String[0][][]; |
10c876d2de66
6887895: CONSTANT_Class_info getBaseName does not handle arrays of primitives correctly
jjg
parents:
diff
changeset
|
119 |
} |
10c876d2de66
6887895: CONSTANT_Class_info getBaseName does not handle arrays of primitives correctly
jjg
parents:
diff
changeset
|
120 |
} |
10c876d2de66
6887895: CONSTANT_Class_info getBaseName does not handle arrays of primitives correctly
jjg
parents:
diff
changeset
|
121 |
} |
10c876d2de66
6887895: CONSTANT_Class_info getBaseName does not handle arrays of primitives correctly
jjg
parents:
diff
changeset
|
122 |