StackMapTest.java revision 3294:9adfb22ff08f
1178481Sjb/* 2178481Sjb * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved. 3178481Sjb * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4178481Sjb * 5178481Sjb * This code is free software; you can redistribute it and/or modify it 6178481Sjb * under the terms of the GNU General Public License version 2 only, as 7178481Sjb * published by the Free Software Foundation. 8178481Sjb * 9178481Sjb * This code is distributed in the hope that it will be useful, but WITHOUT 10178481Sjb * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11178481Sjb * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12178481Sjb * version 2 for more details (a copy is included in the LICENSE file that 13178481Sjb * accompanied this code). 14178481Sjb * 15178481Sjb * You should have received a copy of the GNU General Public License version 16178481Sjb * 2 along with this work; if not, write to the Free Software Foundation, 17178481Sjb * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18178481Sjb * 19178481Sjb * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20178481Sjb * or visit www.oracle.com if you need additional information or have any 21178481Sjb * questions. 22178481Sjb */ 23178481Sjb 24178481Sjb/* 25178481Sjb * @test 26178481Sjb * @bug 4955930 27178481Sjb * @summary The "method0" StackMap attribute should have two entries instead of three 28178481Sjb * @library /tools/lib 29178481Sjb * @modules jdk.compiler/com.sun.tools.javac.api 30178481Sjb * jdk.compiler/com.sun.tools.javac.file 31178481Sjb * jdk.compiler/com.sun.tools.javac.main 32178481Sjb * jdk.jdeps/com.sun.tools.javap 33178481Sjb * @build ToolBox 34178481Sjb * @run compile StackMapTest.java 35178481Sjb * @run main StackMapTest 36178481Sjb */ 37178481Sjb 38178546Sjbimport java.nio.file.Path; 39178481Sjbimport java.nio.file.Paths; 40178481Sjb 41178481Sjb// Original test: test/tools/javac/stackmap/T4955930.sh 42178481Sjbpublic class StackMapTest { 43178481Sjb 44178481Sjb class Test { 45178481Sjb void method0(boolean aboolean) throws Exception { 46178481Sjb label_0: 47178481Sjb while (true) { 48178481Sjb if (aboolean) ; 49178481Sjb else break label_0; 50178481Sjb } 51178481Sjb } 52178481Sjb } 53178481Sjb 54178481Sjb public static void main(String args[]) throws Exception { 55178481Sjb ToolBox tb = new ToolBox(); 56178481Sjb Path pathToClass = Paths.get(ToolBox.testClasses, "StackMapTest$Test.class"); 57178481Sjb String javapOut = tb.new JavapTask() 58178481Sjb .options("-v") 59178481Sjb .classes(pathToClass.toString()) 60178481Sjb .run() 61178481Sjb .getOutput(ToolBox.OutputKind.DIRECT); 62178481Sjb 63178481Sjb if (!javapOut.contains("StackMapTable: number_of_entries = 2")) 64178481Sjb throw new AssertionError("The number of entries of the stack map " 65178481Sjb + "table should be equal to 2"); 66178481Sjb } 67178481Sjb 68178481Sjb} 69178481Sjb