Path: blob/aarch64-shenandoah-jdk8u272-b10/langtools/test/tools/javap/T6729471.java
32285 views
/*1* Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/222324/*25* @test26* @bug 672947127* @summary javap does not output inner interfaces of an interface28*/2930import java.io.*;31import java.net.*;32import java.util.*;3334public class T672947135{36public static void main(String... args) {37new T6729471().run();38}3940void run() {41File testClasses = new File(System.getProperty("test.classes"));4243// simple class44verify("java.util.Map",45"public abstract boolean containsKey(java.lang.Object)");4647// inner class48verify("java.util.Map.Entry",49"public abstract K getKey()");5051// file name52verify(new File(testClasses, "T6729471.class").getPath(),53"public static void main(java.lang.String...)");5455// file url56verify(new File(testClasses, "T6729471.class").toURI().toString(),57"public static void main(java.lang.String...)");5859// jar url: rt.jar60File java_home = new File(System.getProperty("java.home"));61if (java_home.getName().equals("jre"))62java_home = java_home.getParentFile();63File rt_jar = new File(new File(new File(java_home, "jre"), "lib"), "rt.jar");64try {65verify("jar:" + rt_jar.toURL() + "!/java/util/Map.class",66"public abstract boolean containsKey(java.lang.Object)");67} catch (MalformedURLException e) {68error(e.toString());69}7071// jar url: ct.sym, if it exists72File ct_sym = new File(new File(java_home, "lib"), "ct.sym");73if (ct_sym.exists()) {74try {75verify("jar:" + ct_sym.toURL() + "!/META-INF/sym/rt.jar/java/util/Map.class",76"public abstract boolean containsKey(java.lang.Object)");77} catch (MalformedURLException e) {78error(e.toString());79}80} else81System.err.println("warning: ct.sym not found");8283if (errors > 0)84throw new Error(errors + " found.");85}8687void verify(String className, String... expects) {88String output = javap(className);89for (String expect: expects) {90if (output.indexOf(expect)< 0)91error(expect + " not found");92}93}9495void error(String msg) {96System.err.println(msg);97errors++;98}99100int errors;101102String javap(String className) {103String testClasses = System.getProperty("test.classes", ".");104StringWriter sw = new StringWriter();105PrintWriter out = new PrintWriter(sw);106String[] args = { "-classpath", testClasses, className };107int rc = com.sun.tools.javap.Main.run(args, out);108out.close();109String output = sw.toString();110System.out.println("class " + className);111System.out.println(output);112if (rc != 0)113throw new Error("javap failed. rc=" + rc);114if (output.indexOf("Error:") != -1)115throw new Error("javap reported error.");116return output;117}118}119120121122