Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/test/tools/pack200/T7007157.java
38833 views
/*1* Copyright (c) 2010, 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.io.FileOutputStream;24import java.io.IOException;25import java.util.Map;26import java.util.jar.JarFile;27import java.util.jar.Pack200;28/*29* @test30* @bug 700715731* @summary make sure the strip command works on an attribute32* @compile -XDignore.symbol.file Utils.java T7007157.java33* @run main T700715734* @author ksrini35*/36public class T7007157 {3738public static void main(String... args) throws IOException {39File sdkHome = Utils.JavaSDK;40File testJar = new File(new File(sdkHome, "lib"), "tools.jar");41JarFile jarFile = new JarFile(testJar);42File packFile = new File("foo.pack");43Pack200.Packer packer = Pack200.newPacker();44Map<String, String> p = packer.properties();45// Take the time optimization vs. space46p.put(packer.EFFORT, "1"); // CAUTION: do not use 0.47// Make the memory consumption as effective as possible48p.put(packer.SEGMENT_LIMIT, "10000");49// ignore all JAR deflation requests to save time50p.put(packer.DEFLATE_HINT, packer.FALSE);51// save the file ordering of the original JAR52p.put(packer.KEEP_FILE_ORDER, packer.TRUE);53// strip the StackMapTables54p.put(packer.CODE_ATTRIBUTE_PFX + "StackMapTable", packer.STRIP);55FileOutputStream fos = null;56try {57// Write out to a jtreg scratch area58fos = new FileOutputStream(packFile);59// Call the packer60packer.pack(jarFile, fos);61} finally {62Utils.close(fos);63Utils.close(jarFile);64}65Utils.cleanup();66}67}686970