45N/A/*
553N/A * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
45N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
45N/A *
45N/A * This code is free software; you can redistribute it and/or modify it
45N/A * under the terms of the GNU General Public License version 2 only, as
45N/A * published by the Free Software Foundation.
45N/A *
45N/A * This code is distributed in the hope that it will be useful, but WITHOUT
45N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
45N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
45N/A * version 2 for more details (a copy is included in the LICENSE file that
45N/A * accompanied this code).
45N/A *
45N/A * You should have received a copy of the GNU General Public License version
45N/A * 2 along with this work; if not, write to the Free Software Foundation,
45N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
45N/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.
45N/A */
45N/A
45N/A/*
45N/A * @test
64N/A * @bug 4870651 6715757
64N/A * @summary javap should recognize generics, varargs, enum;
64N/A * javap prints "extends java.lang.Object"
45N/A * @build T4870651 Test
45N/A * @run main T4870651
45N/A */
45N/A
45N/Aimport java.io.*;
45N/A
45N/Apublic class T4870651 {
45N/A public static void main(String[] args) throws Exception {
45N/A new T4870651().run();
45N/A }
45N/A
45N/A public void run() throws IOException {
45N/A verify("Test",
64N/A "class Test<T extends java.lang.Object, " +
64N/A "E extends java.lang.Exception & java.lang.Comparable<T>, " +
64N/A "U extends java.lang.Comparable>",
45N/A "v1(java.lang.String...)");
45N/A
45N/A verify("Test$Enum",
45N/A "flags: ACC_FINAL, ACC_SUPER, ACC_ENUM",
45N/A "flags: ACC_PUBLIC, ACC_STATIC, ACC_FINAL, ACC_ENUM");
45N/A
45N/A if (errors > 0)
45N/A throw new Error(errors + " found.");
45N/A }
45N/A
45N/A String javap(String className) {
45N/A String testClasses = System.getProperty("test.classes", ".");
45N/A StringWriter sw = new StringWriter();
45N/A PrintWriter out = new PrintWriter(sw);
45N/A String[] args = { "-classpath", testClasses, "-v", className };
45N/A int rc = com.sun.tools.javap.Main.run(args, out);
45N/A if (rc != 0)
45N/A throw new Error("javap failed. rc=" + rc);
45N/A out.close();
45N/A String output = sw.toString();
45N/A System.out.println("class " + className);
45N/A System.out.println(output);
45N/A return output;
45N/A }
45N/A
45N/A void verify(String className, String... expects) {
45N/A String output = javap(className);
45N/A for (String expect: expects) {
45N/A if (output.indexOf(expect)< 0)
45N/A error(expect + " not found");
45N/A }
45N/A }
45N/A
45N/A void error(String msg) {
45N/A System.err.println(msg);
45N/A errors++;
45N/A }
45N/A
45N/A int errors;
45N/A}