Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/test/tools/pack200/BandIntegrity.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*/2223/*24* @test25* @summary test ensures the proper sequencing of bands, dump bands as well.26* @compile -XDignore.symbol.file Utils.java BandIntegrity.java27* @run main BandIntegrity28* @author ksrini29*/30import java.io.File;31import java.io.IOException;32import java.util.ArrayList;33import java.util.List;3435/*36* This makes use of the optDebugBands to ensure the bands are read in the37* same sequence as it was written. The caveat is that this works only with38* the java unpacker, therefore it will work only with --repack such that39* the java packer and unpacker must be called in the same java instance.40*/41public class BandIntegrity {42public static void main(String... args) throws IOException {43File testFile = new File("test.jar");44Utils.jar("cvf", testFile.getName(),45"-C", Utils.TEST_CLS_DIR.getAbsolutePath(),46".");47List<String> scratch = new ArrayList<>();48// band debugging works only with java unpacker49scratch.add("com.sun.java.util.jar.pack.disable.native=true");50scratch.add("com.sun.java.util.jar.pack.debug.bands=true");51// while at it, might as well exercise this functionality52scratch.add("com.sun.java.util.jar.pack.dump.bands=true");53scratch.add("pack.unknown.attribute=error");54File configFile = new File("pack.conf");55Utils.createFile(configFile, scratch);56File outFile = new File("out.jar");57Utils.repack(testFile, outFile, true,58"-v", "--config-file=" + configFile.getName());59Utils.cleanup();60}61}626364