test/jdk/tools/pack200/PackChecksum.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:
25149
7df9d6b3ef17 8000650: unpack200.exe should check gzip crc
kizune
parents:
diff changeset
     1
/*
36960
d7731fdfe7c3 8150469: unpack200 fails to compare crc correctly.
ksrini
parents: 25149
diff changeset
     2
 * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
25149
7df9d6b3ef17 8000650: unpack200.exe should check gzip crc
kizune
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
7df9d6b3ef17 8000650: unpack200.exe should check gzip crc
kizune
parents:
diff changeset
     4
 *
7df9d6b3ef17 8000650: unpack200.exe should check gzip crc
kizune
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
7df9d6b3ef17 8000650: unpack200.exe should check gzip crc
kizune
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
7df9d6b3ef17 8000650: unpack200.exe should check gzip crc
kizune
parents:
diff changeset
     7
 * published by the Free Software Foundation.
7df9d6b3ef17 8000650: unpack200.exe should check gzip crc
kizune
parents:
diff changeset
     8
 *
7df9d6b3ef17 8000650: unpack200.exe should check gzip crc
kizune
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
7df9d6b3ef17 8000650: unpack200.exe should check gzip crc
kizune
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
7df9d6b3ef17 8000650: unpack200.exe should check gzip crc
kizune
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
7df9d6b3ef17 8000650: unpack200.exe should check gzip crc
kizune
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
7df9d6b3ef17 8000650: unpack200.exe should check gzip crc
kizune
parents:
diff changeset
    13
 * accompanied this code).
7df9d6b3ef17 8000650: unpack200.exe should check gzip crc
kizune
parents:
diff changeset
    14
 *
7df9d6b3ef17 8000650: unpack200.exe should check gzip crc
kizune
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
7df9d6b3ef17 8000650: unpack200.exe should check gzip crc
kizune
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
7df9d6b3ef17 8000650: unpack200.exe should check gzip crc
kizune
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
7df9d6b3ef17 8000650: unpack200.exe should check gzip crc
kizune
parents:
diff changeset
    18
 *
7df9d6b3ef17 8000650: unpack200.exe should check gzip crc
kizune
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
7df9d6b3ef17 8000650: unpack200.exe should check gzip crc
kizune
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
7df9d6b3ef17 8000650: unpack200.exe should check gzip crc
kizune
parents:
diff changeset
    21
 * questions.
7df9d6b3ef17 8000650: unpack200.exe should check gzip crc
kizune
parents:
diff changeset
    22
 */
7df9d6b3ef17 8000650: unpack200.exe should check gzip crc
kizune
parents:
diff changeset
    23
import java.io.File;
7df9d6b3ef17 8000650: unpack200.exe should check gzip crc
kizune
parents:
diff changeset
    24
import java.io.FileOutputStream;
7df9d6b3ef17 8000650: unpack200.exe should check gzip crc
kizune
parents:
diff changeset
    25
import java.io.IOException;
7df9d6b3ef17 8000650: unpack200.exe should check gzip crc
kizune
parents:
diff changeset
    26
import java.io.RandomAccessFile;
7df9d6b3ef17 8000650: unpack200.exe should check gzip crc
kizune
parents:
diff changeset
    27
import java.util.ArrayList;
7df9d6b3ef17 8000650: unpack200.exe should check gzip crc
kizune
parents:
diff changeset
    28
import java.util.List;
7df9d6b3ef17 8000650: unpack200.exe should check gzip crc
kizune
parents:
diff changeset
    29
import java.util.jar.JarEntry;
7df9d6b3ef17 8000650: unpack200.exe should check gzip crc
kizune
parents:
diff changeset
    30
import java.util.jar.JarOutputStream;
7df9d6b3ef17 8000650: unpack200.exe should check gzip crc
kizune
parents:
diff changeset
    31
7df9d6b3ef17 8000650: unpack200.exe should check gzip crc
kizune
parents:
diff changeset
    32
/*
7df9d6b3ef17 8000650: unpack200.exe should check gzip crc
kizune
parents:
diff changeset
    33
 * @test
36960
d7731fdfe7c3 8150469: unpack200 fails to compare crc correctly.
ksrini
parents: 25149
diff changeset
    34
 * @bug 8000650 8150469
25149
7df9d6b3ef17 8000650: unpack200.exe should check gzip crc
kizune
parents:
diff changeset
    35
 * @summary unpack200.exe should check gzip crc
7df9d6b3ef17 8000650: unpack200.exe should check gzip crc
kizune
parents:
diff changeset
    36
 * @compile -XDignore.symbol.file Utils.java PackChecksum.java
7df9d6b3ef17 8000650: unpack200.exe should check gzip crc
kizune
parents:
diff changeset
    37
 * @run main PackChecksum
7df9d6b3ef17 8000650: unpack200.exe should check gzip crc
kizune
parents:
diff changeset
    38
 * @author kizune
7df9d6b3ef17 8000650: unpack200.exe should check gzip crc
kizune
parents:
diff changeset
    39
 */
7df9d6b3ef17 8000650: unpack200.exe should check gzip crc
kizune
parents:
diff changeset
    40
public class PackChecksum {
36960
d7731fdfe7c3 8150469: unpack200 fails to compare crc correctly.
ksrini
parents: 25149
diff changeset
    41
    final int TRAILER_LEN = 8;
d7731fdfe7c3 8150469: unpack200 fails to compare crc correctly.
ksrini
parents: 25149
diff changeset
    42
    final List<String> cmdsList = new ArrayList<>();
d7731fdfe7c3 8150469: unpack200 fails to compare crc correctly.
ksrini
parents: 25149
diff changeset
    43
    static enum Case {
d7731fdfe7c3 8150469: unpack200 fails to compare crc correctly.
ksrini
parents: 25149
diff changeset
    44
        CRC32,
d7731fdfe7c3 8150469: unpack200 fails to compare crc correctly.
ksrini
parents: 25149
diff changeset
    45
        ISIZE,
d7731fdfe7c3 8150469: unpack200 fails to compare crc correctly.
ksrini
parents: 25149
diff changeset
    46
        BOTH;
25149
7df9d6b3ef17 8000650: unpack200.exe should check gzip crc
kizune
parents:
diff changeset
    47
36960
d7731fdfe7c3 8150469: unpack200 fails to compare crc correctly.
ksrini
parents: 25149
diff changeset
    48
    };
25149
7df9d6b3ef17 8000650: unpack200.exe should check gzip crc
kizune
parents:
diff changeset
    49
    public static void main(String... args) throws Exception {
36960
d7731fdfe7c3 8150469: unpack200 fails to compare crc correctly.
ksrini
parents: 25149
diff changeset
    50
        new PackChecksum().run();
d7731fdfe7c3 8150469: unpack200 fails to compare crc correctly.
ksrini
parents: 25149
diff changeset
    51
    }
d7731fdfe7c3 8150469: unpack200 fails to compare crc correctly.
ksrini
parents: 25149
diff changeset
    52
    void run() throws Exception {
d7731fdfe7c3 8150469: unpack200 fails to compare crc correctly.
ksrini
parents: 25149
diff changeset
    53
        testBrokenTrailer(Case.CRC32); // negative
d7731fdfe7c3 8150469: unpack200 fails to compare crc correctly.
ksrini
parents: 25149
diff changeset
    54
        testBrokenTrailer(Case.ISIZE); // negative
d7731fdfe7c3 8150469: unpack200 fails to compare crc correctly.
ksrini
parents: 25149
diff changeset
    55
        testBrokenTrailer(Case.BOTH);  // negative
d7731fdfe7c3 8150469: unpack200 fails to compare crc correctly.
ksrini
parents: 25149
diff changeset
    56
        testMultipleSegments();
25149
7df9d6b3ef17 8000650: unpack200.exe should check gzip crc
kizune
parents:
diff changeset
    57
    }
7df9d6b3ef17 8000650: unpack200.exe should check gzip crc
kizune
parents:
diff changeset
    58
36960
d7731fdfe7c3 8150469: unpack200 fails to compare crc correctly.
ksrini
parents: 25149
diff changeset
    59
    void testMultipleSegments() throws Exception {
d7731fdfe7c3 8150469: unpack200 fails to compare crc correctly.
ksrini
parents: 25149
diff changeset
    60
        File inputJar = new File("input.jar");
d7731fdfe7c3 8150469: unpack200 fails to compare crc correctly.
ksrini
parents: 25149
diff changeset
    61
        Utils.copyFile(Utils.getGoldenJar(), inputJar);
d7731fdfe7c3 8150469: unpack200 fails to compare crc correctly.
ksrini
parents: 25149
diff changeset
    62
        cmdsList.clear();
d7731fdfe7c3 8150469: unpack200 fails to compare crc correctly.
ksrini
parents: 25149
diff changeset
    63
d7731fdfe7c3 8150469: unpack200 fails to compare crc correctly.
ksrini
parents: 25149
diff changeset
    64
        File testPack = new File("out.jar.pack.gz");
d7731fdfe7c3 8150469: unpack200 fails to compare crc correctly.
ksrini
parents: 25149
diff changeset
    65
d7731fdfe7c3 8150469: unpack200 fails to compare crc correctly.
ksrini
parents: 25149
diff changeset
    66
        cmdsList.clear();
d7731fdfe7c3 8150469: unpack200 fails to compare crc correctly.
ksrini
parents: 25149
diff changeset
    67
        cmdsList.add(Utils.getPack200Cmd());
d7731fdfe7c3 8150469: unpack200 fails to compare crc correctly.
ksrini
parents: 25149
diff changeset
    68
        // force multiple segments
d7731fdfe7c3 8150469: unpack200 fails to compare crc correctly.
ksrini
parents: 25149
diff changeset
    69
        cmdsList.add("--segment-limit=100");
d7731fdfe7c3 8150469: unpack200 fails to compare crc correctly.
ksrini
parents: 25149
diff changeset
    70
        cmdsList.add(testPack.getName());
d7731fdfe7c3 8150469: unpack200 fails to compare crc correctly.
ksrini
parents: 25149
diff changeset
    71
        cmdsList.add(inputJar.getName());
d7731fdfe7c3 8150469: unpack200 fails to compare crc correctly.
ksrini
parents: 25149
diff changeset
    72
        Utils.runExec(cmdsList);
25149
7df9d6b3ef17 8000650: unpack200.exe should check gzip crc
kizune
parents:
diff changeset
    73
36960
d7731fdfe7c3 8150469: unpack200 fails to compare crc correctly.
ksrini
parents: 25149
diff changeset
    74
        File destFile = new File("dst.jar");
d7731fdfe7c3 8150469: unpack200 fails to compare crc correctly.
ksrini
parents: 25149
diff changeset
    75
        cmdsList.clear();
d7731fdfe7c3 8150469: unpack200 fails to compare crc correctly.
ksrini
parents: 25149
diff changeset
    76
        cmdsList.add(Utils.getUnpack200Cmd());
d7731fdfe7c3 8150469: unpack200 fails to compare crc correctly.
ksrini
parents: 25149
diff changeset
    77
        cmdsList.add(testPack.getName());
d7731fdfe7c3 8150469: unpack200 fails to compare crc correctly.
ksrini
parents: 25149
diff changeset
    78
        cmdsList.add(destFile.getName());
d7731fdfe7c3 8150469: unpack200 fails to compare crc correctly.
ksrini
parents: 25149
diff changeset
    79
        try {
d7731fdfe7c3 8150469: unpack200 fails to compare crc correctly.
ksrini
parents: 25149
diff changeset
    80
            Utils.runExec(cmdsList);
d7731fdfe7c3 8150469: unpack200 fails to compare crc correctly.
ksrini
parents: 25149
diff changeset
    81
            if (!destFile.exists()) {
d7731fdfe7c3 8150469: unpack200 fails to compare crc correctly.
ksrini
parents: 25149
diff changeset
    82
                throw new Exception("file not created: " + destFile);
d7731fdfe7c3 8150469: unpack200 fails to compare crc correctly.
ksrini
parents: 25149
diff changeset
    83
            }
d7731fdfe7c3 8150469: unpack200 fails to compare crc correctly.
ksrini
parents: 25149
diff changeset
    84
        } finally {
d7731fdfe7c3 8150469: unpack200 fails to compare crc correctly.
ksrini
parents: 25149
diff changeset
    85
            if (inputJar.exists())
d7731fdfe7c3 8150469: unpack200 fails to compare crc correctly.
ksrini
parents: 25149
diff changeset
    86
                inputJar.delete();
d7731fdfe7c3 8150469: unpack200 fails to compare crc correctly.
ksrini
parents: 25149
diff changeset
    87
            if (testPack.exists())
d7731fdfe7c3 8150469: unpack200 fails to compare crc correctly.
ksrini
parents: 25149
diff changeset
    88
                testPack.delete();
d7731fdfe7c3 8150469: unpack200 fails to compare crc correctly.
ksrini
parents: 25149
diff changeset
    89
            if (destFile.exists())
d7731fdfe7c3 8150469: unpack200 fails to compare crc correctly.
ksrini
parents: 25149
diff changeset
    90
                destFile.delete();
d7731fdfe7c3 8150469: unpack200 fails to compare crc correctly.
ksrini
parents: 25149
diff changeset
    91
        }
d7731fdfe7c3 8150469: unpack200 fails to compare crc correctly.
ksrini
parents: 25149
diff changeset
    92
    }
d7731fdfe7c3 8150469: unpack200 fails to compare crc correctly.
ksrini
parents: 25149
diff changeset
    93
d7731fdfe7c3 8150469: unpack200 fails to compare crc correctly.
ksrini
parents: 25149
diff changeset
    94
    void testBrokenTrailer(Case type) throws Exception {
d7731fdfe7c3 8150469: unpack200 fails to compare crc correctly.
ksrini
parents: 25149
diff changeset
    95
        System.out.println("Testing: case " + type);
25149
7df9d6b3ef17 8000650: unpack200.exe should check gzip crc
kizune
parents:
diff changeset
    96
        // Create a fresh .jar file
7df9d6b3ef17 8000650: unpack200.exe should check gzip crc
kizune
parents:
diff changeset
    97
        File testFile = new File("src_tools.jar");
7df9d6b3ef17 8000650: unpack200.exe should check gzip crc
kizune
parents:
diff changeset
    98
        File testPack = new File("src_tools.pack.gz");
7df9d6b3ef17 8000650: unpack200.exe should check gzip crc
kizune
parents:
diff changeset
    99
        generateJar(testFile);
7df9d6b3ef17 8000650: unpack200.exe should check gzip crc
kizune
parents:
diff changeset
   100
36960
d7731fdfe7c3 8150469: unpack200 fails to compare crc correctly.
ksrini
parents: 25149
diff changeset
   101
        cmdsList.clear();
25149
7df9d6b3ef17 8000650: unpack200.exe should check gzip crc
kizune
parents:
diff changeset
   102
        // Create .pack file
7df9d6b3ef17 8000650: unpack200.exe should check gzip crc
kizune
parents:
diff changeset
   103
        cmdsList.add(Utils.getPack200Cmd());
7df9d6b3ef17 8000650: unpack200.exe should check gzip crc
kizune
parents:
diff changeset
   104
        cmdsList.add(testPack.getName());
7df9d6b3ef17 8000650: unpack200.exe should check gzip crc
kizune
parents:
diff changeset
   105
        cmdsList.add(testFile.getName());
7df9d6b3ef17 8000650: unpack200.exe should check gzip crc
kizune
parents:
diff changeset
   106
        Utils.runExec(cmdsList);
7df9d6b3ef17 8000650: unpack200.exe should check gzip crc
kizune
parents:
diff changeset
   107
36960
d7731fdfe7c3 8150469: unpack200 fails to compare crc correctly.
ksrini
parents: 25149
diff changeset
   108
        // mutate the checksum of the packed file
25149
7df9d6b3ef17 8000650: unpack200.exe should check gzip crc
kizune
parents:
diff changeset
   109
        RandomAccessFile raf = new RandomAccessFile(testPack, "rw");
36960
d7731fdfe7c3 8150469: unpack200 fails to compare crc correctly.
ksrini
parents: 25149
diff changeset
   110
d7731fdfe7c3 8150469: unpack200 fails to compare crc correctly.
ksrini
parents: 25149
diff changeset
   111
        switch (type) {
d7731fdfe7c3 8150469: unpack200 fails to compare crc correctly.
ksrini
parents: 25149
diff changeset
   112
            case CRC32:
d7731fdfe7c3 8150469: unpack200 fails to compare crc correctly.
ksrini
parents: 25149
diff changeset
   113
                raf.seek(raf.length() - TRAILER_LEN);
d7731fdfe7c3 8150469: unpack200 fails to compare crc correctly.
ksrini
parents: 25149
diff changeset
   114
                raf.writeInt(0x0dea0a0d);
d7731fdfe7c3 8150469: unpack200 fails to compare crc correctly.
ksrini
parents: 25149
diff changeset
   115
                break;
d7731fdfe7c3 8150469: unpack200 fails to compare crc correctly.
ksrini
parents: 25149
diff changeset
   116
            case ISIZE:
d7731fdfe7c3 8150469: unpack200 fails to compare crc correctly.
ksrini
parents: 25149
diff changeset
   117
                raf.seek(raf.length() - (TRAILER_LEN/2));
d7731fdfe7c3 8150469: unpack200 fails to compare crc correctly.
ksrini
parents: 25149
diff changeset
   118
                raf.writeInt(0x0b0e0e0f);
d7731fdfe7c3 8150469: unpack200 fails to compare crc correctly.
ksrini
parents: 25149
diff changeset
   119
                break;
d7731fdfe7c3 8150469: unpack200 fails to compare crc correctly.
ksrini
parents: 25149
diff changeset
   120
            default:
d7731fdfe7c3 8150469: unpack200 fails to compare crc correctly.
ksrini
parents: 25149
diff changeset
   121
                raf.seek(raf.length() - (TRAILER_LEN));
d7731fdfe7c3 8150469: unpack200 fails to compare crc correctly.
ksrini
parents: 25149
diff changeset
   122
                raf.writeLong(0x0dea0a0d0b0e0e0fL);
d7731fdfe7c3 8150469: unpack200 fails to compare crc correctly.
ksrini
parents: 25149
diff changeset
   123
                break;
d7731fdfe7c3 8150469: unpack200 fails to compare crc correctly.
ksrini
parents: 25149
diff changeset
   124
        }
d7731fdfe7c3 8150469: unpack200 fails to compare crc correctly.
ksrini
parents: 25149
diff changeset
   125
25149
7df9d6b3ef17 8000650: unpack200.exe should check gzip crc
kizune
parents:
diff changeset
   126
        raf.close();
7df9d6b3ef17 8000650: unpack200.exe should check gzip crc
kizune
parents:
diff changeset
   127
7df9d6b3ef17 8000650: unpack200.exe should check gzip crc
kizune
parents:
diff changeset
   128
        File dstFile = new File("dst_tools.jar");
36960
d7731fdfe7c3 8150469: unpack200 fails to compare crc correctly.
ksrini
parents: 25149
diff changeset
   129
        if (dstFile.exists()) {
d7731fdfe7c3 8150469: unpack200 fails to compare crc correctly.
ksrini
parents: 25149
diff changeset
   130
            dstFile.delete();
d7731fdfe7c3 8150469: unpack200 fails to compare crc correctly.
ksrini
parents: 25149
diff changeset
   131
        }
25149
7df9d6b3ef17 8000650: unpack200.exe should check gzip crc
kizune
parents:
diff changeset
   132
        cmdsList.clear();
7df9d6b3ef17 8000650: unpack200.exe should check gzip crc
kizune
parents:
diff changeset
   133
        cmdsList.add(Utils.getUnpack200Cmd());
7df9d6b3ef17 8000650: unpack200.exe should check gzip crc
kizune
parents:
diff changeset
   134
        cmdsList.add(testPack.getName());
7df9d6b3ef17 8000650: unpack200.exe should check gzip crc
kizune
parents:
diff changeset
   135
        cmdsList.add(dstFile.getName());
7df9d6b3ef17 8000650: unpack200.exe should check gzip crc
kizune
parents:
diff changeset
   136
36960
d7731fdfe7c3 8150469: unpack200 fails to compare crc correctly.
ksrini
parents: 25149
diff changeset
   137
        boolean processFailed = false;
25149
7df9d6b3ef17 8000650: unpack200.exe should check gzip crc
kizune
parents:
diff changeset
   138
        try {
7df9d6b3ef17 8000650: unpack200.exe should check gzip crc
kizune
parents:
diff changeset
   139
            Utils.runExec(cmdsList);
7df9d6b3ef17 8000650: unpack200.exe should check gzip crc
kizune
parents:
diff changeset
   140
        } catch (RuntimeException re) {
7df9d6b3ef17 8000650: unpack200.exe should check gzip crc
kizune
parents:
diff changeset
   141
            // unpack200 should exit with non-zero exit code
36960
d7731fdfe7c3 8150469: unpack200 fails to compare crc correctly.
ksrini
parents: 25149
diff changeset
   142
            processFailed = true;
d7731fdfe7c3 8150469: unpack200 fails to compare crc correctly.
ksrini
parents: 25149
diff changeset
   143
        } finally {
d7731fdfe7c3 8150469: unpack200 fails to compare crc correctly.
ksrini
parents: 25149
diff changeset
   144
            // tidy up
d7731fdfe7c3 8150469: unpack200 fails to compare crc correctly.
ksrini
parents: 25149
diff changeset
   145
            if (testFile.exists())
d7731fdfe7c3 8150469: unpack200 fails to compare crc correctly.
ksrini
parents: 25149
diff changeset
   146
                testFile.delete();
d7731fdfe7c3 8150469: unpack200 fails to compare crc correctly.
ksrini
parents: 25149
diff changeset
   147
d7731fdfe7c3 8150469: unpack200 fails to compare crc correctly.
ksrini
parents: 25149
diff changeset
   148
            if (testPack.exists())
d7731fdfe7c3 8150469: unpack200 fails to compare crc correctly.
ksrini
parents: 25149
diff changeset
   149
                testPack.delete();
25149
7df9d6b3ef17 8000650: unpack200.exe should check gzip crc
kizune
parents:
diff changeset
   150
36960
d7731fdfe7c3 8150469: unpack200 fails to compare crc correctly.
ksrini
parents: 25149
diff changeset
   151
            if (!processFailed) {
d7731fdfe7c3 8150469: unpack200 fails to compare crc correctly.
ksrini
parents: 25149
diff changeset
   152
                throw new Exception("case " + type +
d7731fdfe7c3 8150469: unpack200 fails to compare crc correctly.
ksrini
parents: 25149
diff changeset
   153
                        ": file with incorrect CRC, unpacked without the error.");
d7731fdfe7c3 8150469: unpack200 fails to compare crc correctly.
ksrini
parents: 25149
diff changeset
   154
            }
d7731fdfe7c3 8150469: unpack200 fails to compare crc correctly.
ksrini
parents: 25149
diff changeset
   155
            if (dstFile.exists()) {
d7731fdfe7c3 8150469: unpack200 fails to compare crc correctly.
ksrini
parents: 25149
diff changeset
   156
                dstFile.delete();
d7731fdfe7c3 8150469: unpack200 fails to compare crc correctly.
ksrini
parents: 25149
diff changeset
   157
                throw new Exception("case " + type +
d7731fdfe7c3 8150469: unpack200 fails to compare crc correctly.
ksrini
parents: 25149
diff changeset
   158
                        ":  file exists: " + dstFile);
d7731fdfe7c3 8150469: unpack200 fails to compare crc correctly.
ksrini
parents: 25149
diff changeset
   159
            }
25149
7df9d6b3ef17 8000650: unpack200.exe should check gzip crc
kizune
parents:
diff changeset
   160
        }
7df9d6b3ef17 8000650: unpack200.exe should check gzip crc
kizune
parents:
diff changeset
   161
    }
7df9d6b3ef17 8000650: unpack200.exe should check gzip crc
kizune
parents:
diff changeset
   162
36960
d7731fdfe7c3 8150469: unpack200 fails to compare crc correctly.
ksrini
parents: 25149
diff changeset
   163
    void generateJar(File result) throws IOException {
25149
7df9d6b3ef17 8000650: unpack200.exe should check gzip crc
kizune
parents:
diff changeset
   164
        if (result.exists()) {
7df9d6b3ef17 8000650: unpack200.exe should check gzip crc
kizune
parents:
diff changeset
   165
            result.delete();
7df9d6b3ef17 8000650: unpack200.exe should check gzip crc
kizune
parents:
diff changeset
   166
        }
7df9d6b3ef17 8000650: unpack200.exe should check gzip crc
kizune
parents:
diff changeset
   167
7df9d6b3ef17 8000650: unpack200.exe should check gzip crc
kizune
parents:
diff changeset
   168
        try (JarOutputStream output = new JarOutputStream(new FileOutputStream(result)); ) {
7df9d6b3ef17 8000650: unpack200.exe should check gzip crc
kizune
parents:
diff changeset
   169
            for (int i = 0 ; i < 100 ; i++) {
7df9d6b3ef17 8000650: unpack200.exe should check gzip crc
kizune
parents:
diff changeset
   170
                JarEntry e = new JarEntry("F-" + i + ".txt");
7df9d6b3ef17 8000650: unpack200.exe should check gzip crc
kizune
parents:
diff changeset
   171
                output.putNextEntry(e);
7df9d6b3ef17 8000650: unpack200.exe should check gzip crc
kizune
parents:
diff changeset
   172
            }
7df9d6b3ef17 8000650: unpack200.exe should check gzip crc
kizune
parents:
diff changeset
   173
            output.flush();
7df9d6b3ef17 8000650: unpack200.exe should check gzip crc
kizune
parents:
diff changeset
   174
            output.close();
7df9d6b3ef17 8000650: unpack200.exe should check gzip crc
kizune
parents:
diff changeset
   175
        }
7df9d6b3ef17 8000650: unpack200.exe should check gzip crc
kizune
parents:
diff changeset
   176
    }
7df9d6b3ef17 8000650: unpack200.exe should check gzip crc
kizune
parents:
diff changeset
   177
7df9d6b3ef17 8000650: unpack200.exe should check gzip crc
kizune
parents:
diff changeset
   178
}