jjg@350: /* ohair@798: * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved. jjg@350: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. jjg@350: * jjg@350: * This code is free software; you can redistribute it and/or modify it jjg@350: * under the terms of the GNU General Public License version 2 only, as jjg@350: * published by the Free Software Foundation. jjg@350: * jjg@350: * This code is distributed in the hope that it will be useful, but WITHOUT jjg@350: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or jjg@350: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License jjg@350: * version 2 for more details (a copy is included in the LICENSE file that jjg@350: * accompanied this code). jjg@350: * jjg@350: * You should have received a copy of the GNU General Public License version jjg@350: * 2 along with this work; if not, write to the Free Software Foundation, jjg@350: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. jjg@350: * 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@350: */ jjg@350: jjg@350: jjg@350: /* jjg@350: * @test jjg@350: * @bug 6729471 jjg@350: * @summary javap does not output inner interfaces of an interface jjg@350: */ jjg@350: jjg@350: import java.io.*; jjg@386: import java.net.*; jjg@350: import java.util.*; jjg@350: jjg@350: public class T6729471 jjg@350: { jjg@350: public static void main(String... args) { jjg@350: new T6729471().run(); jjg@350: } jjg@350: jjg@350: void run() { jjg@755: File testClasses = new File(System.getProperty("test.classes")); jjg@755: jjg@350: // simple class jjg@350: verify("java.util.Map", jjg@350: "public abstract boolean containsKey(java.lang.Object)"); jjg@350: jjg@350: // inner class jjg@350: verify("java.util.Map.Entry", jjg@350: "public abstract K getKey()"); jjg@350: jjg@350: // file name jjg@755: verify(new File(testClasses, "T6729471.class").getPath(), jjg@350: "public static void main(java.lang.String...)"); jjg@350: jjg@350: // file url jjg@755: verify(new File(testClasses, "T6729471.class").toURI().toString(), jjg@350: "public static void main(java.lang.String...)"); jjg@350: jjg@350: // jar url: rt.jar jjg@350: File java_home = new File(System.getProperty("java.home")); jjg@350: if (java_home.getName().equals("jre")) jjg@350: java_home = java_home.getParentFile(); jjg@350: File rt_jar = new File(new File(new File(java_home, "jre"), "lib"), "rt.jar"); jjg@386: try { jjg@386: verify("jar:" + rt_jar.toURL() + "!/java/util/Map.class", jjg@350: "public abstract boolean containsKey(java.lang.Object)"); jjg@386: } catch (MalformedURLException e) { jjg@386: error(e.toString()); jjg@386: } jjg@350: jjg@350: // jar url: ct.sym, if it exists jjg@350: File ct_sym = new File(new File(java_home, "lib"), "ct.sym"); jjg@350: if (ct_sym.exists()) { jjg@386: try { jjg@386: verify("jar:" + ct_sym.toURL() + "!/META-INF/sym/rt.jar/java/util/Map.class", jjg@386: "public abstract boolean containsKey(java.lang.Object)"); jjg@386: } catch (MalformedURLException e) { jjg@386: error(e.toString()); jjg@386: } jjg@350: } else jjg@350: System.err.println("warning: ct.sym not found"); jjg@350: jjg@350: if (errors > 0) jjg@350: throw new Error(errors + " found."); jjg@350: } jjg@350: jjg@350: void verify(String className, String... expects) { jjg@350: String output = javap(className); jjg@350: for (String expect: expects) { jjg@350: if (output.indexOf(expect)< 0) jjg@350: error(expect + " not found"); jjg@350: } jjg@350: } jjg@350: jjg@350: void error(String msg) { jjg@350: System.err.println(msg); jjg@350: errors++; jjg@350: } jjg@350: jjg@350: int errors; jjg@350: jjg@350: String javap(String className) { jjg@350: String testClasses = System.getProperty("test.classes", "."); jjg@350: StringWriter sw = new StringWriter(); jjg@350: PrintWriter out = new PrintWriter(sw); jjg@350: String[] args = { "-classpath", testClasses, className }; jjg@350: int rc = com.sun.tools.javap.Main.run(args, out); jjg@350: out.close(); jjg@350: String output = sw.toString(); jjg@350: System.out.println("class " + className); jjg@350: System.out.println(output); jjg@350: if (rc != 0) jjg@350: throw new Error("javap failed. rc=" + rc); jjg@350: if (output.indexOf("Error:") != -1) jjg@350: throw new Error("javap reported error."); jjg@350: return output; jjg@350: } jjg@350: } jjg@350: