Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/test/tools/pack200/InstructionTests.java
38833 views
/*1* Copyright (c) 2013, 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*/22import java.io.File;23import java.util.ArrayList;24import java.util.List;2526/*27* @test28* @bug 8003549 800729729* @summary tests class files instruction formats introduced in JSR-33530* @compile -XDignore.symbol.file Utils.java InstructionTests.java31* @run main InstructionTests32* @author ksrini33*/34public class InstructionTests {35public static void main(String... args) throws Exception {36testInvokeOpCodes();37Utils.cleanup();38}39/*40* the following should produce invokestatic and invokespecial41* on InterfaceMethodRefs vs. MethodRefs, packer/unpacker should work42*/43static void testInvokeOpCodes() throws Exception {44List<String> scratch = new ArrayList<>();45final String fname = "A";46String javaFileName = fname + Utils.JAVA_FILE_EXT;47scratch.add("interface I {");48scratch.add(" default void forEach(){}");49scratch.add(" static void next() {}");50scratch.add("}");51scratch.add("class A implements I {");52scratch.add(" public void forEach(Object o){");53scratch.add(" I.super.forEach();");54scratch.add(" I.next();");55scratch.add(" }");56scratch.add("}");57File cwd = new File(".");58File javaFile = new File(cwd, javaFileName);59Utils.createFile(javaFile, scratch);6061// -g to compare LVT and LNT entries62Utils.compiler("-g", javaFile.getName());6364File propsFile = new File("pack.props");65scratch.clear();66scratch.add("com.sun.java.util.jar.pack.class.format.error=error");67scratch.add("pack.unknown.attribute=error");68Utils.createFile(propsFile, scratch);69// jar the file up70File testjarFile = new File(cwd, "test" + Utils.JAR_FILE_EXT);71Utils.jar("cvf", testjarFile.getName(), ".");7273Utils.testWithRepack(testjarFile, "--config-file=" + propsFile.getName());74}75}767778