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