Path: blob/aarch64-shenandoah-jdk8u272-b10/langtools/test/tools/javap/StackMapTableTest.java
32285 views
/*1* Copyright (c) 2014, 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 8033930 803391326* @summary bad formatting of StackMapTable entries27*/2829import java.io.*;30import java.util.*;3132public class StackMapTableTest {33public static void main(String... args) throws Exception {34new StackMapTableTest().run();35}3637void run() throws Exception {38String testClasses = System.getProperty("test.classes");39String out = javap("-v", "-classpath", testClasses, A.class.getName());4041String nl = System.getProperty("line.separator");42out = out.replaceAll(nl, "\n");4344if (out.contains("\n\n\n"))45error("double blank line found");4647String expect =48" StackMapTable: number_of_entries = 2\n" +49" frame_type = 252 /* append */\n" +50" offset_delta = 2\n" +51" locals = [ int ]\n" +52" frame_type = 250 /* chop */\n" +53" offset_delta = 18\n";54if (!out.contains(expect))55error("expected text not found");5657if (errors > 0)58throw new Exception(errors + " errors found");59}6061String javap(String... args) throws Exception {62StringWriter sw = new StringWriter();63PrintWriter out = new PrintWriter(sw);64int rc = com.sun.tools.javap.Main.run(args, out);65out.close();66System.out.println(sw.toString());67if (rc < 0)68throw new Exception("javap exited, rc=" + rc);69return sw.toString();70}7172void error(String msg) {73System.out.println("Error: " + msg);74errors++;75}7677int errors;7879/** Simple test class to run through javap. */80public class A {81public void a() {82for (int i = 0; i < 10; i++) {83System.out.println(i);84}85}86public void b() {87}88public void c() {89}90}91}929394