0N/A/*
0N/A * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
3892N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
0N/A * published by the Free Software Foundation.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
0N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
0N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
2362N/A */
2362N/Aimport java.io.File;
0N/Aimport java.io.FileOutputStream;
0N/Aimport java.io.IOException;
0N/Aimport java.util.Map;
0N/Aimport java.util.jar.JarFile;
0N/Aimport java.util.jar.Pack200;
0N/A/*
0N/A * @test
0N/A * @bug 7007157
0N/A * @summary make sure the strip command works on an attribute
0N/A * @compile -XDignore.symbol.file Utils.java T7007157.java
0N/A * @run main T7007157
0N/A * @author ksrini
0N/A */
0N/Apublic class T7007157 {
0N/A
0N/A public static void main(String... args) throws IOException {
0N/A File sdkHome = Utils.JavaSDK;
0N/A File testJar = new File(new File(sdkHome, "lib"), "tools.jar");
0N/A JarFile jarFile = new JarFile(testJar);
0N/A File packFile = new File("foo.pack");
0N/A Pack200.Packer packer = Pack200.newPacker();
0N/A Map<String, String> p = packer.properties();
0N/A // Take the time optimization vs. space
0N/A p.put(packer.EFFORT, "1"); // CAUTION: do not use 0.
0N/A // Make the memory consumption as effective as possible
0N/A p.put(packer.SEGMENT_LIMIT, "10000");
0N/A // ignore all JAR deflation requests to save time
0N/A p.put(packer.DEFLATE_HINT, packer.FALSE);
0N/A // save the file ordering of the original JAR
0N/A p.put(packer.KEEP_FILE_ORDER, packer.TRUE);
0N/A // strip the StackMapTables
0N/A p.put(packer.CODE_ATTRIBUTE_PFX + "StackMapTable", packer.STRIP);
0N/A FileOutputStream fos = null;
0N/A try {
0N/A // Write out to a jtreg scratch area
0N/A fos = new FileOutputStream(packFile);
0N/A // Call the packer
0N/A packer.pack(jarFile, fos);
0N/A } finally {
0N/A Utils.close(fos);
0N/A Utils.close(jarFile);
0N/A }
0N/A }
0N/A}
0N/A