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