< prev index next >

test/langtools/tools/javap/4870651/T4870651.java

Print this page

 1 /*
 2  * Copyright (c) 2008, 2016, Oracle and/or its affiliates. All rights reserved.
 3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 4  *
 5  * This code is free software; you can redistribute it and/or modify it
 6  * under the terms of the GNU General Public License version 2 only, as
 7  * published by the Free Software Foundation.
 8  *
 9  * This code is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
12  * version 2 for more details (a copy is included in the LICENSE file that
13  * accompanied this code).
14  *
15  * You should have received a copy of the GNU General Public License version
16  * 2 along with this work; if not, write to the Free Software Foundation,
17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18  *
19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20  * or visit www.oracle.com if you need additional information or have any
21  * questions.
22  */
23 
24 /*
25  * @test
26  * @bug 4870651 6715757
27  * @summary javap should recognize generics, varargs, enum;
28  *          javap prints "extends java.lang.Object"
29  * @modules jdk.jdeps/com.sun.tools.javap

30  * @build T4870651 Test
31  * @run main T4870651
32  */
33 
34 import java.io.*;

35 
36 public class T4870651 {
37     public static void main(String[] args) throws Exception {
38         new T4870651().run();
39     }
40 
41     public void run() throws IOException {
42         verify("Test",
43                "class Test<T extends java.lang.Object, " +
44                    "E extends java.lang.Exception & java.lang.Comparable<T>, " +
45                    "U extends java.lang.Comparable>",
46                "v1(java.lang.String...)");
47 
48         verify("Test$Enum",
49                "flags: (0x4030) ACC_FINAL, ACC_SUPER, ACC_ENUM",


50                "flags: (0x4019) ACC_PUBLIC, ACC_STATIC, ACC_FINAL, ACC_ENUM");
51 
52         if (errors > 0)
53             throw new Error(errors + " found.");
54     }
55 
56     String javap(String className) {
57         String testClasses = System.getProperty("test.classes", ".");
58         StringWriter sw = new StringWriter();
59         PrintWriter out = new PrintWriter(sw);
60         String[] args = { "-classpath", testClasses, "-v", className };
61         int rc = com.sun.tools.javap.Main.run(args, out);
62         if (rc != 0)
63             throw new Error("javap failed. rc=" + rc);
64         out.close();
65         String output = sw.toString();
66         System.out.println("class " + className);
67         System.out.println(output);
68         return output;
69     }

 1 /*
 2  * Copyright (c) 2008, 2024, Oracle and/or its affiliates. All rights reserved.
 3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 4  *
 5  * This code is free software; you can redistribute it and/or modify it
 6  * under the terms of the GNU General Public License version 2 only, as
 7  * published by the Free Software Foundation.
 8  *
 9  * This code is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
12  * version 2 for more details (a copy is included in the LICENSE file that
13  * accompanied this code).
14  *
15  * You should have received a copy of the GNU General Public License version
16  * 2 along with this work; if not, write to the Free Software Foundation,
17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18  *
19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20  * or visit www.oracle.com if you need additional information or have any
21  * questions.
22  */
23 
24 /*
25  * @test
26  * @bug 4870651 6715757
27  * @summary javap should recognize generics, varargs, enum;
28  *          javap prints "extends java.lang.Object"
29  * @modules jdk.jdeps/com.sun.tools.javap
30  * @modules java.base/jdk.internal.misc
31  * @build T4870651 Test
32  * @run main T4870651
33  */
34 
35 import java.io.*;
36 import jdk.internal.misc.PreviewFeatures;
37 
38 public class T4870651 {
39     public static void main(String[] args) throws Exception {
40         new T4870651().run();
41     }
42 
43     public void run() throws IOException {
44         verify("Test",
45                "class Test<T extends java.lang.Object, " +
46                    "E extends java.lang.Exception & java.lang.Comparable<T>, " +
47                    "U extends java.lang.Comparable>",
48                "v1(java.lang.String...)");
49 
50         verify("Test$Enum",
51                PreviewFeatures.isEnabled()
52                        ? "flags: (0x4030) ACC_FINAL, ACC_IDENTITY, ACC_ENUM"
53                        : "flags: (0x4030) ACC_FINAL, ACC_SUPER, ACC_ENUM",
54                "flags: (0x4019) ACC_PUBLIC, ACC_STATIC, ACC_FINAL, ACC_ENUM");
55 
56         if (errors > 0)
57             throw new Error(errors + " found.");
58     }
59 
60     String javap(String className) {
61         String testClasses = System.getProperty("test.classes", ".");
62         StringWriter sw = new StringWriter();
63         PrintWriter out = new PrintWriter(sw);
64         String[] args = { "-classpath", testClasses, "-v", className };
65         int rc = com.sun.tools.javap.Main.run(args, out);
66         if (rc != 0)
67             throw new Error("javap failed. rc=" + rc);
68         out.close();
69         String output = sw.toString();
70         System.out.println("class " + className);
71         System.out.println(output);
72         return output;
73     }
< prev index next >