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