Wed, 24 Jun 2015 15:43:06 -0700
Merge
jjg@346 | 1 | /* |
jjg@953 | 2 | * Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved. |
jjg@346 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
jjg@346 | 4 | * |
jjg@346 | 5 | * This code is free software; you can redistribute it and/or modify it |
jjg@346 | 6 | * under the terms of the GNU General Public License version 2 only, as |
jjg@346 | 7 | * published by the Free Software Foundation. |
jjg@346 | 8 | * |
jjg@346 | 9 | * This code is distributed in the hope that it will be useful, but WITHOUT |
jjg@346 | 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
jjg@346 | 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
jjg@346 | 12 | * version 2 for more details (a copy is included in the LICENSE file that |
jjg@346 | 13 | * accompanied this code). |
jjg@346 | 14 | * |
jjg@346 | 15 | * You should have received a copy of the GNU General Public License version |
jjg@346 | 16 | * 2 along with this work; if not, write to the Free Software Foundation, |
jjg@346 | 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
jjg@346 | 18 | * |
ohair@554 | 19 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
ohair@554 | 20 | * or visit www.oracle.com if you need additional information or have any |
ohair@554 | 21 | * questions. |
jjg@346 | 22 | */ |
jjg@346 | 23 | |
jjg@346 | 24 | |
jjg@346 | 25 | /* |
jjg@346 | 26 | * @test |
jjg@953 | 27 | * @bug 4880672 7031005 |
jjg@346 | 28 | * @summary javap does not output inner interfaces of an interface |
jjg@346 | 29 | */ |
jjg@346 | 30 | |
jjg@346 | 31 | import java.io.*; |
jjg@346 | 32 | import java.util.*; |
jjg@346 | 33 | |
jjg@346 | 34 | public class T4880672 |
jjg@346 | 35 | { |
jjg@346 | 36 | public static void main(String... args) { |
jjg@346 | 37 | new T4880672().run(); |
jjg@346 | 38 | } |
jjg@346 | 39 | |
jjg@346 | 40 | void run() { |
jjg@346 | 41 | verify("java.util.Map", "public interface java.util.Map$Entry"); |
jjg@953 | 42 | verify("T4880672", "class T4880672$A$B"); |
jjg@346 | 43 | verify("C", ""); // must not give error if no InnerClasses attribute |
jjg@346 | 44 | if (errors > 0) |
jjg@346 | 45 | throw new Error(errors + " found."); |
jjg@346 | 46 | } |
jjg@346 | 47 | |
jjg@346 | 48 | void verify(String className, String... expects) { |
jjg@346 | 49 | String output = javap(className); |
jjg@346 | 50 | for (String expect: expects) { |
jjg@346 | 51 | if (output.indexOf(expect)< 0) |
jjg@346 | 52 | error(expect + " not found"); |
jjg@346 | 53 | } |
jjg@346 | 54 | } |
jjg@346 | 55 | |
jjg@346 | 56 | void error(String msg) { |
jjg@346 | 57 | System.err.println(msg); |
jjg@346 | 58 | errors++; |
jjg@346 | 59 | } |
jjg@346 | 60 | |
jjg@346 | 61 | int errors; |
jjg@346 | 62 | |
jjg@346 | 63 | String javap(String className) { |
jjg@346 | 64 | String testClasses = System.getProperty("test.classes", "."); |
jjg@346 | 65 | StringWriter sw = new StringWriter(); |
jjg@346 | 66 | PrintWriter out = new PrintWriter(sw); |
jjg@346 | 67 | String[] args = { "-XDinner", "-classpath", testClasses, className }; |
jjg@346 | 68 | int rc = com.sun.tools.javap.Main.run(args, out); |
jjg@346 | 69 | out.close(); |
jjg@346 | 70 | String output = sw.toString(); |
jjg@346 | 71 | System.out.println("class " + className); |
jjg@346 | 72 | System.out.println(output); |
jjg@346 | 73 | if (rc != 0) |
jjg@346 | 74 | throw new Error("javap failed. rc=" + rc); |
jjg@346 | 75 | if (output.indexOf("Error:") != -1) |
jjg@346 | 76 | throw new Error("javap reported error."); |
jjg@346 | 77 | return output; |
jjg@346 | 78 | } |
jjg@346 | 79 | |
jjg@346 | 80 | class A { |
jjg@346 | 81 | class B { } |
jjg@346 | 82 | } |
jjg@346 | 83 | } |
jjg@346 | 84 | |
jjg@346 | 85 | class C { } |
jjg@346 | 86 |