Path: blob/aarch64-shenandoah-jdk8u272-b10/langtools/test/tools/javap/T4975569.java
32285 views
/*1* Copyright (c) 2008, 2009, 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*/2223/*24* @test25* @bug 4975569 662221526* @summary javap doesn't print new flag bits27*/2829import java.io.*;30import java.util.*;3132public class T497556933{34public static void main(String... args) {35new T4975569().run();36}3738void run() {39verify("T4975569$Anno", "flags: ACC_INTERFACE, ACC_ABSTRACT, ACC_ANNOTATION");40verify("T4975569$E", "flags: ACC_FINAL, ACC_SUPER, ACC_ENUM");41verify("T4975569$S", "flags: ACC_BRIDGE, ACC_SYNTHETIC",42"InnerClasses:\n static");43verify("T4975569$V", "void m(java.lang.String...)",44"flags: ACC_VARARGS");45verify("T4975569$Prot", "InnerClasses:\n protected");46//verify("T4975569$Priv", "InnerClasses");47if (errors > 0)48throw new Error(errors + " found.");49}5051void verify(String className, String... expects) {52String output = javap(className);53for (String expect: expects) {54if (output.indexOf(expect)< 0)55error(expect + " not found");56}57}5859void error(String msg) {60System.err.println(msg);61errors++;62}6364int errors;6566String javap(String className) {67String newline = System.getProperty("line.separator");68String testClasses = System.getProperty("test.classes", ".");69StringWriter sw = new StringWriter();70PrintWriter out = new PrintWriter(sw);71String[] args = { "-v", "-classpath", testClasses, className };72int rc = com.sun.tools.javap.Main.run(args, out);73if (rc != 0)74throw new Error("javap failed. rc=" + rc);75out.close();76String output = sw.toString().replaceAll(newline, "\n");77System.out.println("class " + className);78System.out.println(output);79return output;80}8182List x() { return null; };8384class V { void m(String... args) { } }85enum E { e; }86@interface Anno { }87static class S extends T4975569 {88ArrayList x() { return null; }89}9091protected class Prot { }92//private class Priv { int i; }93}94959697