test/jdk/tools/pack200/TestNormal.java
author lancea
Thu, 14 Nov 2019 10:54:32 -0500
changeset 59083 3e4d8b5856f3
parent 47216 71c04702a3d5
permissions -rw-r--r--
8234080: jdk/nio/zipfs/CRCWriteTest.java fails Reviewed-by: clanger, amlu
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
21348
e30c5696b4c5 8020802: Need an ability to create jar files that are invariant to the pack200 packing/unpacking
kizune
parents:
diff changeset
     1
/*
38421
f75f729fdc5c 8156807: Pack200 must support v53.0 class files
ksrini
parents: 27176
diff changeset
     2
 * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
21348
e30c5696b4c5 8020802: Need an ability to create jar files that are invariant to the pack200 packing/unpacking
kizune
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
e30c5696b4c5 8020802: Need an ability to create jar files that are invariant to the pack200 packing/unpacking
kizune
parents:
diff changeset
     4
 *
e30c5696b4c5 8020802: Need an ability to create jar files that are invariant to the pack200 packing/unpacking
kizune
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
e30c5696b4c5 8020802: Need an ability to create jar files that are invariant to the pack200 packing/unpacking
kizune
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
e30c5696b4c5 8020802: Need an ability to create jar files that are invariant to the pack200 packing/unpacking
kizune
parents:
diff changeset
     7
 * published by the Free Software Foundation.
e30c5696b4c5 8020802: Need an ability to create jar files that are invariant to the pack200 packing/unpacking
kizune
parents:
diff changeset
     8
 *
e30c5696b4c5 8020802: Need an ability to create jar files that are invariant to the pack200 packing/unpacking
kizune
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
e30c5696b4c5 8020802: Need an ability to create jar files that are invariant to the pack200 packing/unpacking
kizune
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
e30c5696b4c5 8020802: Need an ability to create jar files that are invariant to the pack200 packing/unpacking
kizune
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
e30c5696b4c5 8020802: Need an ability to create jar files that are invariant to the pack200 packing/unpacking
kizune
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
e30c5696b4c5 8020802: Need an ability to create jar files that are invariant to the pack200 packing/unpacking
kizune
parents:
diff changeset
    13
 * accompanied this code).
e30c5696b4c5 8020802: Need an ability to create jar files that are invariant to the pack200 packing/unpacking
kizune
parents:
diff changeset
    14
 *
e30c5696b4c5 8020802: Need an ability to create jar files that are invariant to the pack200 packing/unpacking
kizune
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
e30c5696b4c5 8020802: Need an ability to create jar files that are invariant to the pack200 packing/unpacking
kizune
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
e30c5696b4c5 8020802: Need an ability to create jar files that are invariant to the pack200 packing/unpacking
kizune
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
e30c5696b4c5 8020802: Need an ability to create jar files that are invariant to the pack200 packing/unpacking
kizune
parents:
diff changeset
    18
 *
e30c5696b4c5 8020802: Need an ability to create jar files that are invariant to the pack200 packing/unpacking
kizune
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
e30c5696b4c5 8020802: Need an ability to create jar files that are invariant to the pack200 packing/unpacking
kizune
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
e30c5696b4c5 8020802: Need an ability to create jar files that are invariant to the pack200 packing/unpacking
kizune
parents:
diff changeset
    21
 * questions.
e30c5696b4c5 8020802: Need an ability to create jar files that are invariant to the pack200 packing/unpacking
kizune
parents:
diff changeset
    22
 */
e30c5696b4c5 8020802: Need an ability to create jar files that are invariant to the pack200 packing/unpacking
kizune
parents:
diff changeset
    23
e30c5696b4c5 8020802: Need an ability to create jar files that are invariant to the pack200 packing/unpacking
kizune
parents:
diff changeset
    24
e30c5696b4c5 8020802: Need an ability to create jar files that are invariant to the pack200 packing/unpacking
kizune
parents:
diff changeset
    25
/*
e30c5696b4c5 8020802: Need an ability to create jar files that are invariant to the pack200 packing/unpacking
kizune
parents:
diff changeset
    26
 * @test
e30c5696b4c5 8020802: Need an ability to create jar files that are invariant to the pack200 packing/unpacking
kizune
parents:
diff changeset
    27
 * @run main/timeout=600 TestNormal
38421
f75f729fdc5c 8156807: Pack200 must support v53.0 class files
ksrini
parents: 27176
diff changeset
    28
 * @bug 8020802 8156807
21348
e30c5696b4c5 8020802: Need an ability to create jar files that are invariant to the pack200 packing/unpacking
kizune
parents:
diff changeset
    29
 * @summary Need an ability to create jar files that are invariant to the pack200 packing/unpacking
e30c5696b4c5 8020802: Need an ability to create jar files that are invariant to the pack200 packing/unpacking
kizune
parents:
diff changeset
    30
 * @author Alexander Zuev
e30c5696b4c5 8020802: Need an ability to create jar files that are invariant to the pack200 packing/unpacking
kizune
parents:
diff changeset
    31
 */
e30c5696b4c5 8020802: Need an ability to create jar files that are invariant to the pack200 packing/unpacking
kizune
parents:
diff changeset
    32
e30c5696b4c5 8020802: Need an ability to create jar files that are invariant to the pack200 packing/unpacking
kizune
parents:
diff changeset
    33
import java.io.*;
e30c5696b4c5 8020802: Need an ability to create jar files that are invariant to the pack200 packing/unpacking
kizune
parents:
diff changeset
    34
e30c5696b4c5 8020802: Need an ability to create jar files that are invariant to the pack200 packing/unpacking
kizune
parents:
diff changeset
    35
public class TestNormal {
e30c5696b4c5 8020802: Need an ability to create jar files that are invariant to the pack200 packing/unpacking
kizune
parents:
diff changeset
    36
    private static String FS = File.separator;
e30c5696b4c5 8020802: Need an ability to create jar files that are invariant to the pack200 packing/unpacking
kizune
parents:
diff changeset
    37
e30c5696b4c5 8020802: Need an ability to create jar files that are invariant to the pack200 packing/unpacking
kizune
parents:
diff changeset
    38
    public static void main(String args[]) throws Exception {
27176
7009a264e019 8060432: tools/pack200/TestNormal.java fails on Windows with java.io.FileNotFoundException after JDK-8058854
ksrini
parents: 27035
diff changeset
    39
        String testdir = Utils.TEST_CLS_DIR.getAbsolutePath();
21348
e30c5696b4c5 8020802: Need an ability to create jar files that are invariant to the pack200 packing/unpacking
kizune
parents:
diff changeset
    40
e30c5696b4c5 8020802: Need an ability to create jar files that are invariant to the pack200 packing/unpacking
kizune
parents:
diff changeset
    41
        try {
38421
f75f729fdc5c 8156807: Pack200 must support v53.0 class files
ksrini
parents: 27176
diff changeset
    42
            String jarCmd = Utils.getJarCmd();
f75f729fdc5c 8156807: Pack200 must support v53.0 class files
ksrini
parents: 27176
diff changeset
    43
            String packCmd = Utils.getPack200Cmd();
21348
e30c5696b4c5 8020802: Need an ability to create jar files that are invariant to the pack200 packing/unpacking
kizune
parents:
diff changeset
    44
38421
f75f729fdc5c 8156807: Pack200 must support v53.0 class files
ksrini
parents: 27176
diff changeset
    45
            // create the original jar
f75f729fdc5c 8156807: Pack200 must support v53.0 class files
ksrini
parents: 27176
diff changeset
    46
            Utils.runExec(jarCmd, "cf", "original.jar", "-C", testdir, ".");
f75f729fdc5c 8156807: Pack200 must support v53.0 class files
ksrini
parents: 27176
diff changeset
    47
f75f729fdc5c 8156807: Pack200 must support v53.0 class files
ksrini
parents: 27176
diff changeset
    48
            // create the reference jar
f75f729fdc5c 8156807: Pack200 must support v53.0 class files
ksrini
parents: 27176
diff changeset
    49
            Utils.runExec(packCmd, "-r", "repacked.jar", "original.jar");
21348
e30c5696b4c5 8020802: Need an ability to create jar files that are invariant to the pack200 packing/unpacking
kizune
parents:
diff changeset
    50
38421
f75f729fdc5c 8156807: Pack200 must support v53.0 class files
ksrini
parents: 27176
diff changeset
    51
            // create the normalized jar using jar(1)
f75f729fdc5c 8156807: Pack200 must support v53.0 class files
ksrini
parents: 27176
diff changeset
    52
            Utils.runExec(jarCmd, "cnf", "normalized.jar", "-C", testdir, ".");
f75f729fdc5c 8156807: Pack200 must support v53.0 class files
ksrini
parents: 27176
diff changeset
    53
f75f729fdc5c 8156807: Pack200 must support v53.0 class files
ksrini
parents: 27176
diff changeset
    54
            // compare archive contents bit wise, these should be identical!
f75f729fdc5c 8156807: Pack200 must support v53.0 class files
ksrini
parents: 27176
diff changeset
    55
            Utils.doCompareBitWise(new File("repacked.jar"),
f75f729fdc5c 8156807: Pack200 must support v53.0 class files
ksrini
parents: 27176
diff changeset
    56
                    new File("normalized.jar"));
21348
e30c5696b4c5 8020802: Need an ability to create jar files that are invariant to the pack200 packing/unpacking
kizune
parents:
diff changeset
    57
        } finally {
38421
f75f729fdc5c 8156807: Pack200 must support v53.0 class files
ksrini
parents: 27176
diff changeset
    58
           Utils.cleanup();
21348
e30c5696b4c5 8020802: Need an ability to create jar files that are invariant to the pack200 packing/unpacking
kizune
parents:
diff changeset
    59
        }
e30c5696b4c5 8020802: Need an ability to create jar files that are invariant to the pack200 packing/unpacking
kizune
parents:
diff changeset
    60
    }
e30c5696b4c5 8020802: Need an ability to create jar files that are invariant to the pack200 packing/unpacking
kizune
parents:
diff changeset
    61
}