test/tools/javap/classfile/T6887895.java

Thu, 25 Aug 2011 17:18:25 -0700

author
schien
date
Thu, 25 Aug 2011 17:18:25 -0700
changeset 1067
f497fac86cf9
parent 554
9d9f26857129
child 2525
2eb010b6cb22
permissions
-rw-r--r--

Added tag jdk8-b02 for changeset b3c059de2a61

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

mercurial