jjg@485: /* ohair@554: * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved. jjg@485: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. jjg@485: * jjg@485: * This code is free software; you can redistribute it and/or modify it jjg@485: * under the terms of the GNU General Public License version 2 only, as jjg@485: * published by the Free Software Foundation. jjg@485: * jjg@485: * This code is distributed in the hope that it will be useful, but WITHOUT jjg@485: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or jjg@485: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License jjg@485: * version 2 for more details (a copy is included in the LICENSE file that jjg@485: * accompanied this code). jjg@485: * jjg@485: * You should have received a copy of the GNU General Public License version jjg@485: * 2 along with this work; if not, write to the Free Software Foundation, jjg@485: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. jjg@485: * 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@485: */ jjg@485: jjg@485: /* jjg@485: * @test jjg@485: * @bug 6918625 jjg@485: * @summary javap dumps type information of array class literals jjg@485: */ jjg@485: jjg@485: import java.io.*; jjg@485: jjg@485: public class ArrayClassLiterals2 { jjg@485: public static void main(String[] args) throws Exception { jjg@485: new ArrayClassLiterals2().run(); jjg@485: } jjg@485: jjg@485: public void run() throws IOException { jjg@485: File classFile = new File(System.getProperty("test.classes"), "ArrayClassLiterals2$Test.class"); jjg@485: jjg@485: verify(classFile, jjg@485: "RuntimeInvisibleTypeAnnotations:", jjg@485: "CLASS_LITERAL_GENERIC_OR_ARRAY" jjg@485: ); jjg@485: jjg@485: if (errors > 0) jjg@485: throw new Error(errors + " found."); jjg@485: } jjg@485: jjg@485: String javap(File f) { jjg@485: StringWriter sw = new StringWriter(); jjg@485: PrintWriter out = new PrintWriter(sw); jjg@485: int rc = com.sun.tools.javap.Main.run(new String[] { "-v", f.getPath() }, out); jjg@485: if (rc != 0) jjg@485: throw new Error("javap failed. rc=" + rc); jjg@485: out.close(); jjg@485: return sw.toString(); jjg@485: } jjg@485: jjg@485: void verify(File classFile, String... expects) { jjg@485: String output = javap(classFile); jjg@485: for (String expect: expects) { jjg@485: if (output.indexOf(expect)< 0) jjg@485: error(expect + " not found"); jjg@485: } jjg@485: } jjg@485: jjg@485: void error(String msg) { jjg@485: System.err.println(msg); jjg@485: errors++; jjg@485: } jjg@485: jjg@485: int errors; jjg@485: jjg@485: jjg@485: /*********************** Test class *************************/ jjg@485: static class Test { jjg@485: @interface A { } jjg@485: void test() { jjg@485: Object a = @A String @A [] @A [].class; jjg@485: } jjg@485: } jjg@485: }