jjg@422: /* ohair@554: * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved. jjg@422: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. jjg@422: * jjg@422: * This code is free software; you can redistribute it and/or modify it jjg@422: * under the terms of the GNU General Public License version 2 only, as jjg@422: * published by the Free Software Foundation. jjg@422: * jjg@422: * This code is distributed in the hope that it will be useful, but WITHOUT jjg@422: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or jjg@422: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License jjg@422: * version 2 for more details (a copy is included in the LICENSE file that jjg@422: * accompanied this code). jjg@422: * jjg@422: * You should have received a copy of the GNU General Public License version jjg@422: * 2 along with this work; if not, write to the Free Software Foundation, jjg@422: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. jjg@422: * ohair@554: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA ohair@554: * or visit www.oracle.com if you need additional information or have any ohair@554: * questions. jjg@422: */ jjg@422: jjg@422: /* jjg@422: * @test jjg@422: * @bug 6887895 jjg@422: * @summary CONSTANT_Class_info getBaseName does not handle arrays of primitives correctly jjg@422: */ jjg@422: jjg@422: import java.io.*; jjg@422: import java.net.*; jjg@422: import java.util.*; jjg@422: import com.sun.tools.classfile.*; jjg@422: import com.sun.tools.classfile.ConstantPool.*; jjg@422: jjg@422: public class T6887895 { jjg@422: public static void main(String[] args) throws Exception { jjg@422: new T6887895().run(); jjg@422: } jjg@422: jjg@422: void run() throws Exception { jjg@422: Set found = new TreeSet(); jjg@422: jjg@422: ClassFile cf = getClassFile("T6887895$Test.class"); jjg@422: for (CPInfo cpInfo: cf.constant_pool.entries()) { jjg@422: if (cpInfo instanceof CONSTANT_Class_info) { jjg@422: CONSTANT_Class_info info = (CONSTANT_Class_info) cpInfo; jjg@422: String name = info.getName(); jjg@422: String baseName = info.getBaseName(); jjg@422: System.out.println("found: " + name + " " + baseName); jjg@422: if (baseName != null) jjg@422: found.add(baseName); jjg@422: } jjg@422: } jjg@422: jjg@422: String[] expectNames = { jjg@422: "java/lang/Object", jjg@422: "java/lang/String", jjg@422: "T6887895", jjg@422: "T6887895$Test" jjg@422: }; jjg@422: jjg@422: Set expect = new TreeSet(Arrays.asList(expectNames)); jjg@422: if (!found.equals(expect)) { jjg@422: System.err.println("found: " + found); jjg@422: System.err.println("expect: " + expect); jjg@422: throw new Exception("unexpected values found"); jjg@422: } jjg@422: } jjg@422: jjg@422: ClassFile getClassFile(String name) throws IOException, ConstantPoolException { jjg@422: URL url = getClass().getResource(name); jjg@422: InputStream in = url.openStream(); jjg@422: try { jjg@422: return ClassFile.read(in); jjg@422: } finally { jjg@422: in.close(); jjg@422: } jjg@422: } jjg@422: jjg@422: class Test { jjg@422: void m() { jjg@422: boolean[] az = new boolean[0]; jjg@422: boolean[][] aaz = new boolean[0][]; jjg@422: boolean[][][] aaaz = new boolean[0][][]; jjg@422: jjg@422: byte[] ab = new byte[0]; jjg@422: byte[][] aab = new byte[0][]; jjg@422: byte[][][] aaab = new byte[0][][]; jjg@422: jjg@422: char[] ac = new char[0]; jjg@422: char[][] aac = new char[0][]; jjg@422: char[][][] aaac = new char[0][][]; jjg@422: jjg@422: double[] ad = new double[0]; jjg@422: double[][] aad = new double[0][]; jjg@422: double[][][] aaad = new double[0][][]; jjg@422: jjg@422: float[] af = new float[0]; jjg@422: float[][] aaf = new float[0][]; jjg@422: float[][][] aaaf = new float[0][][]; jjg@422: jjg@422: int[] ai = new int[0]; jjg@422: int[][] aai = new int[0][]; jjg@422: int[][][] aaai = new int[0][][]; jjg@422: jjg@422: long[] al = new long[0]; jjg@422: long[][] aal = new long[0][]; jjg@422: long[][][] aaal = new long[0][][]; jjg@422: jjg@422: short[] as = new short[0]; jjg@422: short[][] aas = new short[0][]; jjg@422: short[][][] aaas = new short[0][][]; jjg@422: jjg@422: String[] aS = new String[0]; jjg@422: String[][] aaS = new String[0][]; jjg@422: String[][][] aaaS = new String[0][][]; jjg@422: } jjg@422: } jjg@422: } jjg@422: