Separating the unzipping functionality into own module. Step one. closure
authorJaroslav Tulach <jaroslav.tulach@apidesign.org>
Wed, 07 May 2014 16:47:24 +0200
branchclosure
changeset 15493f4c143ff8f0
parent 1548 225ba1d7bdc9
child 1550 cb9e273dfd51
Separating the unzipping functionality into own module. Step one.
pom.xml
rt/emul/compact/src/test/java/org/apidesign/bck2brwsr/compact/tck/ZipArchive.java
rt/emul/compact/src/test/java/org/apidesign/bck2brwsr/compact/tck/ZipCompatibilityTest.java
rt/emul/compact/src/test/java/org/apidesign/bck2brwsr/compact/tck/ZipVsJzLibTest.java
rt/emul/compact/src/test/java/org/apidesign/bck2brwsr/vmtest/impl/CRC32Test.java
rt/emul/compact/src/test/java/org/apidesign/bck2brwsr/vmtest/impl/ZipEntryTest.java
rt/emul/compact/src/test/java/org/apidesign/bck2brwsr/vmtest/impl/ZipFileTest.java
rt/emul/mini/src/main/java/java/util/zip/Adler32.java
rt/emul/mini/src/main/java/java/util/zip/CRC32.java
rt/emul/mini/src/main/java/java/util/zip/Checksum.java
rt/emul/mini/src/main/java/java/util/zip/DataFormatException.java
rt/emul/mini/src/main/java/java/util/zip/Inflater.java
rt/emul/mini/src/main/java/java/util/zip/InflaterInputStream.java
rt/emul/mini/src/main/java/java/util/zip/ZStreamRef.java
rt/emul/mini/src/main/java/java/util/zip/ZipConstants.java
rt/emul/mini/src/main/java/java/util/zip/ZipEntry.java
rt/emul/mini/src/main/java/java/util/zip/ZipException.java
rt/emul/mini/src/main/java/java/util/zip/ZipInputStream.java
rt/emul/mini/src/main/java/java/util/zip/package-info.java
rt/emul/mini/src/main/java/java/util/zip/package.html
rt/emul/mini/src/main/java/org/apidesign/bck2brwsr/emul/zip/Adler32.java
rt/emul/mini/src/main/java/org/apidesign/bck2brwsr/emul/zip/CRC32.java
rt/emul/mini/src/main/java/org/apidesign/bck2brwsr/emul/zip/Checksum.java
rt/emul/mini/src/main/java/org/apidesign/bck2brwsr/emul/zip/FastJar.java
rt/emul/mini/src/main/java/org/apidesign/bck2brwsr/emul/zip/GZIPHeader.java
rt/emul/mini/src/main/java/org/apidesign/bck2brwsr/emul/zip/InfBlocks.java
rt/emul/mini/src/main/java/org/apidesign/bck2brwsr/emul/zip/InfCodes.java
rt/emul/mini/src/main/java/org/apidesign/bck2brwsr/emul/zip/InfTree.java
rt/emul/mini/src/main/java/org/apidesign/bck2brwsr/emul/zip/Inflate.java
rt/emul/mini/src/main/java/org/apidesign/bck2brwsr/emul/zip/Inflater.java
rt/emul/mini/src/main/java/org/apidesign/bck2brwsr/emul/zip/JzLibInflater.java
rt/emul/mini/src/main/java/org/apidesign/bck2brwsr/emul/zip/ZStream.java
rt/emul/mini/src/main/java/org/apidesign/bck2brwsr/emul/zip/ZipConstants64.java
rt/emul/mini/src/main/java/org/apidesign/bck2brwsr/emul/zip/ZipInputStream.java
rt/emul/pom.xml
rt/emul/zip/pom.xml
rt/emul/zip/src/main/java/java/util/zip/Adler32.java
rt/emul/zip/src/main/java/java/util/zip/CRC32.java
rt/emul/zip/src/main/java/java/util/zip/Checksum.java
rt/emul/zip/src/main/java/java/util/zip/DataFormatException.java
rt/emul/zip/src/main/java/java/util/zip/Inflater.java
rt/emul/zip/src/main/java/java/util/zip/InflaterInputStream.java
rt/emul/zip/src/main/java/java/util/zip/ZStreamRef.java
rt/emul/zip/src/main/java/java/util/zip/ZipConstants.java
rt/emul/zip/src/main/java/java/util/zip/ZipEntry.java
rt/emul/zip/src/main/java/java/util/zip/ZipException.java
rt/emul/zip/src/main/java/java/util/zip/ZipInputStream.java
rt/emul/zip/src/main/java/java/util/zip/package-info.java
rt/emul/zip/src/main/java/java/util/zip/package.html
rt/emul/zip/src/main/java/org/apidesign/bck2brwsr/emul/zip/Adler32.java
rt/emul/zip/src/main/java/org/apidesign/bck2brwsr/emul/zip/CRC32.java
rt/emul/zip/src/main/java/org/apidesign/bck2brwsr/emul/zip/Checksum.java
rt/emul/zip/src/main/java/org/apidesign/bck2brwsr/emul/zip/FastJar.java
rt/emul/zip/src/main/java/org/apidesign/bck2brwsr/emul/zip/GZIPHeader.java
rt/emul/zip/src/main/java/org/apidesign/bck2brwsr/emul/zip/InfBlocks.java
rt/emul/zip/src/main/java/org/apidesign/bck2brwsr/emul/zip/InfCodes.java
rt/emul/zip/src/main/java/org/apidesign/bck2brwsr/emul/zip/InfTree.java
rt/emul/zip/src/main/java/org/apidesign/bck2brwsr/emul/zip/Inflate.java
rt/emul/zip/src/main/java/org/apidesign/bck2brwsr/emul/zip/Inflater.java
rt/emul/zip/src/main/java/org/apidesign/bck2brwsr/emul/zip/JzLibInflater.java
rt/emul/zip/src/main/java/org/apidesign/bck2brwsr/emul/zip/ZStream.java
rt/emul/zip/src/main/java/org/apidesign/bck2brwsr/emul/zip/ZipConstants64.java
rt/emul/zip/src/main/java/org/apidesign/bck2brwsr/emul/zip/ZipInputStream.java
rt/emul/zip/src/test/java/org/apidesign/bck2brwsr/emul/zip/CRC32Test.java
rt/emul/zip/src/test/java/org/apidesign/bck2brwsr/emul/zip/ZipArchive.java
rt/emul/zip/src/test/java/org/apidesign/bck2brwsr/emul/zip/ZipCompatibilityTest.java
rt/emul/zip/src/test/java/org/apidesign/bck2brwsr/emul/zip/ZipEntryTest.java
rt/emul/zip/src/test/java/org/apidesign/bck2brwsr/emul/zip/ZipFileTest.java
rt/emul/zip/src/test/java/org/apidesign/bck2brwsr/emul/zip/ZipVsJzLibTest.java
     1.1 --- a/pom.xml	Wed May 07 11:55:06 2014 +0200
     1.2 +++ b/pom.xml	Wed May 07 16:47:24 2014 +0200
     1.3 @@ -87,6 +87,7 @@
     1.4                         <exclude>.*/**</exclude>
     1.5                         <exclude>rt/emul/mini/src/main/**</exclude>
     1.6                         <exclude>rt/emul/compact/src/main/**</exclude>
     1.7 +                       <exclude>rt/emul/zip/src/main/**</exclude>
     1.8                         <exclude>rt/vm/src/main/java/org/apidesign/vm4brwsr/ByteCodeParser.java</exclude>
     1.9                         <exclude>rt/archetype/src/main/resources/archetype-resources/**</exclude>
    1.10                         <exclude>rt/emul/*/src/test/resources/**</exclude>
     2.1 --- a/rt/emul/compact/src/test/java/org/apidesign/bck2brwsr/compact/tck/ZipArchive.java	Wed May 07 11:55:06 2014 +0200
     2.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.3 @@ -1,154 +0,0 @@
     2.4 -/**
     2.5 - * Back 2 Browser Bytecode Translator
     2.6 - * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
     2.7 - *
     2.8 - * This program is free software: you can redistribute it and/or modify
     2.9 - * it under the terms of the GNU General Public License as published by
    2.10 - * the Free Software Foundation, version 2 of the License.
    2.11 - *
    2.12 - * This program is distributed in the hope that it will be useful,
    2.13 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
    2.14 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    2.15 - * GNU General Public License for more details.
    2.16 - *
    2.17 - * You should have received a copy of the GNU General Public License
    2.18 - * along with this program. Look for COPYING file in the top folder.
    2.19 - * If not, see http://opensource.org/licenses/GPL-2.0.
    2.20 - */
    2.21 -package org.apidesign.bck2brwsr.compact.tck;
    2.22 -
    2.23 -import java.io.ByteArrayOutputStream;
    2.24 -import java.io.IOException;
    2.25 -import java.io.InputStream;
    2.26 -import java.util.Arrays;
    2.27 -import java.util.LinkedHashMap;
    2.28 -import java.util.Map;
    2.29 -import java.util.Objects;
    2.30 -import java.util.zip.ZipEntry;
    2.31 -import org.apidesign.bck2brwsr.emul.zip.ZipInputStream;
    2.32 -
    2.33 -/**
    2.34 - *
    2.35 - * @author Jaroslav Tulach <jtulach@netbeans.org>
    2.36 - */
    2.37 -final class ZipArchive {
    2.38 -    private final Map<String, byte[]> entries = new LinkedHashMap<>();
    2.39 -
    2.40 -    public static ZipArchive createZip(InputStream is) throws IOException {
    2.41 -        ZipArchive a = new ZipArchive();
    2.42 -        readZip(is, a);
    2.43 -        return a;
    2.44 -    }
    2.45 -
    2.46 -    public static ZipArchive createReal(InputStream is) throws IOException {
    2.47 -        ZipArchive a = new ZipArchive();
    2.48 -        realZip(is, a);
    2.49 -        return a;
    2.50 -    }
    2.51 -
    2.52 -    /**
    2.53 -     * Registers entry name and data
    2.54 -     */
    2.55 -    final void register(String entry, InputStream is) throws IOException {
    2.56 -        ByteArrayOutputStream os = new ByteArrayOutputStream();
    2.57 -        for (;;) {
    2.58 -            int ch = is.read();
    2.59 -            if (ch == -1) {
    2.60 -                break;
    2.61 -            }
    2.62 -            os.write(ch);
    2.63 -        }
    2.64 -        os.close();
    2.65 -        entries.put(entry, os.toByteArray());
    2.66 -    }
    2.67 -
    2.68 -    @Override
    2.69 -    public int hashCode() {
    2.70 -        return entries.hashCode();
    2.71 -    }
    2.72 -
    2.73 -    @Override
    2.74 -    public boolean equals(Object obj) {
    2.75 -        if (obj == null) {
    2.76 -            return false;
    2.77 -        }
    2.78 -        if (getClass() != obj.getClass()) {
    2.79 -            return false;
    2.80 -        }
    2.81 -        final ZipArchive other = (ZipArchive) obj;
    2.82 -        if (!Objects.deepEquals(this.entries, other.entries)) {
    2.83 -            return false;
    2.84 -        }
    2.85 -        return true;
    2.86 -    }
    2.87 -
    2.88 -    @Override
    2.89 -    public String toString() {
    2.90 -        StringBuilder sb = new StringBuilder();
    2.91 -        for (Map.Entry<String, byte[]> en : entries.entrySet()) {
    2.92 -            String string = en.getKey();
    2.93 -            byte[] bs = en.getValue();
    2.94 -            sb.append(string).append(" = ").append(Arrays.toString(bs)).append("\n");
    2.95 -        }
    2.96 -        return sb.toString();
    2.97 -    }
    2.98 -
    2.99 -    public void assertEquals(ZipArchive zip, String msg) {
   2.100 -        boolean ok = true;
   2.101 -        StringBuilder sb = new StringBuilder();
   2.102 -        sb.append(msg);
   2.103 -        for (Map.Entry<String, byte[]> en : entries.entrySet()) {
   2.104 -            String string = en.getKey();
   2.105 -            byte[] bs = en.getValue();
   2.106 -            byte[] other = zip.entries.get(string);
   2.107 -            sb.append("\n");
   2.108 -            if (other == null) {
   2.109 -                sb.append("EXTRA ").append(string).append(" = ").append(Arrays.toString(bs));
   2.110 -                ok = false;
   2.111 -                continue;
   2.112 -            }
   2.113 -            if (Arrays.equals(bs, other)) {
   2.114 -                sb.append("OK    ").append(string);
   2.115 -                continue;
   2.116 -            } else {
   2.117 -                sb.append("DIFF  ").append(string).append(" = ").append(Arrays.toString(bs)).append("\n");
   2.118 -                sb.append("    TO").append(string).append(" = ").append(Arrays.toString(other)).append("\n");
   2.119 -                ok = false;
   2.120 -                continue;
   2.121 -            }
   2.122 -        }
   2.123 -        for (Map.Entry<String, byte[]> entry : zip.entries.entrySet()) {
   2.124 -            String string = entry.getKey();
   2.125 -            if (entries.get(string) == null) {
   2.126 -                sb.append("MISS  ").append(string).append(" = ").append(Arrays.toString(entry.getValue()));
   2.127 -                ok = false;
   2.128 -            }
   2.129 -        }
   2.130 -        if (!ok) {
   2.131 -            assert false : sb.toString();
   2.132 -        }
   2.133 -    }
   2.134 -
   2.135 -    public static void readZip(InputStream is, ZipArchive data) throws IOException {
   2.136 -        ZipInputStream zip = new org.apidesign.bck2brwsr.emul.zip.ZipInputStream(is);
   2.137 -        for (;;) {
   2.138 -            ZipEntry en = zip.getNextEntry();
   2.139 -            if (en == null) {
   2.140 -                return;
   2.141 -            }
   2.142 -            data.register(en.getName(), zip);
   2.143 -        }
   2.144 -    }
   2.145 -
   2.146 -    public static void realZip(InputStream is, ZipArchive data) throws IOException {
   2.147 -        java.util.zip.ZipInputStream zip = new java.util.zip.ZipInputStream(is);
   2.148 -        for (;;) {
   2.149 -            ZipEntry en = zip.getNextEntry();
   2.150 -            if (en == null) {
   2.151 -                return;
   2.152 -            }
   2.153 -            data.register(en.getName(), zip);
   2.154 -        }
   2.155 -    }
   2.156 -    
   2.157 -}
     3.1 --- a/rt/emul/compact/src/test/java/org/apidesign/bck2brwsr/compact/tck/ZipCompatibilityTest.java	Wed May 07 11:55:06 2014 +0200
     3.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.3 @@ -1,43 +0,0 @@
     3.4 -/**
     3.5 - * Back 2 Browser Bytecode Translator
     3.6 - * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
     3.7 - *
     3.8 - * This program is free software: you can redistribute it and/or modify
     3.9 - * it under the terms of the GNU General Public License as published by
    3.10 - * the Free Software Foundation, version 2 of the License.
    3.11 - *
    3.12 - * This program is distributed in the hope that it will be useful,
    3.13 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
    3.14 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    3.15 - * GNU General Public License for more details.
    3.16 - *
    3.17 - * You should have received a copy of the GNU General Public License
    3.18 - * along with this program. Look for COPYING file in the top folder.
    3.19 - * If not, see http://opensource.org/licenses/GPL-2.0.
    3.20 - */
    3.21 -package org.apidesign.bck2brwsr.compact.tck;
    3.22 -
    3.23 -import java.io.IOException;
    3.24 -import java.io.InputStream;
    3.25 -import org.apidesign.bck2brwsr.vmtest.Compare;
    3.26 -import org.apidesign.bck2brwsr.vmtest.VMTest;
    3.27 -import org.testng.annotations.Factory;
    3.28 -
    3.29 -/**
    3.30 - *
    3.31 - * @author Jaroslav Tulach <jtulach@netbeans.org>
    3.32 - */
    3.33 -public class ZipCompatibilityTest {
    3.34 -    @Compare
    3.35 -    public String testDemoStaticCalculator() throws IOException {
    3.36 -        InputStream is = getClass().getResourceAsStream("demo.static.calculator-TEST.jar");
    3.37 -        ZipArchive zip = ZipArchive.createZip(is);
    3.38 -        final String ts = zip.toString();
    3.39 -        return ts.substring(0, 4096) + ts.hashCode();
    3.40 -    }
    3.41 -    
    3.42 -    @Factory
    3.43 -    public static Object[] create() {
    3.44 -        return VMTest.create(ZipCompatibilityTest.class);
    3.45 -    }
    3.46 -}
     4.1 --- a/rt/emul/compact/src/test/java/org/apidesign/bck2brwsr/compact/tck/ZipVsJzLibTest.java	Wed May 07 11:55:06 2014 +0200
     4.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.3 @@ -1,39 +0,0 @@
     4.4 -/**
     4.5 - * Back 2 Browser Bytecode Translator
     4.6 - * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
     4.7 - *
     4.8 - * This program is free software: you can redistribute it and/or modify
     4.9 - * it under the terms of the GNU General Public License as published by
    4.10 - * the Free Software Foundation, version 2 of the License.
    4.11 - *
    4.12 - * This program is distributed in the hope that it will be useful,
    4.13 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
    4.14 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    4.15 - * GNU General Public License for more details.
    4.16 - *
    4.17 - * You should have received a copy of the GNU General Public License
    4.18 - * along with this program. Look for COPYING file in the top folder.
    4.19 - * If not, see http://opensource.org/licenses/GPL-2.0.
    4.20 - */
    4.21 -package org.apidesign.bck2brwsr.compact.tck;
    4.22 -
    4.23 -import java.io.IOException;
    4.24 -import java.io.InputStream;
    4.25 -import org.testng.annotations.Test;
    4.26 -
    4.27 -/**
    4.28 - *
    4.29 - * @author Jaroslav Tulach <jtulach@netbeans.org>
    4.30 - */
    4.31 -public class ZipVsJzLibTest {
    4.32 -    @Test public void r() throws IOException {
    4.33 -        InputStream is = getClass().getResourceAsStream("demo.static.calculator-TEST.jar");
    4.34 -        ZipArchive zip = ZipArchive.createZip(is);
    4.35 -        
    4.36 -        is = getClass().getResourceAsStream("demo.static.calculator-TEST.jar");
    4.37 -        ZipArchive real = ZipArchive.createReal(is);
    4.38 -        
    4.39 -        real.assertEquals(zip, "Are they the same?");
    4.40 -    }
    4.41 -    
    4.42 -}
     5.1 --- a/rt/emul/compact/src/test/java/org/apidesign/bck2brwsr/vmtest/impl/CRC32Test.java	Wed May 07 11:55:06 2014 +0200
     5.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.3 @@ -1,41 +0,0 @@
     5.4 -/**
     5.5 - * Back 2 Browser Bytecode Translator
     5.6 - * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
     5.7 - *
     5.8 - * This program is free software: you can redistribute it and/or modify
     5.9 - * it under the terms of the GNU General Public License as published by
    5.10 - * the Free Software Foundation, version 2 of the License.
    5.11 - *
    5.12 - * This program is distributed in the hope that it will be useful,
    5.13 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
    5.14 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    5.15 - * GNU General Public License for more details.
    5.16 - *
    5.17 - * You should have received a copy of the GNU General Public License
    5.18 - * along with this program. Look for COPYING file in the top folder.
    5.19 - * If not, see http://opensource.org/licenses/GPL-2.0.
    5.20 - */
    5.21 -package org.apidesign.bck2brwsr.vmtest.impl;
    5.22 -
    5.23 -import java.io.UnsupportedEncodingException;
    5.24 -import java.util.zip.CRC32;
    5.25 -import org.apidesign.bck2brwsr.vmtest.Compare;
    5.26 -import org.apidesign.bck2brwsr.vmtest.VMTest;
    5.27 -import org.testng.annotations.Factory;
    5.28 -
    5.29 -/**
    5.30 - *
    5.31 - * @author Jaroslav Tulach <jtulach@netbeans.org>
    5.32 - */
    5.33 -public class CRC32Test {
    5.34 -
    5.35 -    @Compare public long crc1() throws UnsupportedEncodingException {
    5.36 -        CRC32 crc = new CRC32();
    5.37 -        crc.update("Hello World!".getBytes("UTF-8"));
    5.38 -        return crc.getValue();
    5.39 -    }
    5.40 -    
    5.41 -    @Factory public static Object[] create() {
    5.42 -        return VMTest.create(CRC32Test.class);
    5.43 -    }
    5.44 -}
     6.1 --- a/rt/emul/compact/src/test/java/org/apidesign/bck2brwsr/vmtest/impl/ZipEntryTest.java	Wed May 07 11:55:06 2014 +0200
     6.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.3 @@ -1,67 +0,0 @@
     6.4 -/**
     6.5 - * Back 2 Browser Bytecode Translator
     6.6 - * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
     6.7 - *
     6.8 - * This program is free software: you can redistribute it and/or modify
     6.9 - * it under the terms of the GNU General Public License as published by
    6.10 - * the Free Software Foundation, version 2 of the License.
    6.11 - *
    6.12 - * This program is distributed in the hope that it will be useful,
    6.13 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
    6.14 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    6.15 - * GNU General Public License for more details.
    6.16 - *
    6.17 - * You should have received a copy of the GNU General Public License
    6.18 - * along with this program. Look for COPYING file in the top folder.
    6.19 - * If not, see http://opensource.org/licenses/GPL-2.0.
    6.20 - */
    6.21 -package org.apidesign.bck2brwsr.vmtest.impl;
    6.22 -
    6.23 -import java.io.ByteArrayInputStream;
    6.24 -import java.io.IOException;
    6.25 -import java.io.InputStream;
    6.26 -import org.apidesign.bck2brwsr.emul.zip.FastJar;
    6.27 -import org.testng.annotations.Test;
    6.28 -import static org.testng.Assert.*;
    6.29 -
    6.30 -/**
    6.31 - *
    6.32 - * @author Jaroslav Tulach <jtulach@netbeans.org>
    6.33 - */
    6.34 -@GenerateZip(name = "five.zip", contents = {
    6.35 -    "1.txt", "one",
    6.36 -    "2.txt", "duo",
    6.37 -    "3.txt", "three",
    6.38 -    "4.txt", "four",
    6.39 -    "5.txt", "five"
    6.40 -})
    6.41 -public class ZipEntryTest {
    6.42 -    @Test
    6.43 -    public void readEntriesEffectively() throws IOException {
    6.44 -        InputStream is = ZipEntryTest.class.getResourceAsStream("five.zip");
    6.45 -        byte[] arr = new byte[is.available()];
    6.46 -        int len = is.read(arr);
    6.47 -        assertEquals(len, arr.length, "Read fully");
    6.48 -        
    6.49 -        FastJar fj = new FastJar(arr);
    6.50 -        FastJar.Entry[] entrs = fj.list();
    6.51 -        
    6.52 -        assertEquals(5, entrs.length, "Five entries");
    6.53 -        
    6.54 -        for (int i = 1; i <= 5; i++) {
    6.55 -            FastJar.Entry en = entrs[i - 1];
    6.56 -            assertEquals(en.name, i + ".txt");
    6.57 -//            assertEquals(cis.cnt, 0, "Content of the file should be skipped, not read");
    6.58 -        }
    6.59 -        
    6.60 -        assertContent("three", fj.getInputStream(entrs[3 - 1]), "read OK");
    6.61 -        assertContent("five", fj.getInputStream(entrs[5 - 1]), "read OK");
    6.62 -    }
    6.63 -
    6.64 -    private static void assertContent(String exp, InputStream is, String msg) throws IOException {
    6.65 -        byte[] arr = new byte[512];
    6.66 -        int len = is.read(arr);
    6.67 -        String s = new String(arr, 0, len);
    6.68 -        assertEquals(exp, s, msg);
    6.69 -    }
    6.70 -}
     7.1 --- a/rt/emul/compact/src/test/java/org/apidesign/bck2brwsr/vmtest/impl/ZipFileTest.java	Wed May 07 11:55:06 2014 +0200
     7.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.3 @@ -1,108 +0,0 @@
     7.4 -/**
     7.5 - * Back 2 Browser Bytecode Translator
     7.6 - * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
     7.7 - *
     7.8 - * This program is free software: you can redistribute it and/or modify
     7.9 - * it under the terms of the GNU General Public License as published by
    7.10 - * the Free Software Foundation, version 2 of the License.
    7.11 - *
    7.12 - * This program is distributed in the hope that it will be useful,
    7.13 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
    7.14 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    7.15 - * GNU General Public License for more details.
    7.16 - *
    7.17 - * You should have received a copy of the GNU General Public License
    7.18 - * along with this program. Look for COPYING file in the top folder.
    7.19 - * If not, see http://opensource.org/licenses/GPL-2.0.
    7.20 - */
    7.21 -package org.apidesign.bck2brwsr.vmtest.impl;
    7.22 -
    7.23 -import java.io.IOException;
    7.24 -import java.io.InputStream;
    7.25 -import java.util.Objects;
    7.26 -import java.util.zip.ZipEntry;
    7.27 -import java.util.zip.ZipInputStream;
    7.28 -import org.apidesign.bck2brwsr.core.JavaScriptBody;
    7.29 -import org.apidesign.bck2brwsr.vmtest.BrwsrTest;
    7.30 -import org.apidesign.bck2brwsr.vmtest.Compare;
    7.31 -import org.apidesign.bck2brwsr.vmtest.Http;
    7.32 -import org.apidesign.bck2brwsr.vmtest.VMTest;
    7.33 -import org.testng.annotations.Factory;
    7.34 -
    7.35 -/**
    7.36 - *
    7.37 - * @author Jaroslav Tulach <jtulach@netbeans.org>
    7.38 - */
    7.39 -@GenerateZip(name = "readAnEntry.zip", contents = { 
    7.40 -    "my/main/file.txt", "Hello World!"
    7.41 -})
    7.42 -public class ZipFileTest {
    7.43 -    
    7.44 -    @Compare public String readAnEntry() throws IOException {
    7.45 -        InputStream is = ZipFileTest.class.getResourceAsStream("readAnEntry.zip");
    7.46 -        ZipInputStream zip = new ZipInputStream(is);
    7.47 -        ZipEntry entry = zip.getNextEntry();
    7.48 -        assertEquals(entry.getName(), "my/main/file.txt", "Correct entry");
    7.49 -
    7.50 -        byte[] arr = new byte[4096];
    7.51 -        int len = zip.read(arr);
    7.52 -        
    7.53 -        assertEquals(zip.getNextEntry(), null, "No next entry");
    7.54 -        
    7.55 -        final String ret = new String(arr, 0, len, "UTF-8");
    7.56 -        return ret;
    7.57 -    }
    7.58 -    
    7.59 -    @JavaScriptBody(args = { "res", "path" }, body = 
    7.60 -          "var myvm = bck2brwsr.apply(null, path);\n"
    7.61 -        + "var cls = myvm.loadClass('java.lang.String');\n"
    7.62 -        + "return cls.getClass__Ljava_lang_Class_2().getResourceAsStream__Ljava_io_InputStream_2Ljava_lang_String_2(res);\n"
    7.63 -    )
    7.64 -    private static native Object loadVMResource(String res, String...path);
    7.65 -
    7.66 -    @Http({
    7.67 -        @Http.Resource(path = "/readAnEntry.jar", mimeType = "x-application/zip", content = "", resource="readAnEntry.zip")
    7.68 -    })
    7.69 -    @BrwsrTest  public void canVmLoadResourceFromZip() throws IOException {
    7.70 -        Object res = loadVMResource("/my/main/file.txt", "/readAnEntry.jar");
    7.71 -        assert res instanceof InputStream : "Got array of bytes: " + res;
    7.72 -        InputStream is = (InputStream)res;
    7.73 -        
    7.74 -        byte[] arr = new byte[4096];
    7.75 -        int len = is.read(arr);
    7.76 -        
    7.77 -        final String ret = new String(arr, 0, len, "UTF-8");
    7.78 -
    7.79 -        assertEquals(ret, "Hello World!", "Can read the bytes");
    7.80 -    }
    7.81 -    
    7.82 -    @GenerateZip(name = "cpattr.zip", contents = { 
    7.83 -        "META-INF/MANIFEST.MF", "Manifest-Version: 1.0\n"
    7.84 -        + "Created-By: hand\n"
    7.85 -        + "Class-Path: realJar.jar\n\n\n"
    7.86 -    })
    7.87 -    @Http({
    7.88 -        @Http.Resource(path = "/readComplexEntry.jar", mimeType = "x-application/zip", content = "", resource="cpattr.zip"),
    7.89 -        @Http.Resource(path = "/realJar.jar", mimeType = "x-application/zip", content = "", resource="readAnEntry.zip"),
    7.90 -    })
    7.91 -    @BrwsrTest  public void understandsClassPathAttr() throws IOException {
    7.92 -        Object res = loadVMResource("/my/main/file.txt", "/readComplexEntry.jar");
    7.93 -        assert res instanceof InputStream : "Got array of bytes: " + res;
    7.94 -        InputStream is = (InputStream)res;
    7.95 -        
    7.96 -        byte[] arr = new byte[4096];
    7.97 -        int len = is.read(arr);
    7.98 -        
    7.99 -        final String ret = new String(arr, 0, len, "UTF-8");
   7.100 -
   7.101 -        assertEquals(ret, "Hello World!", "Can read the bytes from secondary JAR");
   7.102 -    }
   7.103 -    
   7.104 -    private static void assertEquals(Object real, Object exp, String msg) {
   7.105 -        assert Objects.equals(exp, real) : msg + " exp: " + exp + " real: " + real;
   7.106 -    }
   7.107 -    
   7.108 -    @Factory public static Object[] create() {
   7.109 -        return VMTest.create(ZipFileTest.class);
   7.110 -    }
   7.111 -}
     8.1 --- a/rt/emul/mini/src/main/java/java/util/zip/Adler32.java	Wed May 07 11:55:06 2014 +0200
     8.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     8.3 @@ -1,205 +0,0 @@
     8.4 -/* Adler32.java - Computes Adler32 data checksum of a data stream
     8.5 -   Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc.
     8.6 -
     8.7 -This file is part of GNU Classpath.
     8.8 -
     8.9 -GNU Classpath is free software; you can redistribute it and/or modify
    8.10 -it under the terms of the GNU General Public License as published by
    8.11 -the Free Software Foundation; either version 2, or (at your option)
    8.12 -any later version.
    8.13 -
    8.14 -GNU Classpath is distributed in the hope that it will be useful, but
    8.15 -WITHOUT ANY WARRANTY; without even the implied warranty of
    8.16 -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    8.17 -General Public License for more details.
    8.18 -
    8.19 -You should have received a copy of the GNU General Public License
    8.20 -along with GNU Classpath; see the file COPYING.  If not, write to the
    8.21 -Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
    8.22 -02111-1307 USA.
    8.23 -
    8.24 -Linking this library statically or dynamically with other modules is
    8.25 -making a combined work based on this library.  Thus, the terms and
    8.26 -conditions of the GNU General Public License cover the whole
    8.27 -combination.
    8.28 -
    8.29 -As a special exception, the copyright holders of this library give you
    8.30 -permission to link this library with independent modules to produce an
    8.31 -executable, regardless of the license terms of these independent
    8.32 -modules, and to copy and distribute the resulting executable under
    8.33 -terms of your choice, provided that you also meet, for each linked
    8.34 -independent module, the terms and conditions of the license of that
    8.35 -module.  An independent module is a module which is not derived from
    8.36 -or based on this library.  If you modify this library, you may extend
    8.37 -this exception to your version of the library, but you are not
    8.38 -obligated to do so.  If you do not wish to do so, delete this
    8.39 -exception statement from your version. */
    8.40 -
    8.41 -package java.util.zip;
    8.42 -
    8.43 -/*
    8.44 - * Written using on-line Java Platform 1.2 API Specification, as well
    8.45 - * as "The Java Class Libraries", 2nd edition (Addison-Wesley, 1998).
    8.46 - * The actual Adler32 algorithm is taken from RFC 1950.
    8.47 - * Status:  Believed complete and correct.
    8.48 - */
    8.49 -
    8.50 -/**
    8.51 - * Computes Adler32 checksum for a stream of data. An Adler32 
    8.52 - * checksum is not as reliable as a CRC32 checksum, but a lot faster to 
    8.53 - * compute.
    8.54 - *<p>
    8.55 - * The specification for Adler32 may be found in RFC 1950.
    8.56 - * (ZLIB Compressed Data Format Specification version 3.3)
    8.57 - *<p>
    8.58 - *<p>
    8.59 - * From that document:
    8.60 - *<p>
    8.61 - *      "ADLER32 (Adler-32 checksum)
    8.62 - *       This contains a checksum value of the uncompressed data
    8.63 - *       (excluding any dictionary data) computed according to Adler-32
    8.64 - *       algorithm. This algorithm is a 32-bit extension and improvement
    8.65 - *       of the Fletcher algorithm, used in the ITU-T X.224 / ISO 8073
    8.66 - *       standard. 
    8.67 - *<p>
    8.68 - *       Adler-32 is composed of two sums accumulated per byte: s1 is
    8.69 - *       the sum of all bytes, s2 is the sum of all s1 values. Both sums
    8.70 - *       are done modulo 65521. s1 is initialized to 1, s2 to zero.  The
    8.71 - *       Adler-32 checksum is stored as s2*65536 + s1 in most-
    8.72 - *       significant-byte first (network) order."
    8.73 - *<p>
    8.74 - * "8.2. The Adler-32 algorithm
    8.75 - *<p>
    8.76 - *    The Adler-32 algorithm is much faster than the CRC32 algorithm yet
    8.77 - *    still provides an extremely low probability of undetected errors.
    8.78 - *<p>
    8.79 - *    The modulo on unsigned long accumulators can be delayed for 5552
    8.80 - *    bytes, so the modulo operation time is negligible.  If the bytes
    8.81 - *    are a, b, c, the second sum is 3a + 2b + c + 3, and so is position
    8.82 - *    and order sensitive, unlike the first sum, which is just a
    8.83 - *    checksum.  That 65521 is prime is important to avoid a possible
    8.84 - *    large class of two-byte errors that leave the check unchanged.
    8.85 - *    (The Fletcher checksum uses 255, which is not prime and which also
    8.86 - *    makes the Fletcher check insensitive to single byte changes 0 <->
    8.87 - *    255.)
    8.88 - *<p>
    8.89 - *    The sum s1 is initialized to 1 instead of zero to make the length
    8.90 - *    of the sequence part of s2, so that the length does not have to be
    8.91 - *   checked separately. (Any sequence of zeroes has a Fletcher
    8.92 - *    checksum of zero.)"
    8.93 - *
    8.94 - * @author John Leuner, Per Bothner
    8.95 - * @since JDK 1.1
    8.96 - *
    8.97 - * @see InflaterInputStream
    8.98 - * @see DeflaterOutputStream
    8.99 - */
   8.100 -public class Adler32 implements Checksum
   8.101 -{
   8.102 -
   8.103 -  /** largest prime smaller than 65536 */
   8.104 -  private static final int BASE = 65521;
   8.105 -
   8.106 -  private int checksum; //we do all in int.
   8.107 -
   8.108 -  //Note that java doesn't have unsigned integers,
   8.109 -  //so we have to be careful with what arithmetic 
   8.110 -  //we do. We return the checksum as a long to 
   8.111 -  //avoid sign confusion.
   8.112 -
   8.113 -  /**
   8.114 -   * Creates a new instance of the <code>Adler32</code> class. 
   8.115 -   * The checksum starts off with a value of 1. 
   8.116 -   */
   8.117 -  public Adler32 ()
   8.118 -  {
   8.119 -    reset();
   8.120 -  }
   8.121 -
   8.122 -  /**
   8.123 -   * Resets the Adler32 checksum to the initial value.
   8.124 -   */
   8.125 -  public void reset () 
   8.126 -  {
   8.127 -    checksum = 1; //Initialize to 1    
   8.128 -  }
   8.129 -
   8.130 -  /**
   8.131 -   * Updates the checksum with the byte b. 
   8.132 -   *
   8.133 -   * @param bval the data value to add. The high byte of the int is ignored.
   8.134 -   */
   8.135 -  public void update (int bval)
   8.136 -  {
   8.137 -    //We could make a length 1 byte array and call update again, but I
   8.138 -    //would rather not have that overhead
   8.139 -    int s1 = checksum & 0xffff;
   8.140 -    int s2 = checksum >>> 16;
   8.141 -    
   8.142 -    s1 = (s1 + (bval & 0xFF)) % BASE;
   8.143 -    s2 = (s1 + s2) % BASE;
   8.144 -    
   8.145 -    checksum = (s2 << 16) + s1;
   8.146 -  }
   8.147 -
   8.148 -  /**
   8.149 -   * Updates the checksum with the bytes taken from the array. 
   8.150 -   * 
   8.151 -   * @param buffer an array of bytes
   8.152 -   */
   8.153 -  public void update (byte[] buffer)
   8.154 -  {
   8.155 -    update(buffer, 0, buffer.length);
   8.156 -  }
   8.157 -
   8.158 -  /**
   8.159 -   * Updates the checksum with the bytes taken from the array. 
   8.160 -   * 
   8.161 -   * @param buf an array of bytes
   8.162 -   * @param off the start of the data used for this update
   8.163 -   * @param len the number of bytes to use for this update
   8.164 -   */
   8.165 -  public void update (byte[] buf, int off, int len)
   8.166 -  {
   8.167 -    //(By Per Bothner)
   8.168 -    int s1 = checksum & 0xffff;
   8.169 -    int s2 = checksum >>> 16;
   8.170 -
   8.171 -    while (len > 0)
   8.172 -      {
   8.173 -	// We can defer the modulo operation:
   8.174 -	// s1 maximally grows from 65521 to 65521 + 255 * 3800
   8.175 -	// s2 maximally grows by 3800 * median(s1) = 2090079800 < 2^31
   8.176 -	int n = 3800;
   8.177 -	if (n > len)
   8.178 -	  n = len;
   8.179 -	len -= n;
   8.180 -	while (--n >= 0)
   8.181 -	  {
   8.182 -	    s1 = s1 + (buf[off++] & 0xFF);
   8.183 -	    s2 = s2 + s1;
   8.184 -	  }
   8.185 -	s1 %= BASE;
   8.186 -	s2 %= BASE;
   8.187 -      }
   8.188 -
   8.189 -    /*Old implementation, borrowed from somewhere:
   8.190 -    int n;
   8.191 -    
   8.192 -    while (len-- > 0) {
   8.193 -
   8.194 -      s1 = (s1 + (bs[offset++] & 0xff)) % BASE; 
   8.195 -      s2 = (s2 + s1) % BASE;
   8.196 -    }*/
   8.197 -    
   8.198 -    checksum = (s2 << 16) | s1;
   8.199 -  }
   8.200 -
   8.201 -  /**
   8.202 -   * Returns the Adler32 data checksum computed so far.
   8.203 -   */
   8.204 -  public long getValue()
   8.205 -  {
   8.206 -    return (long) checksum & 0xffffffffL;
   8.207 -  }
   8.208 -}
     9.1 --- a/rt/emul/mini/src/main/java/java/util/zip/CRC32.java	Wed May 07 11:55:06 2014 +0200
     9.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     9.3 @@ -1,132 +0,0 @@
     9.4 -/* CRC32.java - Computes CRC32 data checksum of a data stream
     9.5 -   Copyright (C) 1999. 2000, 2001 Free Software Foundation, Inc.
     9.6 -
     9.7 -This file is part of GNU Classpath.
     9.8 -
     9.9 -GNU Classpath is free software; you can redistribute it and/or modify
    9.10 -it under the terms of the GNU General Public License as published by
    9.11 -the Free Software Foundation; either version 2, or (at your option)
    9.12 -any later version.
    9.13 -
    9.14 -GNU Classpath is distributed in the hope that it will be useful, but
    9.15 -WITHOUT ANY WARRANTY; without even the implied warranty of
    9.16 -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    9.17 -General Public License for more details.
    9.18 -
    9.19 -You should have received a copy of the GNU General Public License
    9.20 -along with GNU Classpath; see the file COPYING.  If not, write to the
    9.21 -Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
    9.22 -02111-1307 USA.
    9.23 -
    9.24 -Linking this library statically or dynamically with other modules is
    9.25 -making a combined work based on this library.  Thus, the terms and
    9.26 -conditions of the GNU General Public License cover the whole
    9.27 -combination.
    9.28 -
    9.29 -As a special exception, the copyright holders of this library give you
    9.30 -permission to link this library with independent modules to produce an
    9.31 -executable, regardless of the license terms of these independent
    9.32 -modules, and to copy and distribute the resulting executable under
    9.33 -terms of your choice, provided that you also meet, for each linked
    9.34 -independent module, the terms and conditions of the license of that
    9.35 -module.  An independent module is a module which is not derived from
    9.36 -or based on this library.  If you modify this library, you may extend
    9.37 -this exception to your version of the library, but you are not
    9.38 -obligated to do so.  If you do not wish to do so, delete this
    9.39 -exception statement from your version. */
    9.40 -
    9.41 -package java.util.zip;
    9.42 -
    9.43 -/*
    9.44 - * Written using on-line Java Platform 1.2 API Specification, as well
    9.45 - * as "The Java Class Libraries", 2nd edition (Addison-Wesley, 1998).
    9.46 - * The actual CRC32 algorithm is taken from RFC 1952.
    9.47 - * Status:  Believed complete and correct.
    9.48 - */
    9.49 -
    9.50 -/**
    9.51 - * Computes CRC32 data checksum of a data stream.
    9.52 - * The actual CRC32 algorithm is described in RFC 1952
    9.53 - * (GZIP file format specification version 4.3).
    9.54 - * Can be used to get the CRC32 over a stream if used with checked input/output
    9.55 - * streams.
    9.56 - *
    9.57 - * @see InflaterInputStream
    9.58 - * @see DeflaterOutputStream
    9.59 - *
    9.60 - * @author Per Bothner
    9.61 - * @date April 1, 1999.
    9.62 - */
    9.63 -public class CRC32 implements Checksum
    9.64 -{
    9.65 -  /** The crc data checksum so far. */
    9.66 -  private int crc = 0;
    9.67 -
    9.68 -  /** The fast CRC table. Computed once when the CRC32 class is loaded. */
    9.69 -  private static int[] crc_table = make_crc_table();
    9.70 -
    9.71 -  /** Make the table for a fast CRC. */
    9.72 -  private static int[] make_crc_table ()
    9.73 -  {
    9.74 -    int[] crc_table = new int[256];
    9.75 -    for (int n = 0; n < 256; n++)
    9.76 -      {
    9.77 -	int c = n;
    9.78 -	for (int k = 8;  --k >= 0; )
    9.79 -	  {
    9.80 -	    if ((c & 1) != 0)
    9.81 -	      c = 0xedb88320 ^ (c >>> 1);
    9.82 -	    else
    9.83 -	      c = c >>> 1;
    9.84 -	  }
    9.85 -	crc_table[n] = c;
    9.86 -      }
    9.87 -    return crc_table;
    9.88 -  }
    9.89 -
    9.90 -  /**
    9.91 -   * Returns the CRC32 data checksum computed so far.
    9.92 -   */
    9.93 -  public long getValue ()
    9.94 -  {
    9.95 -    return (long) crc & 0xffffffffL;
    9.96 -  }
    9.97 -
    9.98 -  /**
    9.99 -   * Resets the CRC32 data checksum as if no update was ever called.
   9.100 -   */
   9.101 -  public void reset () { crc = 0; }
   9.102 -
   9.103 -  /**
   9.104 -   * Updates the checksum with the int bval. 
   9.105 -   *
   9.106 -   * @param bval (the byte is taken as the lower 8 bits of bval)
   9.107 -   */
   9.108 -
   9.109 -  public void update (int bval)
   9.110 -  {
   9.111 -    int c = ~crc;
   9.112 -    c = crc_table[(c ^ bval) & 0xff] ^ (c >>> 8);
   9.113 -    crc = ~c;
   9.114 -  }
   9.115 -
   9.116 -  /**
   9.117 -   * Adds the byte array to the data checksum.
   9.118 -   *
   9.119 -   * @param buf the buffer which contains the data
   9.120 -   * @param off the offset in the buffer where the data starts
   9.121 -   * @param len the length of the data
   9.122 -   */
   9.123 -  public void update (byte[] buf, int off, int len)
   9.124 -  {
   9.125 -    int c = ~crc;
   9.126 -    while (--len >= 0)
   9.127 -      c = crc_table[(c ^ buf[off++]) & 0xff] ^ (c >>> 8);
   9.128 -    crc = ~c;
   9.129 -  }
   9.130 -
   9.131 -  /**
   9.132 -   * Adds the complete byte array to the data checksum.
   9.133 -   */
   9.134 -  public void update (byte[] buf) { update(buf, 0, buf.length); }
   9.135 -}
    10.1 --- a/rt/emul/mini/src/main/java/java/util/zip/Checksum.java	Wed May 07 11:55:06 2014 +0200
    10.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    10.3 @@ -1,60 +0,0 @@
    10.4 -/*
    10.5 - * Copyright (c) 1996, 1999, Oracle and/or its affiliates. All rights reserved.
    10.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    10.7 - *
    10.8 - * This code is free software; you can redistribute it and/or modify it
    10.9 - * under the terms of the GNU General Public License version 2 only, as
   10.10 - * published by the Free Software Foundation.  Oracle designates this
   10.11 - * particular file as subject to the "Classpath" exception as provided
   10.12 - * by Oracle in the LICENSE file that accompanied this code.
   10.13 - *
   10.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
   10.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   10.16 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   10.17 - * version 2 for more details (a copy is included in the LICENSE file that
   10.18 - * accompanied this code).
   10.19 - *
   10.20 - * You should have received a copy of the GNU General Public License version
   10.21 - * 2 along with this work; if not, write to the Free Software Foundation,
   10.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   10.23 - *
   10.24 - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   10.25 - * or visit www.oracle.com if you need additional information or have any
   10.26 - * questions.
   10.27 - */
   10.28 -
   10.29 -package java.util.zip;
   10.30 -
   10.31 -/**
   10.32 - * An interface representing a data checksum.
   10.33 - *
   10.34 - * @author      David Connelly
   10.35 - */
   10.36 -public
   10.37 -interface Checksum {
   10.38 -    /**
   10.39 -     * Updates the current checksum with the specified byte.
   10.40 -     *
   10.41 -     * @param b the byte to update the checksum with
   10.42 -     */
   10.43 -    public void update(int b);
   10.44 -
   10.45 -    /**
   10.46 -     * Updates the current checksum with the specified array of bytes.
   10.47 -     * @param b the byte array to update the checksum with
   10.48 -     * @param off the start offset of the data
   10.49 -     * @param len the number of bytes to use for the update
   10.50 -     */
   10.51 -    public void update(byte[] b, int off, int len);
   10.52 -
   10.53 -    /**
   10.54 -     * Returns the current checksum value.
   10.55 -     * @return the current checksum value
   10.56 -     */
   10.57 -    public long getValue();
   10.58 -
   10.59 -    /**
   10.60 -     * Resets the checksum to its initial value.
   10.61 -     */
   10.62 -    public void reset();
   10.63 -}
    11.1 --- a/rt/emul/mini/src/main/java/java/util/zip/DataFormatException.java	Wed May 07 11:55:06 2014 +0200
    11.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    11.3 @@ -1,52 +0,0 @@
    11.4 -/*
    11.5 - * Copyright (c) 1996, 2008, Oracle and/or its affiliates. All rights reserved.
    11.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    11.7 - *
    11.8 - * This code is free software; you can redistribute it and/or modify it
    11.9 - * under the terms of the GNU General Public License version 2 only, as
   11.10 - * published by the Free Software Foundation.  Oracle designates this
   11.11 - * particular file as subject to the "Classpath" exception as provided
   11.12 - * by Oracle in the LICENSE file that accompanied this code.
   11.13 - *
   11.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
   11.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   11.16 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   11.17 - * version 2 for more details (a copy is included in the LICENSE file that
   11.18 - * accompanied this code).
   11.19 - *
   11.20 - * You should have received a copy of the GNU General Public License version
   11.21 - * 2 along with this work; if not, write to the Free Software Foundation,
   11.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   11.23 - *
   11.24 - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   11.25 - * or visit www.oracle.com if you need additional information or have any
   11.26 - * questions.
   11.27 - */
   11.28 -
   11.29 -package java.util.zip;
   11.30 -
   11.31 -/**
   11.32 - * Signals that a data format error has occurred.
   11.33 - *
   11.34 - * @author      David Connelly
   11.35 - */
   11.36 -public
   11.37 -class DataFormatException extends Exception {
   11.38 -    private static final long serialVersionUID = 2219632870893641452L;
   11.39 -
   11.40 -    /**
   11.41 -     * Constructs a DataFormatException with no detail message.
   11.42 -     */
   11.43 -    public DataFormatException() {
   11.44 -        super();
   11.45 -    }
   11.46 -
   11.47 -    /**
   11.48 -     * Constructs a DataFormatException with the specified detail message.
   11.49 -     * A detail message is a String that describes this particular exception.
   11.50 -     * @param s the String containing a detail message
   11.51 -     */
   11.52 -    public DataFormatException(String s) {
   11.53 -        super(s);
   11.54 -    }
   11.55 -}
    12.1 --- a/rt/emul/mini/src/main/java/java/util/zip/Inflater.java	Wed May 07 11:55:06 2014 +0200
    12.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    12.3 @@ -1,310 +0,0 @@
    12.4 -/*
    12.5 - * Copyright (c) 1996, 2011, Oracle and/or its affiliates. All rights reserved.
    12.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    12.7 - *
    12.8 - * This code is free software; you can redistribute it and/or modify it
    12.9 - * under the terms of the GNU General Public License version 2 only, as
   12.10 - * published by the Free Software Foundation.  Oracle designates this
   12.11 - * particular file as subject to the "Classpath" exception as provided
   12.12 - * by Oracle in the LICENSE file that accompanied this code.
   12.13 - *
   12.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
   12.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   12.16 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   12.17 - * version 2 for more details (a copy is included in the LICENSE file that
   12.18 - * accompanied this code).
   12.19 - *
   12.20 - * You should have received a copy of the GNU General Public License version
   12.21 - * 2 along with this work; if not, write to the Free Software Foundation,
   12.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   12.23 - *
   12.24 - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   12.25 - * or visit www.oracle.com if you need additional information or have any
   12.26 - * questions.
   12.27 - */
   12.28 -
   12.29 -package java.util.zip;
   12.30 -
   12.31 -/**
   12.32 - * This class provides support for general purpose decompression using the
   12.33 - * popular ZLIB compression library. The ZLIB compression library was
   12.34 - * initially developed as part of the PNG graphics standard and is not
   12.35 - * protected by patents. It is fully described in the specifications at
   12.36 - * the <a href="package-summary.html#package_description">java.util.zip
   12.37 - * package description</a>.
   12.38 - *
   12.39 - * <p>The following code fragment demonstrates a trivial compression
   12.40 - * and decompression of a string using <tt>Deflater</tt> and
   12.41 - * <tt>Inflater</tt>.
   12.42 - *
   12.43 - * <blockquote><pre>
   12.44 - * try {
   12.45 - *     // Encode a String into bytes
   12.46 - *     String inputString = "blahblahblah\u20AC\u20AC";
   12.47 - *     byte[] input = inputString.getBytes("UTF-8");
   12.48 - *
   12.49 - *     // Compress the bytes
   12.50 - *     byte[] output = new byte[100];
   12.51 - *     Deflater compresser = new Deflater();
   12.52 - *     compresser.setInput(input);
   12.53 - *     compresser.finish();
   12.54 - *     int compressedDataLength = compresser.deflate(output);
   12.55 - *
   12.56 - *     // Decompress the bytes
   12.57 - *     Inflater decompresser = new Inflater();
   12.58 - *     decompresser.setInput(output, 0, compressedDataLength);
   12.59 - *     byte[] result = new byte[100];
   12.60 - *     int resultLength = decompresser.inflate(result);
   12.61 - *     decompresser.end();
   12.62 - *
   12.63 - *     // Decode the bytes into a String
   12.64 - *     String outputString = new String(result, 0, resultLength, "UTF-8");
   12.65 - * } catch(java.io.UnsupportedEncodingException ex) {
   12.66 - *     // handle
   12.67 - * } catch (java.util.zip.DataFormatException ex) {
   12.68 - *     // handle
   12.69 - * }
   12.70 - * </pre></blockquote>
   12.71 - *
   12.72 - * @see         Deflater
   12.73 - * @author      David Connelly
   12.74 - *
   12.75 - */
   12.76 -public
   12.77 -class Inflater {
   12.78 -    private final org.apidesign.bck2brwsr.emul.zip.Inflater impl;
   12.79 -    
   12.80 -    /**
   12.81 -     * Creates a new decompressor. If the parameter 'nowrap' is true then
   12.82 -     * the ZLIB header and checksum fields will not be used. This provides
   12.83 -     * compatibility with the compression format used by both GZIP and PKZIP.
   12.84 -     * <p>
   12.85 -     * Note: When using the 'nowrap' option it is also necessary to provide
   12.86 -     * an extra "dummy" byte as input. This is required by the ZLIB native
   12.87 -     * library in order to support certain optimizations.
   12.88 -     *
   12.89 -     * @param nowrap if true then support GZIP compatible compression
   12.90 -     */
   12.91 -    public Inflater(boolean nowrap) {
   12.92 -        if (getClass() == org.apidesign.bck2brwsr.emul.zip.Inflater.class) {
   12.93 -            impl = null;
   12.94 -        } else {
   12.95 -            impl = new org.apidesign.bck2brwsr.emul.zip.Inflater(nowrap);
   12.96 -        }
   12.97 -    }
   12.98 -
   12.99 -    /**
  12.100 -     * Creates a new decompressor.
  12.101 -     */
  12.102 -    public Inflater() {
  12.103 -        this(false);
  12.104 -    }
  12.105 -
  12.106 -    /**
  12.107 -     * Sets input data for decompression. Should be called whenever
  12.108 -     * needsInput() returns true indicating that more input data is
  12.109 -     * required.
  12.110 -     * @param b the input data bytes
  12.111 -     * @param off the start offset of the input data
  12.112 -     * @param len the length of the input data
  12.113 -     * @see Inflater#needsInput
  12.114 -     */
  12.115 -    public void setInput(byte[] b, int off, int len) {
  12.116 -        impl.setInput(b, off, len);
  12.117 -    }
  12.118 -
  12.119 -    /**
  12.120 -     * Sets input data for decompression. Should be called whenever
  12.121 -     * needsInput() returns true indicating that more input data is
  12.122 -     * required.
  12.123 -     * @param b the input data bytes
  12.124 -     * @see Inflater#needsInput
  12.125 -     */
  12.126 -    public void setInput(byte[] b) {
  12.127 -        impl.setInput(b);
  12.128 -    }
  12.129 -
  12.130 -    /**
  12.131 -     * Sets the preset dictionary to the given array of bytes. Should be
  12.132 -     * called when inflate() returns 0 and needsDictionary() returns true
  12.133 -     * indicating that a preset dictionary is required. The method getAdler()
  12.134 -     * can be used to get the Adler-32 value of the dictionary needed.
  12.135 -     * @param b the dictionary data bytes
  12.136 -     * @param off the start offset of the data
  12.137 -     * @param len the length of the data
  12.138 -     * @see Inflater#needsDictionary
  12.139 -     * @see Inflater#getAdler
  12.140 -     */
  12.141 -    public void setDictionary(byte[] b, int off, int len) {
  12.142 -        impl.setDictionary(b, off, len);
  12.143 -    }
  12.144 -
  12.145 -    /**
  12.146 -     * Sets the preset dictionary to the given array of bytes. Should be
  12.147 -     * called when inflate() returns 0 and needsDictionary() returns true
  12.148 -     * indicating that a preset dictionary is required. The method getAdler()
  12.149 -     * can be used to get the Adler-32 value of the dictionary needed.
  12.150 -     * @param b the dictionary data bytes
  12.151 -     * @see Inflater#needsDictionary
  12.152 -     * @see Inflater#getAdler
  12.153 -     */
  12.154 -    public void setDictionary(byte[] b) {
  12.155 -        impl.setDictionary(b);
  12.156 -    }
  12.157 -
  12.158 -    /**
  12.159 -     * Returns the total number of bytes remaining in the input buffer.
  12.160 -     * This can be used to find out what bytes still remain in the input
  12.161 -     * buffer after decompression has finished.
  12.162 -     * @return the total number of bytes remaining in the input buffer
  12.163 -     */
  12.164 -    public int getRemaining() {
  12.165 -        return impl.getRemaining();
  12.166 -    }
  12.167 -
  12.168 -    /**
  12.169 -     * Returns true if no data remains in the input buffer. This can
  12.170 -     * be used to determine if #setInput should be called in order
  12.171 -     * to provide more input.
  12.172 -     * @return true if no data remains in the input buffer
  12.173 -     */
  12.174 -    public boolean needsInput() {
  12.175 -        return impl.needsInput();
  12.176 -    }
  12.177 -
  12.178 -    /**
  12.179 -     * Returns true if a preset dictionary is needed for decompression.
  12.180 -     * @return true if a preset dictionary is needed for decompression
  12.181 -     * @see Inflater#setDictionary
  12.182 -     */
  12.183 -    public boolean needsDictionary() {
  12.184 -        return impl.needsDictionary();
  12.185 -    }
  12.186 -
  12.187 -    /**
  12.188 -     * Returns true if the end of the compressed data stream has been
  12.189 -     * reached.
  12.190 -     * @return true if the end of the compressed data stream has been
  12.191 -     * reached
  12.192 -     */
  12.193 -    public boolean finished() {
  12.194 -        return impl.finished();
  12.195 -    }
  12.196 -
  12.197 -    /**
  12.198 -     * Uncompresses bytes into specified buffer. Returns actual number
  12.199 -     * of bytes uncompressed. A return value of 0 indicates that
  12.200 -     * needsInput() or needsDictionary() should be called in order to
  12.201 -     * determine if more input data or a preset dictionary is required.
  12.202 -     * In the latter case, getAdler() can be used to get the Adler-32
  12.203 -     * value of the dictionary required.
  12.204 -     * @param b the buffer for the uncompressed data
  12.205 -     * @param off the start offset of the data
  12.206 -     * @param len the maximum number of uncompressed bytes
  12.207 -     * @return the actual number of uncompressed bytes
  12.208 -     * @exception DataFormatException if the compressed data format is invalid
  12.209 -     * @see Inflater#needsInput
  12.210 -     * @see Inflater#needsDictionary
  12.211 -     */
  12.212 -    public int inflate(byte[] b, int off, int len)
  12.213 -        throws DataFormatException
  12.214 -    {
  12.215 -        return impl.inflate(b, off, len);
  12.216 -    }
  12.217 -
  12.218 -    /**
  12.219 -     * Uncompresses bytes into specified buffer. Returns actual number
  12.220 -     * of bytes uncompressed. A return value of 0 indicates that
  12.221 -     * needsInput() or needsDictionary() should be called in order to
  12.222 -     * determine if more input data or a preset dictionary is required.
  12.223 -     * In the latter case, getAdler() can be used to get the Adler-32
  12.224 -     * value of the dictionary required.
  12.225 -     * @param b the buffer for the uncompressed data
  12.226 -     * @return the actual number of uncompressed bytes
  12.227 -     * @exception DataFormatException if the compressed data format is invalid
  12.228 -     * @see Inflater#needsInput
  12.229 -     * @see Inflater#needsDictionary
  12.230 -     */
  12.231 -    public int inflate(byte[] b) throws DataFormatException {
  12.232 -        return impl.inflate(b);
  12.233 -    }
  12.234 -
  12.235 -    /**
  12.236 -     * Returns the ADLER-32 value of the uncompressed data.
  12.237 -     * @return the ADLER-32 value of the uncompressed data
  12.238 -     */
  12.239 -    public int getAdler() {
  12.240 -        return impl.getAdler();
  12.241 -    }
  12.242 -
  12.243 -    /**
  12.244 -     * Returns the total number of compressed bytes input so far.
  12.245 -     *
  12.246 -     * <p>Since the number of bytes may be greater than
  12.247 -     * Integer.MAX_VALUE, the {@link #getBytesRead()} method is now
  12.248 -     * the preferred means of obtaining this information.</p>
  12.249 -     *
  12.250 -     * @return the total number of compressed bytes input so far
  12.251 -     */
  12.252 -    public int getTotalIn() {
  12.253 -        return impl.getTotalIn();
  12.254 -    }
  12.255 -
  12.256 -    /**
  12.257 -     * Returns the total number of compressed bytes input so far.</p>
  12.258 -     *
  12.259 -     * @return the total (non-negative) number of compressed bytes input so far
  12.260 -     * @since 1.5
  12.261 -     */
  12.262 -    public long getBytesRead() {
  12.263 -        return impl.getBytesRead();
  12.264 -    }
  12.265 -
  12.266 -    /**
  12.267 -     * Returns the total number of uncompressed bytes output so far.
  12.268 -     *
  12.269 -     * <p>Since the number of bytes may be greater than
  12.270 -     * Integer.MAX_VALUE, the {@link #getBytesWritten()} method is now
  12.271 -     * the preferred means of obtaining this information.</p>
  12.272 -     *
  12.273 -     * @return the total number of uncompressed bytes output so far
  12.274 -     */
  12.275 -    public int getTotalOut() {
  12.276 -        return impl.getTotalOut();
  12.277 -    }
  12.278 -
  12.279 -    /**
  12.280 -     * Returns the total number of uncompressed bytes output so far.</p>
  12.281 -     *
  12.282 -     * @return the total (non-negative) number of uncompressed bytes output so far
  12.283 -     * @since 1.5
  12.284 -     */
  12.285 -    public long getBytesWritten() {
  12.286 -        return impl.getBytesWritten();
  12.287 -    }
  12.288 -
  12.289 -    /**
  12.290 -     * Resets inflater so that a new set of input data can be processed.
  12.291 -     */
  12.292 -    public void reset() {
  12.293 -        impl.reset();
  12.294 -    }
  12.295 -
  12.296 -    /**
  12.297 -     * Closes the decompressor and discards any unprocessed input.
  12.298 -     * This method should be called when the decompressor is no longer
  12.299 -     * being used, but will also be called automatically by the finalize()
  12.300 -     * method. Once this method is called, the behavior of the Inflater
  12.301 -     * object is undefined.
  12.302 -     */
  12.303 -    public void end() {
  12.304 -        impl.end();
  12.305 -    }
  12.306 -
  12.307 -    /**
  12.308 -     * Closes the decompressor when garbage is collected.
  12.309 -     */
  12.310 -    protected void finalize() {
  12.311 -        end();
  12.312 -    }
  12.313 -}
    13.1 --- a/rt/emul/mini/src/main/java/java/util/zip/InflaterInputStream.java	Wed May 07 11:55:06 2014 +0200
    13.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    13.3 @@ -1,288 +0,0 @@
    13.4 -/*
    13.5 - * Copyright (c) 1996, 2006, Oracle and/or its affiliates. All rights reserved.
    13.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    13.7 - *
    13.8 - * This code is free software; you can redistribute it and/or modify it
    13.9 - * under the terms of the GNU General Public License version 2 only, as
   13.10 - * published by the Free Software Foundation.  Oracle designates this
   13.11 - * particular file as subject to the "Classpath" exception as provided
   13.12 - * by Oracle in the LICENSE file that accompanied this code.
   13.13 - *
   13.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
   13.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   13.16 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   13.17 - * version 2 for more details (a copy is included in the LICENSE file that
   13.18 - * accompanied this code).
   13.19 - *
   13.20 - * You should have received a copy of the GNU General Public License version
   13.21 - * 2 along with this work; if not, write to the Free Software Foundation,
   13.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   13.23 - *
   13.24 - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   13.25 - * or visit www.oracle.com if you need additional information or have any
   13.26 - * questions.
   13.27 - */
   13.28 -
   13.29 -package java.util.zip;
   13.30 -
   13.31 -import java.io.FilterInputStream;
   13.32 -import java.io.InputStream;
   13.33 -import java.io.IOException;
   13.34 -import java.io.EOFException;
   13.35 -
   13.36 -/**
   13.37 - * This class implements a stream filter for uncompressing data in the
   13.38 - * "deflate" compression format. It is also used as the basis for other
   13.39 - * decompression filters, such as GZIPInputStream.
   13.40 - *
   13.41 - * @see         Inflater
   13.42 - * @author      David Connelly
   13.43 - */
   13.44 -public
   13.45 -class InflaterInputStream extends FilterInputStream {
   13.46 -    /**
   13.47 -     * Decompressor for this stream.
   13.48 -     */
   13.49 -    protected Inflater inf;
   13.50 -
   13.51 -    /**
   13.52 -     * Input buffer for decompression.
   13.53 -     */
   13.54 -    protected byte[] buf;
   13.55 -
   13.56 -    /**
   13.57 -     * Length of input buffer.
   13.58 -     */
   13.59 -    protected int len;
   13.60 -
   13.61 -    private boolean closed = false;
   13.62 -    // this flag is set to true after EOF has reached
   13.63 -    private boolean reachEOF = false;
   13.64 -
   13.65 -    /**
   13.66 -     * Check to make sure that this stream has not been closed
   13.67 -     */
   13.68 -    private void ensureOpen() throws IOException {
   13.69 -        if (closed) {
   13.70 -            throw new IOException("Stream closed");
   13.71 -        }
   13.72 -    }
   13.73 -
   13.74 -
   13.75 -    /**
   13.76 -     * Creates a new input stream with the specified decompressor and
   13.77 -     * buffer size.
   13.78 -     * @param in the input stream
   13.79 -     * @param inf the decompressor ("inflater")
   13.80 -     * @param size the input buffer size
   13.81 -     * @exception IllegalArgumentException if size is <= 0
   13.82 -     */
   13.83 -    public InflaterInputStream(InputStream in, Inflater inf, int size) {
   13.84 -        super(in);
   13.85 -        if (in == null || inf == null) {
   13.86 -            throw new NullPointerException();
   13.87 -        } else if (size <= 0) {
   13.88 -            throw new IllegalArgumentException("buffer size <= 0");
   13.89 -        }
   13.90 -        this.inf = inf;
   13.91 -        buf = new byte[size];
   13.92 -    }
   13.93 -
   13.94 -    /**
   13.95 -     * Creates a new input stream with the specified decompressor and a
   13.96 -     * default buffer size.
   13.97 -     * @param in the input stream
   13.98 -     * @param inf the decompressor ("inflater")
   13.99 -     */
  13.100 -    public InflaterInputStream(InputStream in, Inflater inf) {
  13.101 -        this(in, inf, 512);
  13.102 -    }
  13.103 -
  13.104 -    boolean usesDefaultInflater = false;
  13.105 -
  13.106 -    /**
  13.107 -     * Creates a new input stream with a default decompressor and buffer size.
  13.108 -     * @param in the input stream
  13.109 -     */
  13.110 -    public InflaterInputStream(InputStream in) {
  13.111 -        this(in, new Inflater());
  13.112 -        usesDefaultInflater = true;
  13.113 -    }
  13.114 -
  13.115 -    private byte[] singleByteBuf = new byte[1];
  13.116 -
  13.117 -    /**
  13.118 -     * Reads a byte of uncompressed data. This method will block until
  13.119 -     * enough input is available for decompression.
  13.120 -     * @return the byte read, or -1 if end of compressed input is reached
  13.121 -     * @exception IOException if an I/O error has occurred
  13.122 -     */
  13.123 -    public int read() throws IOException {
  13.124 -        ensureOpen();
  13.125 -        return read(singleByteBuf, 0, 1) == -1 ? -1 : singleByteBuf[0] & 0xff;
  13.126 -    }
  13.127 -
  13.128 -    /**
  13.129 -     * Reads uncompressed data into an array of bytes. If <code>len</code> is not
  13.130 -     * zero, the method will block until some input can be decompressed; otherwise,
  13.131 -     * no bytes are read and <code>0</code> is returned.
  13.132 -     * @param b the buffer into which the data is read
  13.133 -     * @param off the start offset in the destination array <code>b</code>
  13.134 -     * @param len the maximum number of bytes read
  13.135 -     * @return the actual number of bytes read, or -1 if the end of the
  13.136 -     *         compressed input is reached or a preset dictionary is needed
  13.137 -     * @exception  NullPointerException If <code>b</code> is <code>null</code>.
  13.138 -     * @exception  IndexOutOfBoundsException If <code>off</code> is negative,
  13.139 -     * <code>len</code> is negative, or <code>len</code> is greater than
  13.140 -     * <code>b.length - off</code>
  13.141 -     * @exception ZipException if a ZIP format error has occurred
  13.142 -     * @exception IOException if an I/O error has occurred
  13.143 -     */
  13.144 -    public int read(byte[] b, int off, int len) throws IOException {
  13.145 -        ensureOpen();
  13.146 -        if (b == null) {
  13.147 -            throw new NullPointerException();
  13.148 -        } else if (off < 0 || len < 0 || len > b.length - off) {
  13.149 -            throw new IndexOutOfBoundsException();
  13.150 -        } else if (len == 0) {
  13.151 -            return 0;
  13.152 -        }
  13.153 -        try {
  13.154 -            int n;
  13.155 -            while ((n = inf.inflate(b, off, len)) == 0) {
  13.156 -                if (inf.finished() || inf.needsDictionary()) {
  13.157 -                    reachEOF = true;
  13.158 -                    return -1;
  13.159 -                }
  13.160 -                if (inf.needsInput()) {
  13.161 -                    fill();
  13.162 -                }
  13.163 -            }
  13.164 -            return n;
  13.165 -        } catch (DataFormatException e) {
  13.166 -            String s = e.getMessage();
  13.167 -            throw new ZipException(s != null ? s : "Invalid ZLIB data format");
  13.168 -        }
  13.169 -    }
  13.170 -
  13.171 -    /**
  13.172 -     * Returns 0 after EOF has been reached, otherwise always return 1.
  13.173 -     * <p>
  13.174 -     * Programs should not count on this method to return the actual number
  13.175 -     * of bytes that could be read without blocking.
  13.176 -     *
  13.177 -     * @return     1 before EOF and 0 after EOF.
  13.178 -     * @exception  IOException  if an I/O error occurs.
  13.179 -     *
  13.180 -     */
  13.181 -    public int available() throws IOException {
  13.182 -        ensureOpen();
  13.183 -        if (reachEOF) {
  13.184 -            return 0;
  13.185 -        } else {
  13.186 -            return 1;
  13.187 -        }
  13.188 -    }
  13.189 -
  13.190 -    private byte[] b = new byte[512];
  13.191 -
  13.192 -    /**
  13.193 -     * Skips specified number of bytes of uncompressed data.
  13.194 -     * @param n the number of bytes to skip
  13.195 -     * @return the actual number of bytes skipped.
  13.196 -     * @exception IOException if an I/O error has occurred
  13.197 -     * @exception IllegalArgumentException if n < 0
  13.198 -     */
  13.199 -    public long skip(long n) throws IOException {
  13.200 -        if (n < 0) {
  13.201 -            throw new IllegalArgumentException("negative skip length");
  13.202 -        }
  13.203 -        ensureOpen();
  13.204 -        int max = (int)Math.min(n, Integer.MAX_VALUE);
  13.205 -        int total = 0;
  13.206 -        while (total < max) {
  13.207 -            int len = max - total;
  13.208 -            if (len > b.length) {
  13.209 -                len = b.length;
  13.210 -            }
  13.211 -            len = read(b, 0, len);
  13.212 -            if (len == -1) {
  13.213 -                reachEOF = true;
  13.214 -                break;
  13.215 -            }
  13.216 -            total += len;
  13.217 -        }
  13.218 -        return total;
  13.219 -    }
  13.220 -
  13.221 -    /**
  13.222 -     * Closes this input stream and releases any system resources associated
  13.223 -     * with the stream.
  13.224 -     * @exception IOException if an I/O error has occurred
  13.225 -     */
  13.226 -    public void close() throws IOException {
  13.227 -        if (!closed) {
  13.228 -            if (usesDefaultInflater)
  13.229 -                inf.end();
  13.230 -            in.close();
  13.231 -            closed = true;
  13.232 -        }
  13.233 -    }
  13.234 -
  13.235 -    /**
  13.236 -     * Fills input buffer with more data to decompress.
  13.237 -     * @exception IOException if an I/O error has occurred
  13.238 -     */
  13.239 -    protected void fill() throws IOException {
  13.240 -        ensureOpen();
  13.241 -        len = in.read(buf, 0, buf.length);
  13.242 -        if (len == -1) {
  13.243 -            throw new EOFException("Unexpected end of ZLIB input stream");
  13.244 -        }
  13.245 -        inf.setInput(buf, 0, len);
  13.246 -    }
  13.247 -
  13.248 -    /**
  13.249 -     * Tests if this input stream supports the <code>mark</code> and
  13.250 -     * <code>reset</code> methods. The <code>markSupported</code>
  13.251 -     * method of <code>InflaterInputStream</code> returns
  13.252 -     * <code>false</code>.
  13.253 -     *
  13.254 -     * @return  a <code>boolean</code> indicating if this stream type supports
  13.255 -     *          the <code>mark</code> and <code>reset</code> methods.
  13.256 -     * @see     java.io.InputStream#mark(int)
  13.257 -     * @see     java.io.InputStream#reset()
  13.258 -     */
  13.259 -    public boolean markSupported() {
  13.260 -        return false;
  13.261 -    }
  13.262 -
  13.263 -    /**
  13.264 -     * Marks the current position in this input stream.
  13.265 -     *
  13.266 -     * <p> The <code>mark</code> method of <code>InflaterInputStream</code>
  13.267 -     * does nothing.
  13.268 -     *
  13.269 -     * @param   readlimit   the maximum limit of bytes that can be read before
  13.270 -     *                      the mark position becomes invalid.
  13.271 -     * @see     java.io.InputStream#reset()
  13.272 -     */
  13.273 -    public synchronized void mark(int readlimit) {
  13.274 -    }
  13.275 -
  13.276 -    /**
  13.277 -     * Repositions this stream to the position at the time the
  13.278 -     * <code>mark</code> method was last called on this input stream.
  13.279 -     *
  13.280 -     * <p> The method <code>reset</code> for class
  13.281 -     * <code>InflaterInputStream</code> does nothing except throw an
  13.282 -     * <code>IOException</code>.
  13.283 -     *
  13.284 -     * @exception  IOException  if this method is invoked.
  13.285 -     * @see     java.io.InputStream#mark(int)
  13.286 -     * @see     java.io.IOException
  13.287 -     */
  13.288 -    public synchronized void reset() throws IOException {
  13.289 -        throw new IOException("mark/reset not supported");
  13.290 -    }
  13.291 -}
    14.1 --- a/rt/emul/mini/src/main/java/java/util/zip/ZStreamRef.java	Wed May 07 11:55:06 2014 +0200
    14.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    14.3 @@ -1,46 +0,0 @@
    14.4 -/*
    14.5 - * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
    14.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    14.7 - *
    14.8 - * This code is free software; you can redistribute it and/or modify it
    14.9 - * under the terms of the GNU General Public License version 2 only, as
   14.10 - * published by the Free Software Foundation.  Oracle designates this
   14.11 - * particular file as subject to the "Classpath" exception as provided
   14.12 - * by Oracle in the LICENSE file that accompanied this code.
   14.13 - *
   14.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
   14.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   14.16 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   14.17 - * version 2 for more details (a copy is included in the LICENSE file that
   14.18 - * accompanied this code).
   14.19 - *
   14.20 - * You should have received a copy of the GNU General Public License version
   14.21 - * 2 along with this work; if not, write to the Free Software Foundation,
   14.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   14.23 - *
   14.24 - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   14.25 - * or visit www.oracle.com if you need additional information or have any
   14.26 - * questions.
   14.27 - */
   14.28 -
   14.29 -package java.util.zip;
   14.30 -
   14.31 -/**
   14.32 - * A reference to the native zlib's z_stream structure.
   14.33 - */
   14.34 -
   14.35 -class ZStreamRef {
   14.36 -
   14.37 -    private long address;
   14.38 -    ZStreamRef (long address) {
   14.39 -        this.address = address;
   14.40 -    }
   14.41 -
   14.42 -    long address() {
   14.43 -        return address;
   14.44 -    }
   14.45 -
   14.46 -    void clear() {
   14.47 -        address = 0;
   14.48 -    }
   14.49 -}
    15.1 --- a/rt/emul/mini/src/main/java/java/util/zip/ZipConstants.java	Wed May 07 11:55:06 2014 +0200
    15.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    15.3 @@ -1,98 +0,0 @@
    15.4 -/*
    15.5 - * Copyright (c) 1995, 1996, Oracle and/or its affiliates. All rights reserved.
    15.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    15.7 - *
    15.8 - * This code is free software; you can redistribute it and/or modify it
    15.9 - * under the terms of the GNU General Public License version 2 only, as
   15.10 - * published by the Free Software Foundation.  Oracle designates this
   15.11 - * particular file as subject to the "Classpath" exception as provided
   15.12 - * by Oracle in the LICENSE file that accompanied this code.
   15.13 - *
   15.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
   15.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   15.16 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   15.17 - * version 2 for more details (a copy is included in the LICENSE file that
   15.18 - * accompanied this code).
   15.19 - *
   15.20 - * You should have received a copy of the GNU General Public License version
   15.21 - * 2 along with this work; if not, write to the Free Software Foundation,
   15.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   15.23 - *
   15.24 - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   15.25 - * or visit www.oracle.com if you need additional information or have any
   15.26 - * questions.
   15.27 - */
   15.28 -
   15.29 -package java.util.zip;
   15.30 -
   15.31 -/*
   15.32 - * This interface defines the constants that are used by the classes
   15.33 - * which manipulate ZIP files.
   15.34 - *
   15.35 - * @author      David Connelly
   15.36 - */
   15.37 -interface ZipConstants {
   15.38 -    /*
   15.39 -     * Header signatures
   15.40 -     */
   15.41 -    static long LOCSIG = 0x04034b50L;   // "PK\003\004"
   15.42 -    static long EXTSIG = 0x08074b50L;   // "PK\007\008"
   15.43 -    static long CENSIG = 0x02014b50L;   // "PK\001\002"
   15.44 -    static long ENDSIG = 0x06054b50L;   // "PK\005\006"
   15.45 -
   15.46 -    /*
   15.47 -     * Header sizes in bytes (including signatures)
   15.48 -     */
   15.49 -    static final int LOCHDR = 30;       // LOC header size
   15.50 -    static final int EXTHDR = 16;       // EXT header size
   15.51 -    static final int CENHDR = 46;       // CEN header size
   15.52 -    static final int ENDHDR = 22;       // END header size
   15.53 -
   15.54 -    /*
   15.55 -     * Local file (LOC) header field offsets
   15.56 -     */
   15.57 -    static final int LOCVER = 4;        // version needed to extract
   15.58 -    static final int LOCFLG = 6;        // general purpose bit flag
   15.59 -    static final int LOCHOW = 8;        // compression method
   15.60 -    static final int LOCTIM = 10;       // modification time
   15.61 -    static final int LOCCRC = 14;       // uncompressed file crc-32 value
   15.62 -    static final int LOCSIZ = 18;       // compressed size
   15.63 -    static final int LOCLEN = 22;       // uncompressed size
   15.64 -    static final int LOCNAM = 26;       // filename length
   15.65 -    static final int LOCEXT = 28;       // extra field length
   15.66 -
   15.67 -    /*
   15.68 -     * Extra local (EXT) header field offsets
   15.69 -     */
   15.70 -    static final int EXTCRC = 4;        // uncompressed file crc-32 value
   15.71 -    static final int EXTSIZ = 8;        // compressed size
   15.72 -    static final int EXTLEN = 12;       // uncompressed size
   15.73 -
   15.74 -    /*
   15.75 -     * Central directory (CEN) header field offsets
   15.76 -     */
   15.77 -    static final int CENVEM = 4;        // version made by
   15.78 -    static final int CENVER = 6;        // version needed to extract
   15.79 -    static final int CENFLG = 8;        // encrypt, decrypt flags
   15.80 -    static final int CENHOW = 10;       // compression method
   15.81 -    static final int CENTIM = 12;       // modification time
   15.82 -    static final int CENCRC = 16;       // uncompressed file crc-32 value
   15.83 -    static final int CENSIZ = 20;       // compressed size
   15.84 -    static final int CENLEN = 24;       // uncompressed size
   15.85 -    static final int CENNAM = 28;       // filename length
   15.86 -    static final int CENEXT = 30;       // extra field length
   15.87 -    static final int CENCOM = 32;       // comment length
   15.88 -    static final int CENDSK = 34;       // disk number start
   15.89 -    static final int CENATT = 36;       // internal file attributes
   15.90 -    static final int CENATX = 38;       // external file attributes
   15.91 -    static final int CENOFF = 42;       // LOC header offset
   15.92 -
   15.93 -    /*
   15.94 -     * End of central directory (END) header field offsets
   15.95 -     */
   15.96 -    static final int ENDSUB = 8;        // number of entries on this disk
   15.97 -    static final int ENDTOT = 10;       // total number of entries
   15.98 -    static final int ENDSIZ = 12;       // central directory size in bytes
   15.99 -    static final int ENDOFF = 16;       // offset of first CEN header
  15.100 -    static final int ENDCOM = 20;       // zip file comment length
  15.101 -}
    16.1 --- a/rt/emul/mini/src/main/java/java/util/zip/ZipEntry.java	Wed May 07 11:55:06 2014 +0200
    16.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    16.3 @@ -1,331 +0,0 @@
    16.4 -/*
    16.5 - * Copyright (c) 1995, 2011, Oracle and/or its affiliates. All rights reserved.
    16.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    16.7 - *
    16.8 - * This code is free software; you can redistribute it and/or modify it
    16.9 - * under the terms of the GNU General Public License version 2 only, as
   16.10 - * published by the Free Software Foundation.  Oracle designates this
   16.11 - * particular file as subject to the "Classpath" exception as provided
   16.12 - * by Oracle in the LICENSE file that accompanied this code.
   16.13 - *
   16.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
   16.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   16.16 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   16.17 - * version 2 for more details (a copy is included in the LICENSE file that
   16.18 - * accompanied this code).
   16.19 - *
   16.20 - * You should have received a copy of the GNU General Public License version
   16.21 - * 2 along with this work; if not, write to the Free Software Foundation,
   16.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   16.23 - *
   16.24 - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   16.25 - * or visit www.oracle.com if you need additional information or have any
   16.26 - * questions.
   16.27 - */
   16.28 -
   16.29 -package java.util.zip;
   16.30 -
   16.31 -/**
   16.32 - * This class is used to represent a ZIP file entry.
   16.33 - *
   16.34 - * @author      David Connelly
   16.35 - */
   16.36 -public
   16.37 -class ZipEntry implements ZipConstants, Cloneable {
   16.38 -    String name;        // entry name
   16.39 -    long time = -1;     // modification time (in DOS time)
   16.40 -    long crc = -1;      // crc-32 of entry data
   16.41 -    long size = -1;     // uncompressed size of entry data
   16.42 -    long csize = -1;    // compressed size of entry data
   16.43 -    int method = -1;    // compression method
   16.44 -    int flag = 0;       // general purpose flag
   16.45 -    byte[] extra;       // optional extra field data for entry
   16.46 -    String comment;     // optional comment string for entry
   16.47 -
   16.48 -    /**
   16.49 -     * Compression method for uncompressed entries.
   16.50 -     */
   16.51 -    public static final int STORED = 0;
   16.52 -
   16.53 -    /**
   16.54 -     * Compression method for compressed (deflated) entries.
   16.55 -     */
   16.56 -    public static final int DEFLATED = 8;
   16.57 -
   16.58 -    /**
   16.59 -     * Creates a new zip entry with the specified name.
   16.60 -     *
   16.61 -     * @param name the entry name
   16.62 -     * @exception NullPointerException if the entry name is null
   16.63 -     * @exception IllegalArgumentException if the entry name is longer than
   16.64 -     *            0xFFFF bytes
   16.65 -     */
   16.66 -    public ZipEntry(String name) {
   16.67 -        if (name == null) {
   16.68 -            throw new NullPointerException();
   16.69 -        }
   16.70 -        if (name.length() > 0xFFFF) {
   16.71 -            throw new IllegalArgumentException("entry name too long");
   16.72 -        }
   16.73 -        this.name = name;
   16.74 -    }
   16.75 -
   16.76 -    /**
   16.77 -     * Creates a new zip entry with fields taken from the specified
   16.78 -     * zip entry.
   16.79 -     * @param e a zip Entry object
   16.80 -     */
   16.81 -    public ZipEntry(ZipEntry e) {
   16.82 -        name = e.name;
   16.83 -        time = e.time;
   16.84 -        crc = e.crc;
   16.85 -        size = e.size;
   16.86 -        csize = e.csize;
   16.87 -        method = e.method;
   16.88 -        flag = e.flag;
   16.89 -        extra = e.extra;
   16.90 -        comment = e.comment;
   16.91 -    }
   16.92 -
   16.93 -    /*
   16.94 -     * Creates a new un-initialized zip entry
   16.95 -     */
   16.96 -    ZipEntry() {}
   16.97 -
   16.98 -    /**
   16.99 -     * Returns the name of the entry.
  16.100 -     * @return the name of the entry
  16.101 -     */
  16.102 -    public String getName() {
  16.103 -        return name;
  16.104 -    }
  16.105 -
  16.106 -    /**
  16.107 -     * Sets the modification time of the entry.
  16.108 -     * @param time the entry modification time in number of milliseconds
  16.109 -     *             since the epoch
  16.110 -     * @see #getTime()
  16.111 -     */
  16.112 -    public void setTime(long time) {
  16.113 -        this.time = javaToDosTime(time);
  16.114 -    }
  16.115 -
  16.116 -    /**
  16.117 -     * Returns the modification time of the entry, or -1 if not specified.
  16.118 -     * @return the modification time of the entry, or -1 if not specified
  16.119 -     * @see #setTime(long)
  16.120 -     */
  16.121 -    public long getTime() {
  16.122 -        return time != -1 ? dosToJavaTime(time) : -1;
  16.123 -    }
  16.124 -
  16.125 -    /**
  16.126 -     * Sets the uncompressed size of the entry data.
  16.127 -     * @param size the uncompressed size in bytes
  16.128 -     * @exception IllegalArgumentException if the specified size is less
  16.129 -     *            than 0, is greater than 0xFFFFFFFF when
  16.130 -     *            <a href="package-summary.html#zip64">ZIP64 format</a> is not supported,
  16.131 -     *            or is less than 0 when ZIP64 is supported
  16.132 -     * @see #getSize()
  16.133 -     */
  16.134 -    public void setSize(long size) {
  16.135 -        if (size < 0) {
  16.136 -            throw new IllegalArgumentException("invalid entry size");
  16.137 -        }
  16.138 -        this.size = size;
  16.139 -    }
  16.140 -
  16.141 -    /**
  16.142 -     * Returns the uncompressed size of the entry data, or -1 if not known.
  16.143 -     * @return the uncompressed size of the entry data, or -1 if not known
  16.144 -     * @see #setSize(long)
  16.145 -     */
  16.146 -    public long getSize() {
  16.147 -        return size;
  16.148 -    }
  16.149 -
  16.150 -    /**
  16.151 -     * Returns the size of the compressed entry data, or -1 if not known.
  16.152 -     * In the case of a stored entry, the compressed size will be the same
  16.153 -     * as the uncompressed size of the entry.
  16.154 -     * @return the size of the compressed entry data, or -1 if not known
  16.155 -     * @see #setCompressedSize(long)
  16.156 -     */
  16.157 -    public long getCompressedSize() {
  16.158 -        return csize;
  16.159 -    }
  16.160 -
  16.161 -    /**
  16.162 -     * Sets the size of the compressed entry data.
  16.163 -     * @param csize the compressed size to set to
  16.164 -     * @see #getCompressedSize()
  16.165 -     */
  16.166 -    public void setCompressedSize(long csize) {
  16.167 -        this.csize = csize;
  16.168 -    }
  16.169 -
  16.170 -    /**
  16.171 -     * Sets the CRC-32 checksum of the uncompressed entry data.
  16.172 -     * @param crc the CRC-32 value
  16.173 -     * @exception IllegalArgumentException if the specified CRC-32 value is
  16.174 -     *            less than 0 or greater than 0xFFFFFFFF
  16.175 -     * @see #getCrc()
  16.176 -     */
  16.177 -    public void setCrc(long crc) {
  16.178 -        if (crc < 0 || crc > 0xFFFFFFFFL) {
  16.179 -            throw new IllegalArgumentException("invalid entry crc-32");
  16.180 -        }
  16.181 -        this.crc = crc;
  16.182 -    }
  16.183 -
  16.184 -    /**
  16.185 -     * Returns the CRC-32 checksum of the uncompressed entry data, or -1 if
  16.186 -     * not known.
  16.187 -     * @return the CRC-32 checksum of the uncompressed entry data, or -1 if
  16.188 -     * not known
  16.189 -     * @see #setCrc(long)
  16.190 -     */
  16.191 -    public long getCrc() {
  16.192 -        return crc;
  16.193 -    }
  16.194 -
  16.195 -    /**
  16.196 -     * Sets the compression method for the entry.
  16.197 -     * @param method the compression method, either STORED or DEFLATED
  16.198 -     * @exception IllegalArgumentException if the specified compression
  16.199 -     *            method is invalid
  16.200 -     * @see #getMethod()
  16.201 -     */
  16.202 -    public void setMethod(int method) {
  16.203 -        if (method != STORED && method != DEFLATED) {
  16.204 -            throw new IllegalArgumentException("invalid compression method");
  16.205 -        }
  16.206 -        this.method = method;
  16.207 -    }
  16.208 -
  16.209 -    /**
  16.210 -     * Returns the compression method of the entry, or -1 if not specified.
  16.211 -     * @return the compression method of the entry, or -1 if not specified
  16.212 -     * @see #setMethod(int)
  16.213 -     */
  16.214 -    public int getMethod() {
  16.215 -        return method;
  16.216 -    }
  16.217 -
  16.218 -    /**
  16.219 -     * Sets the optional extra field data for the entry.
  16.220 -     * @param extra the extra field data bytes
  16.221 -     * @exception IllegalArgumentException if the length of the specified
  16.222 -     *            extra field data is greater than 0xFFFF bytes
  16.223 -     * @see #getExtra()
  16.224 -     */
  16.225 -    public void setExtra(byte[] extra) {
  16.226 -        if (extra != null && extra.length > 0xFFFF) {
  16.227 -            throw new IllegalArgumentException("invalid extra field length");
  16.228 -        }
  16.229 -        this.extra = extra;
  16.230 -    }
  16.231 -
  16.232 -    /**
  16.233 -     * Returns the extra field data for the entry, or null if none.
  16.234 -     * @return the extra field data for the entry, or null if none
  16.235 -     * @see #setExtra(byte[])
  16.236 -     */
  16.237 -    public byte[] getExtra() {
  16.238 -        return extra;
  16.239 -    }
  16.240 -
  16.241 -    /**
  16.242 -     * Sets the optional comment string for the entry.
  16.243 -     *
  16.244 -     * <p>ZIP entry comments have maximum length of 0xffff. If the length of the
  16.245 -     * specified comment string is greater than 0xFFFF bytes after encoding, only
  16.246 -     * the first 0xFFFF bytes are output to the ZIP file entry.
  16.247 -     *
  16.248 -     * @param comment the comment string
  16.249 -     *
  16.250 -     * @see #getComment()
  16.251 -     */
  16.252 -    public void setComment(String comment) {
  16.253 -        this.comment = comment;
  16.254 -    }
  16.255 -
  16.256 -    /**
  16.257 -     * Returns the comment string for the entry, or null if none.
  16.258 -     * @return the comment string for the entry, or null if none
  16.259 -     * @see #setComment(String)
  16.260 -     */
  16.261 -    public String getComment() {
  16.262 -        return comment;
  16.263 -    }
  16.264 -
  16.265 -    /**
  16.266 -     * Returns true if this is a directory entry. A directory entry is
  16.267 -     * defined to be one whose name ends with a '/'.
  16.268 -     * @return true if this is a directory entry
  16.269 -     */
  16.270 -    public boolean isDirectory() {
  16.271 -        return name.endsWith("/");
  16.272 -    }
  16.273 -
  16.274 -    /**
  16.275 -     * Returns a string representation of the ZIP entry.
  16.276 -     */
  16.277 -    public String toString() {
  16.278 -        return getName();
  16.279 -    }
  16.280 -
  16.281 -    /*
  16.282 -     * Converts DOS time to Java time (number of milliseconds since epoch).
  16.283 -     */
  16.284 -    private static long dosToJavaTime(long dtime) {
  16.285 -        return dtime;
  16.286 -        /* XXX:
  16.287 -        Date d = new Date((int)(((dtime >> 25) & 0x7f) + 80),
  16.288 -                          (int)(((dtime >> 21) & 0x0f) - 1),
  16.289 -                          (int)((dtime >> 16) & 0x1f),
  16.290 -                          (int)((dtime >> 11) & 0x1f),
  16.291 -                          (int)((dtime >> 5) & 0x3f),
  16.292 -                          (int)((dtime << 1) & 0x3e));
  16.293 -        return d.getTime();
  16.294 -        */
  16.295 -    }
  16.296 -
  16.297 -    /*
  16.298 -     * Converts Java time to DOS time.
  16.299 -     */
  16.300 -    private static long javaToDosTime(long time) {
  16.301 -        return time;
  16.302 -        /* XXX:
  16.303 -        Date d = new Date(time);
  16.304 -        int year = d.getYear() + 1900;
  16.305 -        if (year < 1980) {
  16.306 -            return (1 << 21) | (1 << 16);
  16.307 -        }
  16.308 -        return (year - 1980) << 25 | (d.getMonth() + 1) << 21 |
  16.309 -               d.getDate() << 16 | d.getHours() << 11 | d.getMinutes() << 5 |
  16.310 -               d.getSeconds() >> 1;
  16.311 -        */
  16.312 -    }
  16.313 -
  16.314 -    /**
  16.315 -     * Returns the hash code value for this entry.
  16.316 -     */
  16.317 -    public int hashCode() {
  16.318 -        return name.hashCode();
  16.319 -    }
  16.320 -
  16.321 -    /**
  16.322 -     * Returns a copy of this entry.
  16.323 -     */
  16.324 -    public Object clone() {
  16.325 -        try {
  16.326 -            ZipEntry e = (ZipEntry)super.clone();
  16.327 -            e.extra = (extra == null) ? null : extra.clone();
  16.328 -            return e;
  16.329 -        } catch (CloneNotSupportedException e) {
  16.330 -            // This should never happen, since we are Cloneable
  16.331 -            throw new IllegalStateException();
  16.332 -        }
  16.333 -    }
  16.334 -}
    17.1 --- a/rt/emul/mini/src/main/java/java/util/zip/ZipException.java	Wed May 07 11:55:06 2014 +0200
    17.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    17.3 @@ -1,60 +0,0 @@
    17.4 -/*
    17.5 - * Copyright (c) 1995, 2010, Oracle and/or its affiliates. All rights reserved.
    17.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    17.7 - *
    17.8 - * This code is free software; you can redistribute it and/or modify it
    17.9 - * under the terms of the GNU General Public License version 2 only, as
   17.10 - * published by the Free Software Foundation.  Oracle designates this
   17.11 - * particular file as subject to the "Classpath" exception as provided
   17.12 - * by Oracle in the LICENSE file that accompanied this code.
   17.13 - *
   17.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
   17.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   17.16 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   17.17 - * version 2 for more details (a copy is included in the LICENSE file that
   17.18 - * accompanied this code).
   17.19 - *
   17.20 - * You should have received a copy of the GNU General Public License version
   17.21 - * 2 along with this work; if not, write to the Free Software Foundation,
   17.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   17.23 - *
   17.24 - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   17.25 - * or visit www.oracle.com if you need additional information or have any
   17.26 - * questions.
   17.27 - */
   17.28 -
   17.29 -package java.util.zip;
   17.30 -
   17.31 -import java.io.IOException;
   17.32 -
   17.33 -/**
   17.34 - * Signals that a Zip exception of some sort has occurred.
   17.35 - *
   17.36 - * @author  unascribed
   17.37 - * @see     java.io.IOException
   17.38 - * @since   JDK1.0
   17.39 - */
   17.40 -
   17.41 -public
   17.42 -class ZipException extends IOException {
   17.43 -    private static final long serialVersionUID = 8000196834066748623L;
   17.44 -
   17.45 -    /**
   17.46 -     * Constructs a <code>ZipException</code> with <code>null</code>
   17.47 -     * as its error detail message.
   17.48 -     */
   17.49 -    public ZipException() {
   17.50 -        super();
   17.51 -    }
   17.52 -
   17.53 -    /**
   17.54 -     * Constructs a <code>ZipException</code> with the specified detail
   17.55 -     * message.
   17.56 -     *
   17.57 -     * @param   s   the detail message.
   17.58 -     */
   17.59 -
   17.60 -    public ZipException(String s) {
   17.61 -        super(s);
   17.62 -    }
   17.63 -}
    18.1 --- a/rt/emul/mini/src/main/java/java/util/zip/ZipInputStream.java	Wed May 07 11:55:06 2014 +0200
    18.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    18.3 @@ -1,194 +0,0 @@
    18.4 -/*
    18.5 - * Copyright (c) 1996, 2009, Oracle and/or its affiliates. All rights reserved.
    18.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    18.7 - *
    18.8 - * This code is free software; you can redistribute it and/or modify it
    18.9 - * under the terms of the GNU General Public License version 2 only, as
   18.10 - * published by the Free Software Foundation.  Oracle designates this
   18.11 - * particular file as subject to the "Classpath" exception as provided
   18.12 - * by Oracle in the LICENSE file that accompanied this code.
   18.13 - *
   18.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
   18.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   18.16 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   18.17 - * version 2 for more details (a copy is included in the LICENSE file that
   18.18 - * accompanied this code).
   18.19 - *
   18.20 - * You should have received a copy of the GNU General Public License version
   18.21 - * 2 along with this work; if not, write to the Free Software Foundation,
   18.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   18.23 - *
   18.24 - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   18.25 - * or visit www.oracle.com if you need additional information or have any
   18.26 - * questions.
   18.27 - */
   18.28 -
   18.29 -package java.util.zip;
   18.30 -
   18.31 -import java.io.InputStream;
   18.32 -import java.io.IOException;
   18.33 -
   18.34 -/**
   18.35 - * This class implements an input stream filter for reading files in the
   18.36 - * ZIP file format. Includes support for both compressed and uncompressed
   18.37 - * entries.
   18.38 - *
   18.39 - * @author      David Connelly
   18.40 - */
   18.41 -public
   18.42 -class ZipInputStream extends InflaterInputStream implements ZipConstants {
   18.43 -    private final org.apidesign.bck2brwsr.emul.zip.ZipInputStream impl;
   18.44 -
   18.45 -    /**
   18.46 -     * Creates a new ZIP input stream.
   18.47 -     *
   18.48 -     * <p>The UTF-8 {@link java.nio.charset.Charset charset} is used to
   18.49 -     * decode the entry names.
   18.50 -     *
   18.51 -     * @param in the actual input stream
   18.52 -     */
   18.53 -    public ZipInputStream(InputStream in) {
   18.54 -        super(in);
   18.55 -        impl = new org.apidesign.bck2brwsr.emul.zip.ZipInputStream(in);
   18.56 -    }
   18.57 -
   18.58 -    /**
   18.59 -     * Creates a new ZIP input stream.
   18.60 -     *
   18.61 -     * @param in the actual input stream
   18.62 -     *
   18.63 -     * @param charset
   18.64 -     *        The {@linkplain java.nio.charset.Charset charset} to be
   18.65 -     *        used to decode the ZIP entry name (ignored if the
   18.66 -     *        <a href="package-summary.html#lang_encoding"> language
   18.67 -     *        encoding bit</a> of the ZIP entry's general purpose bit
   18.68 -     *        flag is set).
   18.69 -     *
   18.70 -     * @since 1.7
   18.71 -     *
   18.72 -    public ZipInputStream(InputStream in, Charset charset) {
   18.73 -        super(new PushbackInputStream(in, 512), new Inflater(true), 512);
   18.74 -        usesDefaultInflater = true;
   18.75 -        if(in == null) {
   18.76 -            throw new NullPointerException("in is null");
   18.77 -        }
   18.78 -        if (charset == null)
   18.79 -            throw new NullPointerException("charset is null");
   18.80 -        this.zc = ZipCoder.get(charset);
   18.81 -    }
   18.82 -    */
   18.83 -
   18.84 -    /**
   18.85 -     * Reads the next ZIP file entry and positions the stream at the
   18.86 -     * beginning of the entry data.
   18.87 -     * @return the next ZIP file entry, or null if there are no more entries
   18.88 -     * @exception ZipException if a ZIP file error has occurred
   18.89 -     * @exception IOException if an I/O error has occurred
   18.90 -     */
   18.91 -    public ZipEntry getNextEntry() throws IOException {
   18.92 -        return impl.getNextEntry();
   18.93 -    }
   18.94 -
   18.95 -    /**
   18.96 -     * Closes the current ZIP entry and positions the stream for reading the
   18.97 -     * next entry.
   18.98 -     * @exception ZipException if a ZIP file error has occurred
   18.99 -     * @exception IOException if an I/O error has occurred
  18.100 -     */
  18.101 -    public void closeEntry() throws IOException {
  18.102 -        impl.closeEntry();
  18.103 -    }
  18.104 -
  18.105 -    /**
  18.106 -     * Returns 0 after EOF has reached for the current entry data,
  18.107 -     * otherwise always return 1.
  18.108 -     * <p>
  18.109 -     * Programs should not count on this method to return the actual number
  18.110 -     * of bytes that could be read without blocking.
  18.111 -     *
  18.112 -     * @return     1 before EOF and 0 after EOF has reached for current entry.
  18.113 -     * @exception  IOException  if an I/O error occurs.
  18.114 -     *
  18.115 -     */
  18.116 -    public int available() throws IOException {
  18.117 -        return impl.available();
  18.118 -    }
  18.119 -
  18.120 -    /**
  18.121 -     * Reads from the current ZIP entry into an array of bytes.
  18.122 -     * If <code>len</code> is not zero, the method
  18.123 -     * blocks until some input is available; otherwise, no
  18.124 -     * bytes are read and <code>0</code> is returned.
  18.125 -     * @param b the buffer into which the data is read
  18.126 -     * @param off the start offset in the destination array <code>b</code>
  18.127 -     * @param len the maximum number of bytes read
  18.128 -     * @return the actual number of bytes read, or -1 if the end of the
  18.129 -     *         entry is reached
  18.130 -     * @exception  NullPointerException if <code>b</code> is <code>null</code>.
  18.131 -     * @exception  IndexOutOfBoundsException if <code>off</code> is negative,
  18.132 -     * <code>len</code> is negative, or <code>len</code> is greater than
  18.133 -     * <code>b.length - off</code>
  18.134 -     * @exception ZipException if a ZIP file error has occurred
  18.135 -     * @exception IOException if an I/O error has occurred
  18.136 -     */
  18.137 -    public int read(byte[] b, int off, int len) throws IOException {
  18.138 -        return impl.read(b, off, len);
  18.139 -    }
  18.140 -
  18.141 -    /**
  18.142 -     * Skips specified number of bytes in the current ZIP entry.
  18.143 -     * @param n the number of bytes to skip
  18.144 -     * @return the actual number of bytes skipped
  18.145 -     * @exception ZipException if a ZIP file error has occurred
  18.146 -     * @exception IOException if an I/O error has occurred
  18.147 -     * @exception IllegalArgumentException if n < 0
  18.148 -     */
  18.149 -    public long skip(long n) throws IOException {
  18.150 -        return impl.skip(n);
  18.151 -    }
  18.152 -
  18.153 -    /**
  18.154 -     * Closes this input stream and releases any system resources associated
  18.155 -     * with the stream.
  18.156 -     * @exception IOException if an I/O error has occurred
  18.157 -     */
  18.158 -    public void close() throws IOException {
  18.159 -        impl.close();
  18.160 -    }
  18.161 -
  18.162 -    /**
  18.163 -     * Creates a new <code>ZipEntry</code> object for the specified
  18.164 -     * entry name.
  18.165 -     *
  18.166 -     * @param name the ZIP file entry name
  18.167 -     * @return the ZipEntry just created
  18.168 -     */
  18.169 -    protected ZipEntry createZipEntry(String name) {
  18.170 -        return new ZipEntry(name);
  18.171 -    }
  18.172 -
  18.173 -    @Override
  18.174 -    public int read() throws IOException {
  18.175 -        return impl.read();
  18.176 -    }
  18.177 -
  18.178 -    @Override
  18.179 -    public boolean markSupported() {
  18.180 -        return impl.markSupported();
  18.181 -    }
  18.182 -
  18.183 -    @Override
  18.184 -    public void mark(int readlimit) {
  18.185 -        impl.mark(readlimit);
  18.186 -    }
  18.187 -
  18.188 -    @Override
  18.189 -    public void reset() throws IOException {
  18.190 -        impl.reset();
  18.191 -    }
  18.192 -
  18.193 -    @Override
  18.194 -    public int read(byte[] b) throws IOException {
  18.195 -        return impl.read(b);
  18.196 -    }
  18.197 -}
    19.1 --- a/rt/emul/mini/src/main/java/java/util/zip/package-info.java	Wed May 07 11:55:06 2014 +0200
    19.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    19.3 @@ -1,21 +0,0 @@
    19.4 -/**
    19.5 - * Back 2 Browser Bytecode Translator
    19.6 - * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
    19.7 - *
    19.8 - * This program is free software: you can redistribute it and/or modify
    19.9 - * it under the terms of the GNU General Public License as published by
   19.10 - * the Free Software Foundation, version 2 of the License.
   19.11 - *
   19.12 - * This program is distributed in the hope that it will be useful,
   19.13 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
   19.14 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   19.15 - * GNU General Public License for more details.
   19.16 - *
   19.17 - * You should have received a copy of the GNU General Public License
   19.18 - * along with this program. Look for COPYING file in the top folder.
   19.19 - * If not, see http://opensource.org/licenses/GPL-2.0.
   19.20 - */
   19.21 -@Exported
   19.22 -package java.util.zip;
   19.23 -
   19.24 -import org.apidesign.bck2brwsr.core.Exported;
    20.1 --- a/rt/emul/mini/src/main/java/java/util/zip/package.html	Wed May 07 11:55:06 2014 +0200
    20.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    20.3 @@ -1,98 +0,0 @@
    20.4 -<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
    20.5 -<html>
    20.6 -<head>
    20.7 -<!--
    20.8 -Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved.
    20.9 -DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   20.10 -
   20.11 -This code is free software; you can redistribute it and/or modify it
   20.12 -under the terms of the GNU General Public License version 2 only, as
   20.13 -published by the Free Software Foundation.  Oracle designates this
   20.14 -particular file as subject to the "Classpath" exception as provided
   20.15 -by Oracle in the LICENSE file that accompanied this code.
   20.16 -
   20.17 -This code is distributed in the hope that it will be useful, but WITHOUT
   20.18 -ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   20.19 -FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   20.20 -version 2 for more details (a copy is included in the LICENSE file that
   20.21 -accompanied this code).
   20.22 -
   20.23 -You should have received a copy of the GNU General Public License version
   20.24 -2 along with this work; if not, write to the Free Software Foundation,
   20.25 -Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   20.26 -
   20.27 -Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   20.28 -or visit www.oracle.com if you need additional information or have any
   20.29 -questions.
   20.30 --->
   20.31 -
   20.32 -</head>
   20.33 -<body bgcolor="white">
   20.34 -
   20.35 -Provides classes for reading and writing the standard ZIP and GZIP
   20.36 -file formats.  Also includes classes for compressing and decompressing
   20.37 -data using the DEFLATE compression algorithm, which is used by the
   20.38 -ZIP and GZIP file formats. Additionally, there are utility classes
   20.39 -for computing the CRC-32 and Adler-32 checksums of arbitrary
   20.40 -input streams.
   20.41 -
   20.42 -
   20.43 -<h2>Package Specification</h2>
   20.44 -
   20.45 -</a>
   20.46 -<ul>
   20.47 -  <li><a href="ftp://ftp.uu.net/pub/archiving/zip/doc/appnote-970311-iz.zip">
   20.48 -      Info-ZIP Application Note 970311
   20.49 -      </a> - a detailed description of the Info-ZIP format upon which
   20.50 -      the <code>java.util.zip</code> classes are based.
   20.51 -<p>
   20.52 -  <a name="zip64">
   20.53 -  <li>An implementation may optionally support the ZIP64(tm) format extensions
   20.54 -      defined by the 
   20.55 -      <a href="http://www.pkware.com/documents/casestudies/APPNOTE.TXT">
   20.56 -      PKWARE ZIP File Format Specification</a>. The ZIP64(tm) format extensions
   20.57 -      are used to overcome the size limitations of the original ZIP format.
   20.58 -<p>
   20.59 -  <a name="lang_encoding">
   20.60 -  <li>APPENDIX D of <a href="http://www.pkware.com/documents/casestudies/APPNOTE.TXT">
   20.61 -      PKWARE ZIP File Format Specification</a> - Language Encoding Flag (EFS) to
   20.62 -      encode ZIP entry filename and comment fields using UTF-8.
   20.63 -<p>
   20.64 -  <li><a href="http://www.ietf.org/rfc/rfc1950.txt">
   20.65 -      ZLIB Compressed Data Format Specification version 3.3</a>
   20.66 -      &nbsp;
   20.67 -      <a href="http://www.ietf.org/rfc/rfc1950.txt.pdf">(pdf)</a>
   20.68 -      (RFC 1950)
   20.69 -<p>
   20.70 -  <li><a href="http://www.ietf.org/rfc/rfc1951.txt">
   20.71 -      DEFLATE Compressed Data Format Specification version 1.3</a>
   20.72 -      &nbsp;
   20.73 -      <a href="http://www.ietf.org/rfc/rfc1951.txt.pdf">(pdf)</a>
   20.74 -      (RFC 1951)
   20.75 -<p>
   20.76 -  <li><a href="http://www.ietf.org/rfc/rfc1952.txt">
   20.77 -      GZIP file format specification version 4.3</a>
   20.78 -      &nbsp;
   20.79 -      <a href="http://www.ietf.org/rfc/rfc1952.txt.pdf">(pdf)</a>
   20.80 -      (RFC 1952)
   20.81 -<p>
   20.82 -  <li>CRC-32 checksum is described in RFC 1952 (above)
   20.83 -<p>
   20.84 -  <li>Adler-32 checksum is described in RFC 1950 (above)
   20.85 -</ul>
   20.86 -
   20.87 -
   20.88 -<!--
   20.89 -<h2>Related Documentation</h2>
   20.90 -
   20.91 -For overviews, tutorials, examples, guides, and tool documentation, please see:
   20.92 -<ul>
   20.93 -  <li><a href="">##### REFER TO NON-SPEC DOCUMENTATION HERE #####</a>
   20.94 -</ul>
   20.95 --->
   20.96 -
   20.97 -@since JDK1.1
   20.98 -</body>
   20.99 -</html>
  20.100 -
  20.101 -
    21.1 --- a/rt/emul/mini/src/main/java/org/apidesign/bck2brwsr/emul/zip/Adler32.java	Wed May 07 11:55:06 2014 +0200
    21.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    21.3 @@ -1,139 +0,0 @@
    21.4 -/* -*-mode:java; c-basic-offset:2; -*- */
    21.5 -/*
    21.6 -Copyright (c) 2000-2011 ymnk, JCraft,Inc. All rights reserved.
    21.7 -
    21.8 -Redistribution and use in source and binary forms, with or without
    21.9 -modification, are permitted provided that the following conditions are met:
   21.10 -
   21.11 -  1. Redistributions of source code must retain the above copyright notice,
   21.12 -     this list of conditions and the following disclaimer.
   21.13 -
   21.14 -  2. Redistributions in binary form must reproduce the above copyright 
   21.15 -     notice, this list of conditions and the following disclaimer in 
   21.16 -     the documentation and/or other materials provided with the distribution.
   21.17 -
   21.18 -  3. The names of the authors may not be used to endorse or promote products
   21.19 -     derived from this software without specific prior written permission.
   21.20 -
   21.21 -THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
   21.22 -INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
   21.23 -FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
   21.24 -INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
   21.25 -INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   21.26 -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
   21.27 -OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
   21.28 -LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
   21.29 -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
   21.30 -EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
   21.31 - */
   21.32 -/*
   21.33 - * This program is based on zlib-1.1.3, so all credit should go authors
   21.34 - * Jean-loup Gailly(jloup@gzip.org) and Mark Adler(madler@alumni.caltech.edu)
   21.35 - * and contributors of zlib.
   21.36 - */
   21.37 -
   21.38 -package org.apidesign.bck2brwsr.emul.zip;
   21.39 -
   21.40 -final class Adler32 implements Checksum {
   21.41 -
   21.42 -  // largest prime smaller than 65536
   21.43 -  static final private int BASE=65521; 
   21.44 -  // NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1
   21.45 -  static final private int NMAX=5552;
   21.46 -
   21.47 -  private long s1=1L;
   21.48 -  private long s2=0L;
   21.49 -
   21.50 -  public void reset(long init){
   21.51 -    s1=init&0xffff;
   21.52 -    s2=(init>>16)&0xffff;
   21.53 -  }
   21.54 -
   21.55 -  public void reset(){
   21.56 -    s1=1L;
   21.57 -    s2=0L;
   21.58 -  }
   21.59 -
   21.60 -  public long getValue(){
   21.61 -    return ((s2<<16)|s1);
   21.62 -  }
   21.63 -
   21.64 -  public void update(byte[] buf, int index, int len){
   21.65 -
   21.66 -    if(len==1){
   21.67 -      s1+=buf[index++]&0xff; s2+=s1;
   21.68 -      s1%=BASE;
   21.69 -      s2%=BASE;
   21.70 -      return;
   21.71 -    }
   21.72 -
   21.73 -    int len1 = len/NMAX;
   21.74 -    int len2 = len%NMAX;
   21.75 -    while(len1-->0) {
   21.76 -      int k=NMAX;
   21.77 -      len-=k;
   21.78 -      while(k-->0){
   21.79 -	s1+=buf[index++]&0xff; s2+=s1;
   21.80 -      }
   21.81 -      s1%=BASE;
   21.82 -      s2%=BASE;
   21.83 -    }
   21.84 -
   21.85 -    int k=len2;
   21.86 -    len-=k;
   21.87 -    while(k-->0){
   21.88 -      s1+=buf[index++]&0xff; s2+=s1;
   21.89 -    }
   21.90 -    s1%=BASE;
   21.91 -    s2%=BASE;
   21.92 -  }
   21.93 -
   21.94 -  public Adler32 copy(){
   21.95 -    Adler32 foo = new Adler32();
   21.96 -    foo.s1 = this.s1;
   21.97 -    foo.s2 = this.s2;
   21.98 -    return foo;
   21.99 -  }
  21.100 -
  21.101 -  // The following logic has come from zlib.1.2.
  21.102 -  static long combine(long adler1, long adler2, long len2){
  21.103 -    long BASEL = (long)BASE;
  21.104 -    long sum1;
  21.105 -    long sum2;
  21.106 -    long rem;  // unsigned int
  21.107 -
  21.108 -    rem = len2 % BASEL;
  21.109 -    sum1 = adler1 & 0xffffL;
  21.110 -    sum2 = rem * sum1;
  21.111 -    sum2 %= BASEL; // MOD(sum2);
  21.112 -    sum1 += (adler2 & 0xffffL) + BASEL - 1;
  21.113 -    sum2 += ((adler1 >> 16) & 0xffffL) + ((adler2 >> 16) & 0xffffL) + BASEL - rem;
  21.114 -    if (sum1 >= BASEL) sum1 -= BASEL;
  21.115 -    if (sum1 >= BASEL) sum1 -= BASEL;
  21.116 -    if (sum2 >= (BASEL << 1)) sum2 -= (BASEL << 1);
  21.117 -    if (sum2 >= BASEL) sum2 -= BASEL;
  21.118 -    return sum1 | (sum2 << 16);
  21.119 -  }
  21.120 -
  21.121 -/*
  21.122 -  private java.util.zip.Adler32 adler=new java.util.zip.Adler32();
  21.123 -  public void update(byte[] buf, int index, int len){
  21.124 -    if(buf==null) {adler.reset();}
  21.125 -    else{adler.update(buf, index, len);}
  21.126 -  }
  21.127 -  public void reset(){
  21.128 -    adler.reset();
  21.129 -  }
  21.130 -  public void reset(long init){
  21.131 -    if(init==1L){
  21.132 -      adler.reset();
  21.133 -    }
  21.134 -    else{
  21.135 -      System.err.println("unsupported operation");
  21.136 -    }
  21.137 -  }
  21.138 -  public long getValue(){
  21.139 -    return adler.getValue();
  21.140 -  }
  21.141 -*/
  21.142 -}
    22.1 --- a/rt/emul/mini/src/main/java/org/apidesign/bck2brwsr/emul/zip/CRC32.java	Wed May 07 11:55:06 2014 +0200
    22.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    22.3 @@ -1,181 +0,0 @@
    22.4 -/* -*-mode:java; c-basic-offset:2; -*- */
    22.5 -/*
    22.6 -Copyright (c) 2011 ymnk, JCraft,Inc. All rights reserved.
    22.7 -
    22.8 -Redistribution and use in source and binary forms, with or without
    22.9 -modification, are permitted provided that the following conditions are met:
   22.10 -
   22.11 -  1. Redistributions of source code must retain the above copyright notice,
   22.12 -     this list of conditions and the following disclaimer.
   22.13 -
   22.14 -  2. Redistributions in binary form must reproduce the above copyright 
   22.15 -     notice, this list of conditions and the following disclaimer in 
   22.16 -     the documentation and/or other materials provided with the distribution.
   22.17 -
   22.18 -  3. The names of the authors may not be used to endorse or promote products
   22.19 -     derived from this software without specific prior written permission.
   22.20 -
   22.21 -THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
   22.22 -INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
   22.23 -FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
   22.24 -INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
   22.25 -INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   22.26 -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
   22.27 -OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
   22.28 -LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
   22.29 -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
   22.30 -EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
   22.31 - */
   22.32 -/*
   22.33 - * This program is based on zlib-1.1.3, so all credit should go authors
   22.34 - * Jean-loup Gailly(jloup@gzip.org) and Mark Adler(madler@alumni.caltech.edu)
   22.35 - * and contributors of zlib.
   22.36 - */
   22.37 -
   22.38 -package org.apidesign.bck2brwsr.emul.zip;
   22.39 -
   22.40 -import org.apidesign.bck2brwsr.emul.lang.System;
   22.41 -
   22.42 -final class CRC32 implements Checksum {
   22.43 -
   22.44 -  /*
   22.45 -   *  The following logic has come from RFC1952.
   22.46 -   */
   22.47 -  private int v = 0;
   22.48 -  private static int[] crc_table = null;
   22.49 -  static {
   22.50 -    crc_table = new int[256];
   22.51 -    for (int n = 0; n < 256; n++) {
   22.52 -      int c = n;
   22.53 -      for (int k = 8;  --k >= 0; ) {
   22.54 -        if ((c & 1) != 0)
   22.55 -	  c = 0xedb88320 ^ (c >>> 1);
   22.56 -        else
   22.57 -          c = c >>> 1;
   22.58 -      }
   22.59 -      crc_table[n] = c;
   22.60 -    }
   22.61 -  }
   22.62 -
   22.63 -  public void update (byte[] buf, int index, int len) {
   22.64 -    int c = ~v;
   22.65 -    while (--len >= 0)
   22.66 -      c = crc_table[(c^buf[index++])&0xff]^(c >>> 8);
   22.67 -    v = ~c;
   22.68 -  }
   22.69 -
   22.70 -  public void reset(){
   22.71 -    v = 0;
   22.72 -  }
   22.73 -
   22.74 -  public void reset(long vv){
   22.75 -    v = (int)(vv&0xffffffffL);
   22.76 -  }
   22.77 -
   22.78 -  public long getValue(){
   22.79 -    return (long)(v&0xffffffffL);
   22.80 -  }
   22.81 -
   22.82 -  // The following logic has come from zlib.1.2.
   22.83 -  private static final int GF2_DIM = 32;
   22.84 -  static long combine(long crc1, long crc2, long len2){
   22.85 -    long row;
   22.86 -    long[] even = new long[GF2_DIM];
   22.87 -    long[] odd = new long[GF2_DIM];
   22.88 -
   22.89 -    // degenerate case (also disallow negative lengths)
   22.90 -    if (len2 <= 0)
   22.91 -      return crc1;
   22.92 -
   22.93 -    // put operator for one zero bit in odd
   22.94 -    odd[0] = 0xedb88320L;          // CRC-32 polynomial
   22.95 -    row = 1;
   22.96 -    for (int n = 1; n < GF2_DIM; n++) {
   22.97 -        odd[n] = row;
   22.98 -        row <<= 1;
   22.99 -    }
  22.100 -
  22.101 -    // put operator for two zero bits in even
  22.102 -    gf2_matrix_square(even, odd);
  22.103 -
  22.104 -    // put operator for four zero bits in odd
  22.105 -    gf2_matrix_square(odd, even);
  22.106 -
  22.107 -    // apply len2 zeros to crc1 (first square will put the operator for one
  22.108 -    // zero byte, eight zero bits, in even)
  22.109 -    do {
  22.110 -      // apply zeros operator for this bit of len2
  22.111 -      gf2_matrix_square(even, odd);
  22.112 -      if ((len2 & 1)!=0)
  22.113 -        crc1 = gf2_matrix_times(even, crc1);
  22.114 -      len2 >>= 1;
  22.115 -
  22.116 -      // if no more bits set, then done
  22.117 -      if (len2 == 0)
  22.118 -        break;
  22.119 -
  22.120 -      // another iteration of the loop with odd and even swapped
  22.121 -      gf2_matrix_square(odd, even);
  22.122 -      if ((len2 & 1)!=0)
  22.123 -        crc1 = gf2_matrix_times(odd, crc1);
  22.124 -      len2 >>= 1;
  22.125 -
  22.126 -      // if no more bits set, then done
  22.127 -    } while (len2 != 0);
  22.128 -
  22.129 -    /* return combined crc */
  22.130 -    crc1 ^= crc2;
  22.131 -    return crc1;
  22.132 -  }
  22.133 -
  22.134 -  private static long gf2_matrix_times(long[] mat, long vec){
  22.135 -    long sum = 0;
  22.136 -    int index = 0;
  22.137 -    while (vec!=0) {
  22.138 -      if ((vec & 1)!=0)
  22.139 -        sum ^= mat[index];
  22.140 -      vec >>= 1;
  22.141 -      index++;
  22.142 -    }
  22.143 -    return sum;
  22.144 -  }
  22.145 -
  22.146 -  static final void gf2_matrix_square(long[] square, long[] mat) {
  22.147 -    for (int n = 0; n < GF2_DIM; n++)
  22.148 -      square[n] = gf2_matrix_times(mat, mat[n]);
  22.149 -  }
  22.150 -
  22.151 -  /*
  22.152 -  private java.util.zip.CRC32 crc32 = new java.util.zip.CRC32();
  22.153 -
  22.154 -  public void update(byte[] buf, int index, int len){
  22.155 -    if(buf==null) {crc32.reset();}
  22.156 -    else{crc32.update(buf, index, len);}
  22.157 -  }
  22.158 -  public void reset(){
  22.159 -    crc32.reset();
  22.160 -  }
  22.161 -  public void reset(long init){
  22.162 -    if(init==0L){
  22.163 -      crc32.reset();
  22.164 -    }
  22.165 -    else{
  22.166 -      System.err.println("unsupported operation");
  22.167 -    }
  22.168 -  }
  22.169 -  public long getValue(){
  22.170 -    return crc32.getValue();
  22.171 -  }
  22.172 -*/
  22.173 -  public CRC32 copy(){
  22.174 -    CRC32 foo = new CRC32();
  22.175 -    foo.v = this.v;
  22.176 -    return foo;
  22.177 -  }
  22.178 -
  22.179 -  public static int[] getCRC32Table(){
  22.180 -    int[] tmp = new int[crc_table.length];
  22.181 -    System.arraycopy(crc_table, 0, tmp, 0, tmp.length);
  22.182 -    return tmp;
  22.183 -  }
  22.184 -}
    23.1 --- a/rt/emul/mini/src/main/java/org/apidesign/bck2brwsr/emul/zip/Checksum.java	Wed May 07 11:55:06 2014 +0200
    23.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    23.3 @@ -1,43 +0,0 @@
    23.4 -/* -*-mode:java; c-basic-offset:2; -*- */
    23.5 -/*
    23.6 -Copyright (c) 2011 ymnk, JCraft,Inc. All rights reserved.
    23.7 -
    23.8 -Redistribution and use in source and binary forms, with or without
    23.9 -modification, are permitted provided that the following conditions are met:
   23.10 -
   23.11 -  1. Redistributions of source code must retain the above copyright notice,
   23.12 -     this list of conditions and the following disclaimer.
   23.13 -
   23.14 -  2. Redistributions in binary form must reproduce the above copyright 
   23.15 -     notice, this list of conditions and the following disclaimer in 
   23.16 -     the documentation and/or other materials provided with the distribution.
   23.17 -
   23.18 -  3. The names of the authors may not be used to endorse or promote products
   23.19 -     derived from this software without specific prior written permission.
   23.20 -
   23.21 -THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
   23.22 -INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
   23.23 -FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
   23.24 -INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
   23.25 -INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   23.26 -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
   23.27 -OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
   23.28 -LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
   23.29 -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
   23.30 -EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
   23.31 - */
   23.32 -/*
   23.33 - * This program is based on zlib-1.1.3, so all credit should go authors
   23.34 - * Jean-loup Gailly(jloup@gzip.org) and Mark Adler(madler@alumni.caltech.edu)
   23.35 - * and contributors of zlib.
   23.36 - */
   23.37 -
   23.38 -package org.apidesign.bck2brwsr.emul.zip;
   23.39 -
   23.40 -interface Checksum {
   23.41 -  void update(byte[] buf, int index, int len);
   23.42 -  void reset();
   23.43 -  void reset(long init);
   23.44 -  long getValue();
   23.45 -  Checksum copy();
   23.46 -}
    24.1 --- a/rt/emul/mini/src/main/java/org/apidesign/bck2brwsr/emul/zip/FastJar.java	Wed May 07 11:55:06 2014 +0200
    24.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    24.3 @@ -1,175 +0,0 @@
    24.4 -/*
    24.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
    24.6 - *
    24.7 - * Copyright 1997-2010 Oracle and/or its affiliates. All rights reserved.
    24.8 - *
    24.9 - * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
   24.10 - * Other names may be trademarks of their respective owners.
   24.11 - *
   24.12 - * The contents of this file are subject to the terms of either the GNU
   24.13 - * General Public License Version 2 only ("GPL") or the Common
   24.14 - * Development and Distribution License("CDDL") (collectively, the
   24.15 - * "License"). You may not use this file except in compliance with the
   24.16 - * License. You can obtain a copy of the License at
   24.17 - * http://www.netbeans.org/cddl-gplv2.html
   24.18 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
   24.19 - * specific language governing permissions and limitations under the
   24.20 - * License.  When distributing the software, include this License Header
   24.21 - * Notice in each file and include the License file at
   24.22 - * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
   24.23 - * particular file as subject to the "Classpath" exception as provided
   24.24 - * by Oracle in the GPL Version 2 section of the License file that
   24.25 - * accompanied this code. If applicable, add the following below the
   24.26 - * License Header, with the fields enclosed by brackets [] replaced by
   24.27 - * your own identifying information:
   24.28 - * "Portions Copyrighted [year] [name of copyright owner]"
   24.29 - *
   24.30 - * Contributor(s):
   24.31 - *
   24.32 - * Portions Copyrighted 2007 Sun Microsystems, Inc.
   24.33 - */
   24.34 -package org.apidesign.bck2brwsr.emul.zip;
   24.35 -
   24.36 -import java.io.ByteArrayInputStream;
   24.37 -import java.io.IOException;
   24.38 -import java.io.InputStream;
   24.39 -import java.util.zip.ZipEntry;
   24.40 -import java.util.zip.ZipInputStream;
   24.41 -
   24.42 -/**
   24.43 - *
   24.44 - * @author Tomas Zezula
   24.45 - */
   24.46 -public final class FastJar {
   24.47 -    private final byte[] arr;
   24.48 -
   24.49 -    public FastJar(byte[] arr) {
   24.50 -        this.arr = arr;
   24.51 -    }
   24.52 -    
   24.53 -    
   24.54 -    private static final int GIVE_UP = 1<<16;
   24.55 -
   24.56 -    public static final  class Entry {
   24.57 -        
   24.58 -        public final String name;
   24.59 -        final long offset;
   24.60 -        private final long dosTime;
   24.61 -        
   24.62 -        Entry (String name, long offset, long time) {
   24.63 -            assert name != null;
   24.64 -            this.name = name;
   24.65 -            this.offset = offset;
   24.66 -            this.dosTime = time;
   24.67 -        }        
   24.68 -/*        
   24.69 -        public long getTime () {
   24.70 -            Date d = new Date((int)(((dosTime >> 25) & 0x7f) + 80),
   24.71 -                    (int)(((dosTime >> 21) & 0x0f) - 1),
   24.72 -                    (int)((dosTime >> 16) & 0x1f),
   24.73 -                    (int)((dosTime >> 11) & 0x1f),
   24.74 -                    (int)((dosTime >> 5) & 0x3f),
   24.75 -                    (int)((dosTime << 1) & 0x3e));
   24.76 -            return d.getTime();
   24.77 -        }
   24.78 -        */
   24.79 -    }
   24.80 -    
   24.81 -    public InputStream getInputStream (final Entry e) throws IOException {
   24.82 -        return getInputStream(arr, e.offset);
   24.83 -    }
   24.84 -    
   24.85 -    private static InputStream getInputStream (byte[] arr, final long offset) throws IOException {
   24.86 -        ByteArrayInputStream is = new ByteArrayInputStream(arr);
   24.87 -        is.skip(offset);
   24.88 -        ZipInputStream in = new ZipInputStream (is);
   24.89 -        ZipEntry e = in.getNextEntry();
   24.90 -        if (e != null && e.getCrc() == 0L && e.getMethod() == ZipEntry.STORED) {
   24.91 -            int cp = arr.length - is.available();
   24.92 -            return new ByteArrayInputStream(arr, cp, (int)e.getSize());
   24.93 -        }
   24.94 -        return in;
   24.95 -    }
   24.96 -    
   24.97 -    public Entry[] list() throws IOException {
   24.98 -        final int size = arr.length;
   24.99 -
  24.100 -        int at = size - ZipInputStream.ENDHDR;
  24.101 -
  24.102 -        byte[] data = new byte[ZipInputStream.ENDHDR];        
  24.103 -        int giveup = 0;
  24.104 -
  24.105 -        do {
  24.106 -            org.apidesign.bck2brwsr.emul.lang.System.arraycopy(arr, at, data, 0, data.length);
  24.107 -            at--;
  24.108 -            giveup++;
  24.109 -            if (giveup > GIVE_UP) {
  24.110 -                throw new IOException ();
  24.111 -            }
  24.112 -        } while (getsig(data) != ZipInputStream.ENDSIG);
  24.113 -
  24.114 -
  24.115 -        final long censize = endsiz(data);
  24.116 -        final long cenoff  = endoff(data);
  24.117 -        at = (int) cenoff;                                                     
  24.118 -
  24.119 -        Entry[] result = new Entry[0];
  24.120 -        int cenread = 0;
  24.121 -        data = new byte[ZipInputStream.CENHDR];
  24.122 -        while (cenread < censize) {
  24.123 -            org.apidesign.bck2brwsr.emul.lang.System.arraycopy(arr, at, data, 0, data.length);
  24.124 -            at += data.length;
  24.125 -            if (getsig(data) != ZipInputStream.CENSIG) {
  24.126 -                throw new IOException("No central table");          //NOI18N
  24.127 -            }
  24.128 -            int cennam = cennam(data);
  24.129 -            int cenext = cenext(data);
  24.130 -            int cencom = cencom(data);
  24.131 -            long lhoff = cenoff(data);
  24.132 -            long centim = centim(data);
  24.133 -            String name = new String(arr, at, cennam, "UTF-8");
  24.134 -            at += cennam;
  24.135 -            int seekby = cenext+cencom;
  24.136 -            int cendatalen = ZipInputStream.CENHDR + cennam + seekby;
  24.137 -            cenread+=cendatalen;
  24.138 -            result = addEntry(result, new Entry(name,lhoff, centim));
  24.139 -            at += seekby;
  24.140 -        }
  24.141 -        return result;
  24.142 -    }
  24.143 -
  24.144 -    private Entry[] addEntry(Entry[] result, Entry entry) {
  24.145 -        Entry[] e = new Entry[result.length + 1];
  24.146 -        e[result.length] = entry;
  24.147 -        org.apidesign.bck2brwsr.emul.lang.System.arraycopy(result, 0, e, 0, result.length);
  24.148 -        return e;
  24.149 -    }
  24.150 -
  24.151 -    private static final long getsig(final byte[] b) throws IOException {return get32(b,0);}
  24.152 -    private static final long endsiz(final byte[] b) throws IOException {return get32(b,ZipInputStream.ENDSIZ);}
  24.153 -    private static final long endoff(final byte[] b) throws IOException {return get32(b,ZipInputStream.ENDOFF);}
  24.154 -    private static final long  cenlen(final byte[] b) throws IOException {return get32(b,ZipInputStream.CENLEN);}
  24.155 -    private static final long  censiz(final byte[] b) throws IOException {return get32(b,ZipInputStream.CENSIZ);}
  24.156 -    private static final long centim(final byte[] b) throws IOException {return get32(b,ZipInputStream.CENTIM);}
  24.157 -    private static final int  cennam(final byte[] b) throws IOException {return get16(b,ZipInputStream.CENNAM);}
  24.158 -    private static final int  cenext(final byte[] b) throws IOException {return get16(b,ZipInputStream.CENEXT);}
  24.159 -    private static final int  cencom(final byte[] b) throws IOException {return get16(b,ZipInputStream.CENCOM);}
  24.160 -    private static final long cenoff (final byte[] b) throws IOException {return get32(b,ZipInputStream.CENOFF);}
  24.161 -    private static final int lochow(final byte[] b) throws IOException {return get16(b,ZipInputStream.LOCHOW);}
  24.162 -    private static final int locname(final byte[] b) throws IOException {return get16(b,ZipInputStream.LOCNAM);}
  24.163 -    private static final int locext(final byte[] b) throws IOException {return get16(b,ZipInputStream.LOCEXT);}
  24.164 -    private static final long locsiz(final byte[] b) throws IOException {return get32(b,ZipInputStream.LOCSIZ);}
  24.165 -    
  24.166 -    private static final int get16(final byte[] b, int off) throws IOException {        
  24.167 -        final int b1 = b[off];
  24.168 -	final int b2 = b[off+1];
  24.169 -        return (b1 & 0xff) | ((b2 & 0xff) << 8);
  24.170 -    }
  24.171 -
  24.172 -    private static final long get32(final byte[] b, int off) throws IOException {
  24.173 -	final int s1 = get16(b, off);
  24.174 -	final int s2 = get16(b, off+2);
  24.175 -        return s1 | ((long)s2 << 16);
  24.176 -    }
  24.177 -
  24.178 -}
    25.1 --- a/rt/emul/mini/src/main/java/org/apidesign/bck2brwsr/emul/zip/GZIPHeader.java	Wed May 07 11:55:06 2014 +0200
    25.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    25.3 @@ -1,215 +0,0 @@
    25.4 -/* -*-mode:java; c-basic-offset:2; -*- */
    25.5 -/*
    25.6 -Copyright (c) 2011 ymnk, JCraft,Inc. All rights reserved.
    25.7 -
    25.8 -Redistribution and use in source and binary forms, with or without
    25.9 -modification, are permitted provided that the following conditions are met:
   25.10 -
   25.11 -  1. Redistributions of source code must retain the above copyright notice,
   25.12 -     this list of conditions and the following disclaimer.
   25.13 -
   25.14 -  2. Redistributions in binary form must reproduce the above copyright 
   25.15 -     notice, this list of conditions and the following disclaimer in 
   25.16 -     the documentation and/or other materials provided with the distribution.
   25.17 -
   25.18 -  3. The names of the authors may not be used to endorse or promote products
   25.19 -     derived from this software without specific prior written permission.
   25.20 -
   25.21 -THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
   25.22 -INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
   25.23 -FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
   25.24 -INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
   25.25 -INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   25.26 -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
   25.27 -OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
   25.28 -LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
   25.29 -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
   25.30 -EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
   25.31 - */
   25.32 -/*
   25.33 - * This program is based on zlib-1.1.3, so all credit should go authors
   25.34 - * Jean-loup Gailly(jloup@gzip.org) and Mark Adler(madler@alumni.caltech.edu)
   25.35 - * and contributors of zlib.
   25.36 - */
   25.37 -
   25.38 -package org.apidesign.bck2brwsr.emul.zip;
   25.39 -
   25.40 -import org.apidesign.bck2brwsr.emul.lang.System;
   25.41 -import java.io.UnsupportedEncodingException;
   25.42 -
   25.43 -/**
   25.44 - * @see "http://www.ietf.org/rfc/rfc1952.txt"
   25.45 - */
   25.46 -final class GZIPHeader implements Cloneable {
   25.47 -
   25.48 -  public static final byte OS_MSDOS = (byte) 0x00;
   25.49 -  public static final byte OS_AMIGA = (byte) 0x01;
   25.50 -  public static final byte OS_VMS = (byte) 0x02;
   25.51 -  public static final byte OS_UNIX = (byte) 0x03;
   25.52 -  public static final byte OS_ATARI = (byte) 0x05;
   25.53 -  public static final byte OS_OS2 = (byte) 0x06;
   25.54 -  public static final byte OS_MACOS = (byte) 0x07;
   25.55 -  public static final byte OS_TOPS20 = (byte) 0x0a;
   25.56 -  public static final byte OS_WIN32 = (byte) 0x0b;
   25.57 -  public static final byte OS_VMCMS = (byte) 0x04;
   25.58 -  public static final byte OS_ZSYSTEM = (byte) 0x08;
   25.59 -  public static final byte OS_CPM = (byte) 0x09;
   25.60 -  public static final byte OS_QDOS = (byte) 0x0c;
   25.61 -  public static final byte OS_RISCOS = (byte) 0x0d;
   25.62 -  public static final byte OS_UNKNOWN = (byte) 0xff;
   25.63 -
   25.64 -  boolean text = false;
   25.65 -  private boolean fhcrc = false;
   25.66 -  long time;
   25.67 -  int xflags;
   25.68 -  int os = 255;
   25.69 -  byte[] extra;
   25.70 -  byte[] name;
   25.71 -  byte[] comment;
   25.72 -  int hcrc;
   25.73 -  long crc;
   25.74 -  boolean done = false;
   25.75 -  long mtime = 0;
   25.76 -
   25.77 -  public void setModifiedTime(long mtime) {
   25.78 -    this.mtime = mtime;
   25.79 -  }
   25.80 -
   25.81 -  public long getModifiedTime() {
   25.82 -    return mtime;
   25.83 -  }
   25.84 -
   25.85 -  public void setOS(int os) {
   25.86 -    if((0<=os && os <=13) || os==255)
   25.87 -      this.os=os;
   25.88 -    else
   25.89 -      throw new IllegalArgumentException("os: "+os);
   25.90 -  }
   25.91 -
   25.92 -  public int getOS(){
   25.93 -    return os;
   25.94 -  }
   25.95 -
   25.96 -  public void setName(String name) {
   25.97 -    try{
   25.98 -      this.name=name.getBytes("ISO-8859-1");
   25.99 -    }
  25.100 -    catch(UnsupportedEncodingException e){
  25.101 -      throw new IllegalArgumentException("name must be in ISO-8859-1 "+name);
  25.102 -    }
  25.103 -  }
  25.104 -
  25.105 -  public String getName(){
  25.106 -    if(name==null) return "";
  25.107 -    try {
  25.108 -      return new String(name, "ISO-8859-1");
  25.109 -    }
  25.110 -    catch (UnsupportedEncodingException e) {
  25.111 -      throw new IllegalArgumentException(e.toString());
  25.112 -    }
  25.113 -  }
  25.114 -
  25.115 -  public void setComment(String comment) {
  25.116 -    try{
  25.117 -      this.comment=comment.getBytes("ISO-8859-1");
  25.118 -    }
  25.119 -    catch(UnsupportedEncodingException e){
  25.120 -      throw new IllegalArgumentException("comment must be in ISO-8859-1 "+name);
  25.121 -    }
  25.122 -  }
  25.123 -
  25.124 -  public String getComment(){
  25.125 -    if(comment==null) return "";
  25.126 -    try {
  25.127 -      return new String(comment, "ISO-8859-1");
  25.128 -    }
  25.129 -    catch (UnsupportedEncodingException e) {
  25.130 -      throw new IllegalArgumentException(e.toString());
  25.131 -    }
  25.132 -  }
  25.133 -
  25.134 -  public void setCRC(long crc){
  25.135 -    this.crc = crc;
  25.136 -  }
  25.137 -
  25.138 -  public long getCRC(){
  25.139 -    return crc;
  25.140 -  }
  25.141 -/*
  25.142 -  void put(Deflate d){
  25.143 -    int flag = 0;
  25.144 -    if(text){
  25.145 -      flag |= 1;     // FTEXT
  25.146 -    }
  25.147 -    if(fhcrc){
  25.148 -      flag |= 2;     // FHCRC
  25.149 -    }
  25.150 -    if(extra!=null){
  25.151 -      flag |= 4;     // FEXTRA
  25.152 -    }
  25.153 -    if(name!=null){
  25.154 -      flag |= 8;    // FNAME
  25.155 -    }
  25.156 -    if(comment!=null){
  25.157 -      flag |= 16;   // FCOMMENT
  25.158 -    }
  25.159 -    int xfl = 0;
  25.160 -    if(d.level == JZlib.Z_BEST_SPEED){
  25.161 -      xfl |= 4;
  25.162 -    }
  25.163 -    else if (d.level == JZlib.Z_BEST_COMPRESSION){
  25.164 -      xfl |= 2;
  25.165 -    }
  25.166 -
  25.167 -    d.put_short((short)0x8b1f);  // ID1 ID2
  25.168 -    d.put_byte((byte)8);         // CM(Compression Method)
  25.169 -    d.put_byte((byte)flag);
  25.170 -    d.put_byte((byte)mtime);
  25.171 -    d.put_byte((byte)(mtime>>8));
  25.172 -    d.put_byte((byte)(mtime>>16));
  25.173 -    d.put_byte((byte)(mtime>>24));
  25.174 -    d.put_byte((byte)xfl);
  25.175 -    d.put_byte((byte)os);
  25.176 -
  25.177 -    if(extra!=null){
  25.178 -      d.put_byte((byte)extra.length);
  25.179 -      d.put_byte((byte)(extra.length>>8));
  25.180 -      d.put_byte(extra, 0, extra.length);
  25.181 -    }
  25.182 -
  25.183 -    if(name!=null){
  25.184 -      d.put_byte(name, 0, name.length);
  25.185 -      d.put_byte((byte)0);
  25.186 -    }
  25.187 -
  25.188 -    if(comment!=null){
  25.189 -      d.put_byte(comment, 0, comment.length);
  25.190 -      d.put_byte((byte)0);
  25.191 -    }
  25.192 -  }
  25.193 -*/
  25.194 -  @Override
  25.195 -  public Object clone() throws CloneNotSupportedException {
  25.196 -    GZIPHeader gheader = (GZIPHeader)super.clone();
  25.197 -    byte[] tmp;
  25.198 -    if(gheader.extra!=null){
  25.199 -      tmp=new byte[gheader.extra.length];
  25.200 -      System.arraycopy(gheader.extra, 0, tmp, 0, tmp.length);
  25.201 -      gheader.extra = tmp;
  25.202 -    }
  25.203 -
  25.204 -    if(gheader.name!=null){
  25.205 -      tmp=new byte[gheader.name.length];
  25.206 -      System.arraycopy(gheader.name, 0, tmp, 0, tmp.length);
  25.207 -      gheader.name = tmp;
  25.208 -    }
  25.209 -
  25.210 -    if(gheader.comment!=null){
  25.211 -      tmp=new byte[gheader.comment.length];
  25.212 -      System.arraycopy(gheader.comment, 0, tmp, 0, tmp.length);
  25.213 -      gheader.comment = tmp;
  25.214 -    }
  25.215 -
  25.216 -    return gheader;
  25.217 -  }
  25.218 -}
    26.1 --- a/rt/emul/mini/src/main/java/org/apidesign/bck2brwsr/emul/zip/InfBlocks.java	Wed May 07 11:55:06 2014 +0200
    26.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    26.3 @@ -1,616 +0,0 @@
    26.4 -/* -*-mode:java; c-basic-offset:2; -*- */
    26.5 -/*
    26.6 -Copyright (c) 2011 ymnk, JCraft,Inc. All rights reserved.
    26.7 -
    26.8 -Redistribution and use in source and binary forms, with or without
    26.9 -modification, are permitted provided that the following conditions are met:
   26.10 -
   26.11 -  1. Redistributions of source code must retain the above copyright notice,
   26.12 -     this list of conditions and the following disclaimer.
   26.13 -
   26.14 -  2. Redistributions in binary form must reproduce the above copyright 
   26.15 -     notice, this list of conditions and the following disclaimer in 
   26.16 -     the documentation and/or other materials provided with the distribution.
   26.17 -
   26.18 -  3. The names of the authors may not be used to endorse or promote products
   26.19 -     derived from this software without specific prior written permission.
   26.20 -
   26.21 -THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
   26.22 -INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
   26.23 -FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
   26.24 -INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
   26.25 -INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   26.26 -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
   26.27 -OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
   26.28 -LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
   26.29 -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
   26.30 -EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
   26.31 - */
   26.32 -/*
   26.33 - * This program is based on zlib-1.1.3, so all credit should go authors
   26.34 - * Jean-loup Gailly(jloup@gzip.org) and Mark Adler(madler@alumni.caltech.edu)
   26.35 - * and contributors of zlib.
   26.36 - */
   26.37 -
   26.38 -package org.apidesign.bck2brwsr.emul.zip;
   26.39 -
   26.40 -import org.apidesign.bck2brwsr.emul.lang.System;
   26.41 -
   26.42 -final class InfBlocks{
   26.43 -  static final private int MANY=1440;
   26.44 -
   26.45 -  // And'ing with mask[n] masks the lower n bits
   26.46 -  static final private int[] inflate_mask = {
   26.47 -    0x00000000, 0x00000001, 0x00000003, 0x00000007, 0x0000000f,
   26.48 -    0x0000001f, 0x0000003f, 0x0000007f, 0x000000ff, 0x000001ff,
   26.49 -    0x000003ff, 0x000007ff, 0x00000fff, 0x00001fff, 0x00003fff,
   26.50 -    0x00007fff, 0x0000ffff
   26.51 -  };
   26.52 -
   26.53 -  // Table for deflate from PKZIP's appnote.txt.
   26.54 -  static final int[] border = { // Order of the bit length code lengths
   26.55 -    16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15
   26.56 -  };
   26.57 -
   26.58 -  static final private int Z_OK=0;
   26.59 -  static final private int Z_STREAM_END=1;
   26.60 -  static final private int Z_NEED_DICT=2;
   26.61 -  static final private int Z_ERRNO=-1;
   26.62 -  static final private int Z_STREAM_ERROR=-2;
   26.63 -  static final private int Z_DATA_ERROR=-3;
   26.64 -  static final private int Z_MEM_ERROR=-4;
   26.65 -  static final private int Z_BUF_ERROR=-5;
   26.66 -  static final private int Z_VERSION_ERROR=-6;
   26.67 -
   26.68 -  static final private int TYPE=0;  // get type bits (3, including end bit)
   26.69 -  static final private int LENS=1;  // get lengths for stored
   26.70 -  static final private int STORED=2;// processing stored block
   26.71 -  static final private int TABLE=3; // get table lengths
   26.72 -  static final private int BTREE=4; // get bit lengths tree for a dynamic block
   26.73 -  static final private int DTREE=5; // get length, distance trees for a dynamic block
   26.74 -  static final private int CODES=6; // processing fixed or dynamic block
   26.75 -  static final private int DRY=7;   // output remaining window bytes
   26.76 -  static final private int DONE=8;  // finished last block, done
   26.77 -  static final private int BAD=9;   // ot a data error--stuck here
   26.78 -
   26.79 -  int mode;            // current inflate_block mode 
   26.80 -
   26.81 -  int left;            // if STORED, bytes left to copy 
   26.82 -
   26.83 -  int table;           // table lengths (14 bits) 
   26.84 -  int index;           // index into blens (or border) 
   26.85 -  int[] blens;         // bit lengths of codes 
   26.86 -  int[] bb=new int[1]; // bit length tree depth 
   26.87 -  int[] tb=new int[1]; // bit length decoding tree 
   26.88 -
   26.89 -  int[] bl=new int[1];
   26.90 -  int[] bd=new int[1];
   26.91 -
   26.92 -  int[][] tl=new int[1][];
   26.93 -  int[][] td=new int[1][];
   26.94 -  int[] tli=new int[1]; // tl_index
   26.95 -  int[] tdi=new int[1]; // td_index
   26.96 -
   26.97 -  private final InfCodes codes;      // if CODES, current state 
   26.98 -
   26.99 -  int last;            // true if this block is the last block 
  26.100 -
  26.101 -  // mode independent information 
  26.102 -  int bitk;            // bits in bit buffer 
  26.103 -  int bitb;            // bit buffer 
  26.104 -  int[] hufts;         // single malloc for tree space 
  26.105 -  byte[] window;       // sliding window 
  26.106 -  int end;             // one byte after sliding window 
  26.107 -  int read;            // window read pointer 
  26.108 -  int write;           // window write pointer 
  26.109 -  private boolean check;
  26.110 -
  26.111 -  private final InfTree inftree=new InfTree();
  26.112 -
  26.113 -  private final ZStream z; 
  26.114 -
  26.115 -  InfBlocks(ZStream z, int w){
  26.116 -    this.z=z;
  26.117 -    this.codes=new InfCodes(this.z, this);
  26.118 -    hufts=new int[MANY*3];
  26.119 -    window=new byte[w];
  26.120 -    end=w;
  26.121 -    this.check = (z.istate.wrap==0) ? false : true;
  26.122 -    mode = TYPE;
  26.123 -    reset();
  26.124 -  }
  26.125 -
  26.126 -  void reset(){
  26.127 -    if(mode==BTREE || mode==DTREE){
  26.128 -    }
  26.129 -    if(mode==CODES){
  26.130 -      codes.free(z);
  26.131 -    }
  26.132 -    mode=TYPE;
  26.133 -    bitk=0;
  26.134 -    bitb=0;
  26.135 -    read=write=0;
  26.136 -    if(check){
  26.137 -      z.adler.reset();
  26.138 -    }
  26.139 -  }
  26.140 -
  26.141 -  int proc(int r){
  26.142 -    int t;              // temporary storage
  26.143 -    int b;              // bit buffer
  26.144 -    int k;              // bits in bit buffer
  26.145 -    int p;              // input data pointer
  26.146 -    int n;              // bytes available there
  26.147 -    int q;              // output window write pointer
  26.148 -    int m;              // bytes to end of window or read pointer
  26.149 -
  26.150 -    // copy input/output information to locals (UPDATE macro restores)
  26.151 -    {p=z.next_in_index;n=z.avail_in;b=bitb;k=bitk;}
  26.152 -    {q=write;m=(int)(q<read?read-q-1:end-q);}
  26.153 -
  26.154 -    // process input based on current state
  26.155 -    while(true){
  26.156 -      switch (mode){
  26.157 -      case TYPE:
  26.158 -
  26.159 -	while(k<(3)){
  26.160 -	  if(n!=0){
  26.161 -	    r=Z_OK;
  26.162 -	  }
  26.163 -	  else{
  26.164 -	    bitb=b; bitk=k; 
  26.165 -	    z.avail_in=n;
  26.166 -	    z.total_in+=p-z.next_in_index;z.next_in_index=p;
  26.167 -	    write=q;
  26.168 -	    return inflate_flush(r);
  26.169 -	  };
  26.170 -	  n--;
  26.171 -	  b|=(z.next_in[p++]&0xff)<<k;
  26.172 -	  k+=8;
  26.173 -	}
  26.174 -	t = (int)(b & 7);
  26.175 -	last = t & 1;
  26.176 -
  26.177 -	switch (t >>> 1){
  26.178 -        case 0:                         // stored 
  26.179 -          {b>>>=(3);k-=(3);}
  26.180 -          t = k & 7;                    // go to byte boundary
  26.181 -
  26.182 -          {b>>>=(t);k-=(t);}
  26.183 -          mode = LENS;                  // get length of stored block
  26.184 -          break;
  26.185 -        case 1:                         // fixed
  26.186 -          InfTree.inflate_trees_fixed(bl, bd, tl, td, z);
  26.187 -          codes.init(bl[0], bd[0], tl[0], 0, td[0], 0);
  26.188 -
  26.189 -          {b>>>=(3);k-=(3);}
  26.190 -
  26.191 -          mode = CODES;
  26.192 -          break;
  26.193 -        case 2:                         // dynamic
  26.194 -
  26.195 -          {b>>>=(3);k-=(3);}
  26.196 -
  26.197 -          mode = TABLE;
  26.198 -          break;
  26.199 -        case 3:                         // illegal
  26.200 -
  26.201 -          {b>>>=(3);k-=(3);}
  26.202 -          mode = BAD;
  26.203 -          z.msg = "invalid block type";
  26.204 -          r = Z_DATA_ERROR;
  26.205 -
  26.206 -	  bitb=b; bitk=k; 
  26.207 -	  z.avail_in=n;z.total_in+=p-z.next_in_index;z.next_in_index=p;
  26.208 -	  write=q;
  26.209 -	  return inflate_flush(r);
  26.210 -	}
  26.211 -	break;
  26.212 -      case LENS:
  26.213 -
  26.214 -	while(k<(32)){
  26.215 -	  if(n!=0){
  26.216 -	    r=Z_OK;
  26.217 -	  }
  26.218 -	  else{
  26.219 -	    bitb=b; bitk=k; 
  26.220 -	    z.avail_in=n;
  26.221 -	    z.total_in+=p-z.next_in_index;z.next_in_index=p;
  26.222 -	    write=q;
  26.223 -	    return inflate_flush(r);
  26.224 -	  };
  26.225 -	  n--;
  26.226 -	  b|=(z.next_in[p++]&0xff)<<k;
  26.227 -	  k+=8;
  26.228 -	}
  26.229 -
  26.230 -	if ((((~b) >>> 16) & 0xffff) != (b & 0xffff)){
  26.231 -	  mode = BAD;
  26.232 -	  z.msg = "invalid stored block lengths";
  26.233 -	  r = Z_DATA_ERROR;
  26.234 -
  26.235 -	  bitb=b; bitk=k; 
  26.236 -	  z.avail_in=n;z.total_in+=p-z.next_in_index;z.next_in_index=p;
  26.237 -	  write=q;
  26.238 -	  return inflate_flush(r);
  26.239 -	}
  26.240 -	left = (b & 0xffff);
  26.241 -	b = k = 0;                       // dump bits
  26.242 -	mode = left!=0 ? STORED : (last!=0 ? DRY : TYPE);
  26.243 -	break;
  26.244 -      case STORED:
  26.245 -	if (n == 0){
  26.246 -	  bitb=b; bitk=k; 
  26.247 -	  z.avail_in=n;z.total_in+=p-z.next_in_index;z.next_in_index=p;
  26.248 -	  write=q;
  26.249 -	  return inflate_flush(r);
  26.250 -	}
  26.251 -
  26.252 -	if(m==0){
  26.253 -	  if(q==end&&read!=0){
  26.254 -	    q=0; m=(int)(q<read?read-q-1:end-q);
  26.255 -	  }
  26.256 -	  if(m==0){
  26.257 -	    write=q; 
  26.258 -	    r=inflate_flush(r);
  26.259 -	    q=write;m=(int)(q<read?read-q-1:end-q);
  26.260 -	    if(q==end&&read!=0){
  26.261 -	      q=0; m=(int)(q<read?read-q-1:end-q);
  26.262 -	    }
  26.263 -	    if(m==0){
  26.264 -	      bitb=b; bitk=k; 
  26.265 -	      z.avail_in=n;z.total_in+=p-z.next_in_index;z.next_in_index=p;
  26.266 -	      write=q;
  26.267 -	      return inflate_flush(r);
  26.268 -	    }
  26.269 -	  }
  26.270 -	}
  26.271 -	r=Z_OK;
  26.272 -
  26.273 -	t = left;
  26.274 -	if(t>n) t = n;
  26.275 -	if(t>m) t = m;
  26.276 -	System.arraycopy(z.next_in, p, window, q, t);
  26.277 -	p += t;  n -= t;
  26.278 -	q += t;  m -= t;
  26.279 -	if ((left -= t) != 0)
  26.280 -	  break;
  26.281 -	mode = last!=0 ? DRY : TYPE;
  26.282 -	break;
  26.283 -      case TABLE:
  26.284 -
  26.285 -	while(k<(14)){
  26.286 -	  if(n!=0){
  26.287 -	    r=Z_OK;
  26.288 -	  }
  26.289 -	  else{
  26.290 -	    bitb=b; bitk=k; 
  26.291 -	    z.avail_in=n;
  26.292 -	    z.total_in+=p-z.next_in_index;z.next_in_index=p;
  26.293 -	    write=q;
  26.294 -	    return inflate_flush(r);
  26.295 -	  };
  26.296 -	  n--;
  26.297 -	  b|=(z.next_in[p++]&0xff)<<k;
  26.298 -	  k+=8;
  26.299 -	}
  26.300 -
  26.301 -	table = t = (b & 0x3fff);
  26.302 -	if ((t & 0x1f) > 29 || ((t >> 5) & 0x1f) > 29)
  26.303 -	  {
  26.304 -	    mode = BAD;
  26.305 -	    z.msg = "too many length or distance symbols";
  26.306 -	    r = Z_DATA_ERROR;
  26.307 -
  26.308 -	    bitb=b; bitk=k; 
  26.309 -	    z.avail_in=n;z.total_in+=p-z.next_in_index;z.next_in_index=p;
  26.310 -	    write=q;
  26.311 -	    return inflate_flush(r);
  26.312 -	  }
  26.313 -	t = 258 + (t & 0x1f) + ((t >> 5) & 0x1f);
  26.314 -	if(blens==null || blens.length<t){
  26.315 -	  blens=new int[t];
  26.316 -	}
  26.317 -	else{
  26.318 -	  for(int i=0; i<t; i++){blens[i]=0;}
  26.319 -	}
  26.320 -
  26.321 -	{b>>>=(14);k-=(14);}
  26.322 -
  26.323 -	index = 0;
  26.324 -	mode = BTREE;
  26.325 -      case BTREE:
  26.326 -	while (index < 4 + (table >>> 10)){
  26.327 -	  while(k<(3)){
  26.328 -	    if(n!=0){
  26.329 -	      r=Z_OK;
  26.330 -	    }
  26.331 -	    else{
  26.332 -	      bitb=b; bitk=k; 
  26.333 -	      z.avail_in=n;
  26.334 -	      z.total_in+=p-z.next_in_index;z.next_in_index=p;
  26.335 -	      write=q;
  26.336 -	      return inflate_flush(r);
  26.337 -	    };
  26.338 -	    n--;
  26.339 -	    b|=(z.next_in[p++]&0xff)<<k;
  26.340 -	    k+=8;
  26.341 -	  }
  26.342 -
  26.343 -	  blens[border[index++]] = b&7;
  26.344 -
  26.345 -	  {b>>>=(3);k-=(3);}
  26.346 -	}
  26.347 -
  26.348 -	while(index < 19){
  26.349 -	  blens[border[index++]] = 0;
  26.350 -	}
  26.351 -
  26.352 -	bb[0] = 7;
  26.353 -	t = inftree.inflate_trees_bits(blens, bb, tb, hufts, z);
  26.354 -	if (t != Z_OK){
  26.355 -	  r = t;
  26.356 -	  if (r == Z_DATA_ERROR){
  26.357 -	    blens=null;
  26.358 -	    mode = BAD;
  26.359 -	  }
  26.360 -
  26.361 -	  bitb=b; bitk=k; 
  26.362 -	  z.avail_in=n;z.total_in+=p-z.next_in_index;z.next_in_index=p;
  26.363 -	  write=q;
  26.364 -	  return inflate_flush(r);
  26.365 -	}
  26.366 -
  26.367 -	index = 0;
  26.368 -	mode = DTREE;
  26.369 -      case DTREE:
  26.370 -	while (true){
  26.371 -	  t = table;
  26.372 -	  if(!(index < 258 + (t & 0x1f) + ((t >> 5) & 0x1f))){
  26.373 -	    break;
  26.374 -	  }
  26.375 -
  26.376 -	  int[] h;
  26.377 -	  int i, j, c;
  26.378 -
  26.379 -	  t = bb[0];
  26.380 -
  26.381 -	  while(k<(t)){
  26.382 -	    if(n!=0){
  26.383 -	      r=Z_OK;
  26.384 -	    }
  26.385 -	    else{
  26.386 -	      bitb=b; bitk=k; 
  26.387 -	      z.avail_in=n;
  26.388 -	      z.total_in+=p-z.next_in_index;z.next_in_index=p;
  26.389 -	      write=q;
  26.390 -	      return inflate_flush(r);
  26.391 -	    };
  26.392 -	    n--;
  26.393 -	    b|=(z.next_in[p++]&0xff)<<k;
  26.394 -	    k+=8;
  26.395 -	  }
  26.396 -
  26.397 -	  if(tb[0]==-1){
  26.398 -            //System.err.println("null...");
  26.399 -	  }
  26.400 -
  26.401 -	  t=hufts[(tb[0]+(b&inflate_mask[t]))*3+1];
  26.402 -	  c=hufts[(tb[0]+(b&inflate_mask[t]))*3+2];
  26.403 -
  26.404 -	  if (c < 16){
  26.405 -	    b>>>=(t);k-=(t);
  26.406 -	    blens[index++] = c;
  26.407 -	  }
  26.408 -	  else { // c == 16..18
  26.409 -	    i = c == 18 ? 7 : c - 14;
  26.410 -	    j = c == 18 ? 11 : 3;
  26.411 -
  26.412 -	    while(k<(t+i)){
  26.413 -	      if(n!=0){
  26.414 -		r=Z_OK;
  26.415 -	      }
  26.416 -	      else{
  26.417 -		bitb=b; bitk=k; 
  26.418 -		z.avail_in=n;
  26.419 -		z.total_in+=p-z.next_in_index;z.next_in_index=p;
  26.420 -		write=q;
  26.421 -		return inflate_flush(r);
  26.422 -	      };
  26.423 -	      n--;
  26.424 -	      b|=(z.next_in[p++]&0xff)<<k;
  26.425 -	      k+=8;
  26.426 -	    }
  26.427 -
  26.428 -	    b>>>=(t);k-=(t);
  26.429 -
  26.430 -	    j += (b & inflate_mask[i]);
  26.431 -
  26.432 -	    b>>>=(i);k-=(i);
  26.433 -
  26.434 -	    i = index;
  26.435 -	    t = table;
  26.436 -	    if (i + j > 258 + (t & 0x1f) + ((t >> 5) & 0x1f) ||
  26.437 -		(c == 16 && i < 1)){
  26.438 -	      blens=null;
  26.439 -	      mode = BAD;
  26.440 -	      z.msg = "invalid bit length repeat";
  26.441 -	      r = Z_DATA_ERROR;
  26.442 -
  26.443 -	      bitb=b; bitk=k; 
  26.444 -	      z.avail_in=n;z.total_in+=p-z.next_in_index;z.next_in_index=p;
  26.445 -	      write=q;
  26.446 -	      return inflate_flush(r);
  26.447 -	    }
  26.448 -
  26.449 -	    c = c == 16 ? blens[i-1] : 0;
  26.450 -	    do{
  26.451 -	      blens[i++] = c;
  26.452 -	    }
  26.453 -	    while (--j!=0);
  26.454 -	    index = i;
  26.455 -	  }
  26.456 -	}
  26.457 -
  26.458 -	tb[0]=-1;
  26.459 -	{
  26.460 -	  bl[0] = 9;         // must be <= 9 for lookahead assumptions
  26.461 -	  bd[0] = 6;         // must be <= 9 for lookahead assumptions
  26.462 -	  t = table;
  26.463 -	  t = inftree.inflate_trees_dynamic(257 + (t & 0x1f), 
  26.464 -					    1 + ((t >> 5) & 0x1f),
  26.465 -					    blens, bl, bd, tli, tdi, hufts, z);
  26.466 -
  26.467 -	  if (t != Z_OK){
  26.468 -	    if (t == Z_DATA_ERROR){
  26.469 -	      blens=null;
  26.470 -	      mode = BAD;
  26.471 -	    }
  26.472 -	    r = t;
  26.473 -
  26.474 -	    bitb=b; bitk=k; 
  26.475 -	    z.avail_in=n;z.total_in+=p-z.next_in_index;z.next_in_index=p;
  26.476 -	    write=q;
  26.477 -	    return inflate_flush(r);
  26.478 -	  }
  26.479 -	  codes.init(bl[0], bd[0], hufts, tli[0], hufts, tdi[0]);
  26.480 -	}
  26.481 -	mode = CODES;
  26.482 -      case CODES:
  26.483 -	bitb=b; bitk=k;
  26.484 -	z.avail_in=n; z.total_in+=p-z.next_in_index;z.next_in_index=p;
  26.485 -	write=q;
  26.486 -
  26.487 -	if ((r = codes.proc(r)) != Z_STREAM_END){
  26.488 -	  return inflate_flush(r);
  26.489 -	}
  26.490 -	r = Z_OK;
  26.491 -	codes.free(z);
  26.492 -
  26.493 -	p=z.next_in_index; n=z.avail_in;b=bitb;k=bitk;
  26.494 -	q=write;m=(int)(q<read?read-q-1:end-q);
  26.495 -
  26.496 -	if (last==0){
  26.497 -	  mode = TYPE;
  26.498 -	  break;
  26.499 -	}
  26.500 -	mode = DRY;
  26.501 -      case DRY:
  26.502 -	write=q; 
  26.503 -	r=inflate_flush(r); 
  26.504 -	q=write; m=(int)(q<read?read-q-1:end-q);
  26.505 -	if (read != write){
  26.506 -	  bitb=b; bitk=k; 
  26.507 -	  z.avail_in=n;z.total_in+=p-z.next_in_index;z.next_in_index=p;
  26.508 -	  write=q;
  26.509 -	  return inflate_flush(r);
  26.510 -	}
  26.511 -	mode = DONE;
  26.512 -      case DONE:
  26.513 -	r = Z_STREAM_END;
  26.514 -
  26.515 -	bitb=b; bitk=k; 
  26.516 -	z.avail_in=n;z.total_in+=p-z.next_in_index;z.next_in_index=p;
  26.517 -	write=q;
  26.518 -	return inflate_flush(r);
  26.519 -      case BAD:
  26.520 -	r = Z_DATA_ERROR;
  26.521 -
  26.522 -	bitb=b; bitk=k; 
  26.523 -	z.avail_in=n;z.total_in+=p-z.next_in_index;z.next_in_index=p;
  26.524 -	write=q;
  26.525 -	return inflate_flush(r);
  26.526 -
  26.527 -      default:
  26.528 -	r = Z_STREAM_ERROR;
  26.529 -
  26.530 -	bitb=b; bitk=k; 
  26.531 -	z.avail_in=n;z.total_in+=p-z.next_in_index;z.next_in_index=p;
  26.532 -	write=q;
  26.533 -	return inflate_flush(r);
  26.534 -      }
  26.535 -    }
  26.536 -  }
  26.537 -
  26.538 -  void free(){
  26.539 -    reset();
  26.540 -    window=null;
  26.541 -    hufts=null;
  26.542 -    //ZFREE(z, s);
  26.543 -  }
  26.544 -
  26.545 -  void set_dictionary(byte[] d, int start, int n){
  26.546 -    System.arraycopy(d, start, window, 0, n);
  26.547 -    read = write = n;
  26.548 -  }
  26.549 -
  26.550 -  // Returns true if inflate is currently at the end of a block generated
  26.551 -  // by Z_SYNC_FLUSH or Z_FULL_FLUSH. 
  26.552 -  int sync_point(){
  26.553 -    return mode == LENS ? 1 : 0;
  26.554 -  }
  26.555 -
  26.556 -  // copy as much as possible from the sliding window to the output area
  26.557 -  int inflate_flush(int r){
  26.558 -    int n;
  26.559 -    int p;
  26.560 -    int q;
  26.561 -
  26.562 -    // local copies of source and destination pointers
  26.563 -    p = z.next_out_index;
  26.564 -    q = read;
  26.565 -
  26.566 -    // compute number of bytes to copy as far as end of window
  26.567 -    n = (int)((q <= write ? write : end) - q);
  26.568 -    if(n > z.avail_out) n = z.avail_out;
  26.569 -    if(n!=0 && r == Z_BUF_ERROR) r = Z_OK;
  26.570 -
  26.571 -    // update counters
  26.572 -    z.avail_out -= n;
  26.573 -    z.total_out += n;
  26.574 -
  26.575 -    // update check information
  26.576 -    if(check && n>0){
  26.577 -      z.adler.update(window, q, n);
  26.578 -    }
  26.579 -
  26.580 -    // copy as far as end of window
  26.581 -    System.arraycopy(window, q, z.next_out, p, n);
  26.582 -    p += n;
  26.583 -    q += n;
  26.584 -
  26.585 -    // see if more to copy at beginning of window
  26.586 -    if (q == end){
  26.587 -      // wrap pointers
  26.588 -      q = 0;
  26.589 -      if (write == end)
  26.590 -        write = 0;
  26.591 -
  26.592 -      // compute bytes to copy
  26.593 -      n = write - q;
  26.594 -      if (n > z.avail_out) n = z.avail_out;
  26.595 -      if (n!=0 && r == Z_BUF_ERROR) r = Z_OK;
  26.596 -
  26.597 -      // update counters
  26.598 -      z.avail_out -= n;
  26.599 -      z.total_out += n;
  26.600 -
  26.601 -      // update check information
  26.602 -      if(check && n>0){
  26.603 -	z.adler.update(window, q, n);
  26.604 -      }
  26.605 -
  26.606 -      // copy
  26.607 -      System.arraycopy(window, q, z.next_out, p, n);
  26.608 -      p += n;
  26.609 -      q += n;
  26.610 -    }
  26.611 -
  26.612 -    // update pointers
  26.613 -    z.next_out_index = p;
  26.614 -    read = q;
  26.615 -
  26.616 -    // done
  26.617 -    return r;
  26.618 -  }
  26.619 -}
    27.1 --- a/rt/emul/mini/src/main/java/org/apidesign/bck2brwsr/emul/zip/InfCodes.java	Wed May 07 11:55:06 2014 +0200
    27.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    27.3 @@ -1,612 +0,0 @@
    27.4 -/* -*-mode:java; c-basic-offset:2; -*- */
    27.5 -/*
    27.6 -Copyright (c) 2000,2001,2002,2003 ymnk, JCraft,Inc. All rights reserved.
    27.7 -
    27.8 -Redistribution and use in source and binary forms, with or without
    27.9 -modification, are permitted provided that the following conditions are met:
   27.10 -
   27.11 -  1. Redistributions of source code must retain the above copyright notice,
   27.12 -     this list of conditions and the following disclaimer.
   27.13 -
   27.14 -  2. Redistributions in binary form must reproduce the above copyright 
   27.15 -     notice, this list of conditions and the following disclaimer in 
   27.16 -     the documentation and/or other materials provided with the distribution.
   27.17 -
   27.18 -  3. The names of the authors may not be used to endorse or promote products
   27.19 -     derived from this software without specific prior written permission.
   27.20 -
   27.21 -THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
   27.22 -INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
   27.23 -FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
   27.24 -INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
   27.25 -INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   27.26 -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
   27.27 -OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
   27.28 -LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
   27.29 -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
   27.30 -EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
   27.31 - */
   27.32 -/*
   27.33 - * This program is based on zlib-1.1.3, so all credit should go authors
   27.34 - * Jean-loup Gailly(jloup@gzip.org) and Mark Adler(madler@alumni.caltech.edu)
   27.35 - * and contributors of zlib.
   27.36 - */
   27.37 -
   27.38 -package org.apidesign.bck2brwsr.emul.zip;
   27.39 -
   27.40 -import org.apidesign.bck2brwsr.emul.lang.System;
   27.41 -
   27.42 -final class InfCodes{
   27.43 -
   27.44 -  static final private int[] inflate_mask = {
   27.45 -    0x00000000, 0x00000001, 0x00000003, 0x00000007, 0x0000000f,
   27.46 -    0x0000001f, 0x0000003f, 0x0000007f, 0x000000ff, 0x000001ff,
   27.47 -    0x000003ff, 0x000007ff, 0x00000fff, 0x00001fff, 0x00003fff,
   27.48 -    0x00007fff, 0x0000ffff
   27.49 -  };
   27.50 -
   27.51 -  static final private int Z_OK=0;
   27.52 -  static final private int Z_STREAM_END=1;
   27.53 -  static final private int Z_NEED_DICT=2;
   27.54 -  static final private int Z_ERRNO=-1;
   27.55 -  static final private int Z_STREAM_ERROR=-2;
   27.56 -  static final private int Z_DATA_ERROR=-3;
   27.57 -  static final private int Z_MEM_ERROR=-4;
   27.58 -  static final private int Z_BUF_ERROR=-5;
   27.59 -  static final private int Z_VERSION_ERROR=-6;
   27.60 -
   27.61 -  // waiting for "i:"=input,
   27.62 -  //             "o:"=output,
   27.63 -  //             "x:"=nothing
   27.64 -  static final private int START=0;  // x: set up for LEN
   27.65 -  static final private int LEN=1;    // i: get length/literal/eob next
   27.66 -  static final private int LENEXT=2; // i: getting length extra (have base)
   27.67 -  static final private int DIST=3;   // i: get distance next
   27.68 -  static final private int DISTEXT=4;// i: getting distance extra
   27.69 -  static final private int COPY=5;   // o: copying bytes in window, waiting for space
   27.70 -  static final private int LIT=6;    // o: got literal, waiting for output space
   27.71 -  static final private int WASH=7;   // o: got eob, possibly still output waiting
   27.72 -  static final private int END=8;    // x: got eob and all data flushed
   27.73 -  static final private int BADCODE=9;// x: got error
   27.74 -
   27.75 -  int mode;      // current inflate_codes mode
   27.76 -
   27.77 -  // mode dependent information
   27.78 -  int len;
   27.79 -
   27.80 -  int[] tree; // pointer into tree
   27.81 -  int tree_index=0;
   27.82 -  int need;   // bits needed
   27.83 -
   27.84 -  int lit;
   27.85 -
   27.86 -  // if EXT or COPY, where and how much
   27.87 -  int get;              // bits to get for extra
   27.88 -  int dist;             // distance back to copy from
   27.89 -
   27.90 -  byte lbits;           // ltree bits decoded per branch
   27.91 -  byte dbits;           // dtree bits decoder per branch
   27.92 -  int[] ltree;          // literal/length/eob tree
   27.93 -  int ltree_index;      // literal/length/eob tree
   27.94 -  int[] dtree;          // distance tree
   27.95 -  int dtree_index;      // distance tree
   27.96 -
   27.97 -  private final ZStream z;
   27.98 -  private final InfBlocks s;
   27.99 -  InfCodes(ZStream z, InfBlocks s){
  27.100 -    this.z=z; 
  27.101 -    this.s=s; 
  27.102 -  }
  27.103 -
  27.104 -  void init(int bl, int bd,
  27.105 -	   int[] tl, int tl_index,
  27.106 -	   int[] td, int td_index){
  27.107 -    mode=START;
  27.108 -    lbits=(byte)bl;
  27.109 -    dbits=(byte)bd;
  27.110 -    ltree=tl;
  27.111 -    ltree_index=tl_index;
  27.112 -    dtree = td;
  27.113 -    dtree_index=td_index;
  27.114 -    tree=null;
  27.115 -  }
  27.116 -
  27.117 -  int proc(int r){ 
  27.118 -    int j;              // temporary storage
  27.119 -    int[] t;            // temporary pointer
  27.120 -    int tindex;         // temporary pointer
  27.121 -    int e;              // extra bits or operation
  27.122 -    int b=0;            // bit buffer
  27.123 -    int k=0;            // bits in bit buffer
  27.124 -    int p=0;            // input data pointer
  27.125 -    int n;              // bytes available there
  27.126 -    int q;              // output window write pointer
  27.127 -    int m;              // bytes to end of window or read pointer
  27.128 -    int f;              // pointer to copy strings from
  27.129 -
  27.130 -    // copy input/output information to locals (UPDATE macro restores)
  27.131 -    p=z.next_in_index;n=z.avail_in;b=s.bitb;k=s.bitk;
  27.132 -    q=s.write;m=q<s.read?s.read-q-1:s.end-q;
  27.133 -
  27.134 -    // process input and output based on current state
  27.135 -    while (true){
  27.136 -      switch (mode){
  27.137 -	// waiting for "i:"=input, "o:"=output, "x:"=nothing
  27.138 -      case START:         // x: set up for LEN
  27.139 -	if (m >= 258 && n >= 10){
  27.140 -
  27.141 -	  s.bitb=b;s.bitk=k;
  27.142 -	  z.avail_in=n;z.total_in+=p-z.next_in_index;z.next_in_index=p;
  27.143 -	  s.write=q;
  27.144 -	  r = inflate_fast(lbits, dbits, 
  27.145 -			   ltree, ltree_index, 
  27.146 -			   dtree, dtree_index,
  27.147 -			   s, z);
  27.148 -
  27.149 -	  p=z.next_in_index;n=z.avail_in;b=s.bitb;k=s.bitk;
  27.150 -	  q=s.write;m=q<s.read?s.read-q-1:s.end-q;
  27.151 -
  27.152 -	  if (r != Z_OK){
  27.153 -	    mode = r == Z_STREAM_END ? WASH : BADCODE;
  27.154 -	    break;
  27.155 -	  }
  27.156 -	}
  27.157 -	need = lbits;
  27.158 -	tree = ltree;
  27.159 -	tree_index=ltree_index;
  27.160 -
  27.161 -	mode = LEN;
  27.162 -      case LEN:           // i: get length/literal/eob next
  27.163 -	j = need;
  27.164 -
  27.165 -	while(k<(j)){
  27.166 -	  if(n!=0)r=Z_OK;
  27.167 -	  else{
  27.168 -
  27.169 -	    s.bitb=b;s.bitk=k;
  27.170 -	    z.avail_in=n;z.total_in+=p-z.next_in_index;z.next_in_index=p;
  27.171 -	    s.write=q;
  27.172 -	    return s.inflate_flush(r);
  27.173 -	  }
  27.174 -	  n--;
  27.175 -	  b|=(z.next_in[p++]&0xff)<<k;
  27.176 -	  k+=8;
  27.177 -	}
  27.178 -
  27.179 -	tindex=(tree_index+(b&inflate_mask[j]))*3;
  27.180 -
  27.181 -	b>>>=(tree[tindex+1]);
  27.182 -	k-=(tree[tindex+1]);
  27.183 -
  27.184 -	e=tree[tindex];
  27.185 -
  27.186 -	if(e == 0){               // literal
  27.187 -	  lit = tree[tindex+2];
  27.188 -	  mode = LIT;
  27.189 -	  break;
  27.190 -	}
  27.191 -	if((e & 16)!=0 ){          // length
  27.192 -	  get = e & 15;
  27.193 -	  len = tree[tindex+2];
  27.194 -	  mode = LENEXT;
  27.195 -	  break;
  27.196 -	}
  27.197 -	if ((e & 64) == 0){        // next table
  27.198 -	  need = e;
  27.199 -	  tree_index = tindex/3+tree[tindex+2];
  27.200 -	  break;
  27.201 -	}
  27.202 -	if ((e & 32)!=0){               // end of block
  27.203 -	  mode = WASH;
  27.204 -	  break;
  27.205 -	}
  27.206 -	mode = BADCODE;        // invalid code
  27.207 -	z.msg = "invalid literal/length code";
  27.208 -	r = Z_DATA_ERROR;
  27.209 -
  27.210 -	s.bitb=b;s.bitk=k;
  27.211 -	z.avail_in=n;z.total_in+=p-z.next_in_index;z.next_in_index=p;
  27.212 -	s.write=q;
  27.213 -	return s.inflate_flush(r);
  27.214 -
  27.215 -      case LENEXT:        // i: getting length extra (have base)
  27.216 -	j = get;
  27.217 -
  27.218 -	while(k<(j)){
  27.219 -	  if(n!=0)r=Z_OK;
  27.220 -	  else{
  27.221 -
  27.222 -	    s.bitb=b;s.bitk=k;
  27.223 -	    z.avail_in=n;z.total_in+=p-z.next_in_index;z.next_in_index=p;
  27.224 -	    s.write=q;
  27.225 -	    return s.inflate_flush(r);
  27.226 -	  }
  27.227 -	  n--; b|=(z.next_in[p++]&0xff)<<k;
  27.228 -	  k+=8;
  27.229 -	}
  27.230 -
  27.231 -	len += (b & inflate_mask[j]);
  27.232 -
  27.233 -	b>>=j;
  27.234 -	k-=j;
  27.235 -
  27.236 -	need = dbits;
  27.237 -	tree = dtree;
  27.238 -	tree_index=dtree_index;
  27.239 -	mode = DIST;
  27.240 -      case DIST:          // i: get distance next
  27.241 -	j = need;
  27.242 -
  27.243 -	while(k<(j)){
  27.244 -	  if(n!=0)r=Z_OK;
  27.245 -	  else{
  27.246 -
  27.247 -	    s.bitb=b;s.bitk=k;
  27.248 -	    z.avail_in=n;z.total_in+=p-z.next_in_index;z.next_in_index=p;
  27.249 -	    s.write=q;
  27.250 -	    return s.inflate_flush(r);
  27.251 -	  }
  27.252 -	  n--; b|=(z.next_in[p++]&0xff)<<k;
  27.253 -	  k+=8;
  27.254 -	}
  27.255 -
  27.256 -	tindex=(tree_index+(b & inflate_mask[j]))*3;
  27.257 -
  27.258 -	b>>=tree[tindex+1];
  27.259 -	k-=tree[tindex+1];
  27.260 -
  27.261 -	e = (tree[tindex]);
  27.262 -	if((e & 16)!=0){               // distance
  27.263 -	  get = e & 15;
  27.264 -	  dist = tree[tindex+2];
  27.265 -	  mode = DISTEXT;
  27.266 -	  break;
  27.267 -	}
  27.268 -	if ((e & 64) == 0){        // next table
  27.269 -	  need = e;
  27.270 -	  tree_index = tindex/3 + tree[tindex+2];
  27.271 -	  break;
  27.272 -	}
  27.273 -	mode = BADCODE;        // invalid code
  27.274 -	z.msg = "invalid distance code";
  27.275 -	r = Z_DATA_ERROR;
  27.276 -
  27.277 -	s.bitb=b;s.bitk=k;
  27.278 -	z.avail_in=n;z.total_in+=p-z.next_in_index;z.next_in_index=p;
  27.279 -	s.write=q;
  27.280 -	return s.inflate_flush(r);
  27.281 -
  27.282 -      case DISTEXT:       // i: getting distance extra
  27.283 -	j = get;
  27.284 -
  27.285 -	while(k<(j)){
  27.286 -	  if(n!=0)r=Z_OK;
  27.287 -	  else{
  27.288 -
  27.289 -	    s.bitb=b;s.bitk=k;
  27.290 -	    z.avail_in=n;z.total_in+=p-z.next_in_index;z.next_in_index=p;
  27.291 -	    s.write=q;
  27.292 -	    return s.inflate_flush(r);
  27.293 -	  }
  27.294 -	  n--; b|=(z.next_in[p++]&0xff)<<k;
  27.295 -	  k+=8;
  27.296 -	}
  27.297 -
  27.298 -	dist += (b & inflate_mask[j]);
  27.299 -
  27.300 -	b>>=j;
  27.301 -	k-=j;
  27.302 -
  27.303 -	mode = COPY;
  27.304 -      case COPY:          // o: copying bytes in window, waiting for space
  27.305 -        f = q - dist;
  27.306 -        while(f < 0){     // modulo window size-"while" instead
  27.307 -          f += s.end;     // of "if" handles invalid distances
  27.308 -	}
  27.309 -	while (len!=0){
  27.310 -
  27.311 -	  if(m==0){
  27.312 -	    if(q==s.end&&s.read!=0){q=0;m=q<s.read?s.read-q-1:s.end-q;}
  27.313 -	    if(m==0){
  27.314 -	      s.write=q; r=s.inflate_flush(r);
  27.315 -	      q=s.write;m=q<s.read?s.read-q-1:s.end-q;
  27.316 -
  27.317 -	      if(q==s.end&&s.read!=0){q=0;m=q<s.read?s.read-q-1:s.end-q;}
  27.318 -
  27.319 -	      if(m==0){
  27.320 -		s.bitb=b;s.bitk=k;
  27.321 -		z.avail_in=n;z.total_in+=p-z.next_in_index;z.next_in_index=p;
  27.322 -		s.write=q;
  27.323 -		return s.inflate_flush(r);
  27.324 -	      }  
  27.325 -	    }
  27.326 -	  }
  27.327 -
  27.328 -	  s.window[q++]=s.window[f++]; m--;
  27.329 -
  27.330 -	  if (f == s.end)
  27.331 -            f = 0;
  27.332 -	  len--;
  27.333 -	}
  27.334 -	mode = START;
  27.335 -	break;
  27.336 -      case LIT:           // o: got literal, waiting for output space
  27.337 -	if(m==0){
  27.338 -	  if(q==s.end&&s.read!=0){q=0;m=q<s.read?s.read-q-1:s.end-q;}
  27.339 -	  if(m==0){
  27.340 -	    s.write=q; r=s.inflate_flush(r);
  27.341 -	    q=s.write;m=q<s.read?s.read-q-1:s.end-q;
  27.342 -
  27.343 -	    if(q==s.end&&s.read!=0){q=0;m=q<s.read?s.read-q-1:s.end-q;}
  27.344 -	    if(m==0){
  27.345 -	      s.bitb=b;s.bitk=k;
  27.346 -	      z.avail_in=n;z.total_in+=p-z.next_in_index;z.next_in_index=p;
  27.347 -	      s.write=q;
  27.348 -	      return s.inflate_flush(r);
  27.349 -	    }
  27.350 -	  }
  27.351 -	}
  27.352 -	r=Z_OK;
  27.353 -
  27.354 -	s.window[q++]=(byte)lit; m--;
  27.355 -
  27.356 -	mode = START;
  27.357 -	break;
  27.358 -      case WASH:           // o: got eob, possibly more output
  27.359 -	if (k > 7){        // return unused byte, if any
  27.360 -	  k -= 8;
  27.361 -	  n++;
  27.362 -	  p--;             // can always return one
  27.363 -	}
  27.364 -
  27.365 -	s.write=q; r=s.inflate_flush(r);
  27.366 -	q=s.write;m=q<s.read?s.read-q-1:s.end-q;
  27.367 -
  27.368 -	if (s.read != s.write){
  27.369 -	  s.bitb=b;s.bitk=k;
  27.370 -	  z.avail_in=n;z.total_in+=p-z.next_in_index;z.next_in_index=p;
  27.371 -	  s.write=q;
  27.372 -	  return s.inflate_flush(r);
  27.373 -	}
  27.374 -	mode = END;
  27.375 -      case END:
  27.376 -	r = Z_STREAM_END;
  27.377 -	s.bitb=b;s.bitk=k;
  27.378 -	z.avail_in=n;z.total_in+=p-z.next_in_index;z.next_in_index=p;
  27.379 -	s.write=q;
  27.380 -	return s.inflate_flush(r);
  27.381 -
  27.382 -      case BADCODE:       // x: got error
  27.383 -
  27.384 -	r = Z_DATA_ERROR;
  27.385 -
  27.386 -	s.bitb=b;s.bitk=k;
  27.387 -	z.avail_in=n;z.total_in+=p-z.next_in_index;z.next_in_index=p;
  27.388 -	s.write=q;
  27.389 -	return s.inflate_flush(r);
  27.390 -
  27.391 -      default:
  27.392 -	r = Z_STREAM_ERROR;
  27.393 -
  27.394 -	s.bitb=b;s.bitk=k;
  27.395 -	z.avail_in=n;z.total_in+=p-z.next_in_index;z.next_in_index=p;
  27.396 -	s.write=q;
  27.397 -	return s.inflate_flush(r);
  27.398 -      }
  27.399 -    }
  27.400 -  }
  27.401 -
  27.402 -  void free(ZStream z){
  27.403 -    //  ZFREE(z, c);
  27.404 -  }
  27.405 -
  27.406 -  // Called with number of bytes left to write in window at least 258
  27.407 -  // (the maximum string length) and number of input bytes available
  27.408 -  // at least ten.  The ten bytes are six bytes for the longest length/
  27.409 -  // distance pair plus four bytes for overloading the bit buffer.
  27.410 -
  27.411 -  int inflate_fast(int bl, int bd, 
  27.412 -		   int[] tl, int tl_index,
  27.413 -		   int[] td, int td_index,
  27.414 -		   InfBlocks s, ZStream z){
  27.415 -    int t;                // temporary pointer
  27.416 -    int[] tp;             // temporary pointer
  27.417 -    int tp_index;         // temporary pointer
  27.418 -    int e;                // extra bits or operation
  27.419 -    int b;                // bit buffer
  27.420 -    int k;                // bits in bit buffer
  27.421 -    int p;                // input data pointer
  27.422 -    int n;                // bytes available there
  27.423 -    int q;                // output window write pointer
  27.424 -    int m;                // bytes to end of window or read pointer
  27.425 -    int ml;               // mask for literal/length tree
  27.426 -    int md;               // mask for distance tree
  27.427 -    int c;                // bytes to copy
  27.428 -    int d;                // distance back to copy from
  27.429 -    int r;                // copy source pointer
  27.430 -
  27.431 -    int tp_index_t_3;     // (tp_index+t)*3
  27.432 -
  27.433 -    // load input, output, bit values
  27.434 -    p=z.next_in_index;n=z.avail_in;b=s.bitb;k=s.bitk;
  27.435 -    q=s.write;m=q<s.read?s.read-q-1:s.end-q;
  27.436 -
  27.437 -    // initialize masks
  27.438 -    ml = inflate_mask[bl];
  27.439 -    md = inflate_mask[bd];
  27.440 -
  27.441 -    // do until not enough input or output space for fast loop
  27.442 -    do {                          // assume called with m >= 258 && n >= 10
  27.443 -      // get literal/length code
  27.444 -      while(k<(20)){              // max bits for literal/length code
  27.445 -	n--;
  27.446 -	b|=(z.next_in[p++]&0xff)<<k;k+=8;
  27.447 -      }
  27.448 -
  27.449 -      t= b&ml;
  27.450 -      tp=tl; 
  27.451 -      tp_index=tl_index;
  27.452 -      tp_index_t_3=(tp_index+t)*3;
  27.453 -      if ((e = tp[tp_index_t_3]) == 0){
  27.454 -	b>>=(tp[tp_index_t_3+1]); k-=(tp[tp_index_t_3+1]);
  27.455 -
  27.456 -	s.window[q++] = (byte)tp[tp_index_t_3+2];
  27.457 -	m--;
  27.458 -	continue;
  27.459 -      }
  27.460 -      do {
  27.461 -
  27.462 -	b>>=(tp[tp_index_t_3+1]); k-=(tp[tp_index_t_3+1]);
  27.463 -
  27.464 -	if((e&16)!=0){
  27.465 -	  e &= 15;
  27.466 -	  c = tp[tp_index_t_3+2] + ((int)b & inflate_mask[e]);
  27.467 -
  27.468 -	  b>>=e; k-=e;
  27.469 -
  27.470 -	  // decode distance base of block to copy
  27.471 -	  while(k<(15)){           // max bits for distance code
  27.472 -	    n--;
  27.473 -	    b|=(z.next_in[p++]&0xff)<<k;k+=8;
  27.474 -	  }
  27.475 -
  27.476 -	  t= b&md;
  27.477 -	  tp=td;
  27.478 -	  tp_index=td_index;
  27.479 -          tp_index_t_3=(tp_index+t)*3;
  27.480 -	  e = tp[tp_index_t_3];
  27.481 -
  27.482 -	  do {
  27.483 -
  27.484 -	    b>>=(tp[tp_index_t_3+1]); k-=(tp[tp_index_t_3+1]);
  27.485 -
  27.486 -	    if((e&16)!=0){
  27.487 -	      // get extra bits to add to distance base
  27.488 -	      e &= 15;
  27.489 -	      while(k<(e)){         // get extra bits (up to 13)
  27.490 -		n--;
  27.491 -		b|=(z.next_in[p++]&0xff)<<k;k+=8;
  27.492 -	      }
  27.493 -
  27.494 -	      d = tp[tp_index_t_3+2] + (b&inflate_mask[e]);
  27.495 -
  27.496 -	      b>>=(e); k-=(e);
  27.497 -
  27.498 -	      // do the copy
  27.499 -	      m -= c;
  27.500 -	      if (q >= d){                // offset before dest
  27.501 -		//  just copy
  27.502 -		r=q-d;
  27.503 -		if(q-r>0 && 2>(q-r)){           
  27.504 -		  s.window[q++]=s.window[r++]; // minimum count is three,
  27.505 -		  s.window[q++]=s.window[r++]; // so unroll loop a little
  27.506 -		  c-=2;
  27.507 -		}
  27.508 -		else{
  27.509 -		  System.arraycopy(s.window, r, s.window, q, 2);
  27.510 -		  q+=2; r+=2; c-=2;
  27.511 -		}
  27.512 -	      }
  27.513 -	      else{                  // else offset after destination
  27.514 -                r=q-d;
  27.515 -                do{
  27.516 -                  r+=s.end;          // force pointer in window
  27.517 -                }while(r<0);         // covers invalid distances
  27.518 -		e=s.end-r;
  27.519 -		if(c>e){             // if source crosses,
  27.520 -		  c-=e;              // wrapped copy
  27.521 -		  if(q-r>0 && e>(q-r)){           
  27.522 -		    do{s.window[q++] = s.window[r++];}
  27.523 -		    while(--e!=0);
  27.524 -		  }
  27.525 -		  else{
  27.526 -		    System.arraycopy(s.window, r, s.window, q, e);
  27.527 -		    q+=e; r+=e; e=0;
  27.528 -		  }
  27.529 -		  r = 0;                  // copy rest from start of window
  27.530 -		}
  27.531 -
  27.532 -	      }
  27.533 -
  27.534 -	      // copy all or what's left
  27.535 -	      if(q-r>0 && c>(q-r)){           
  27.536 -		do{s.window[q++] = s.window[r++];}
  27.537 -		while(--c!=0);
  27.538 -	      }
  27.539 -	      else{
  27.540 -		System.arraycopy(s.window, r, s.window, q, c);
  27.541 -		q+=c; r+=c; c=0;
  27.542 -	      }
  27.543 -	      break;
  27.544 -	    }
  27.545 -	    else if((e&64)==0){
  27.546 -	      t+=tp[tp_index_t_3+2];
  27.547 -	      t+=(b&inflate_mask[e]);
  27.548 -	      tp_index_t_3=(tp_index+t)*3;
  27.549 -	      e=tp[tp_index_t_3];
  27.550 -	    }
  27.551 -	    else{
  27.552 -	      z.msg = "invalid distance code";
  27.553 -
  27.554 -	      c=z.avail_in-n;c=(k>>3)<c?k>>3:c;n+=c;p-=c;k-=c<<3;
  27.555 -
  27.556 -	      s.bitb=b;s.bitk=k;
  27.557 -	      z.avail_in=n;z.total_in+=p-z.next_in_index;z.next_in_index=p;
  27.558 -	      s.write=q;
  27.559 -
  27.560 -	      return Z_DATA_ERROR;
  27.561 -	    }
  27.562 -	  }
  27.563 -	  while(true);
  27.564 -	  break;
  27.565 -	}
  27.566 -
  27.567 -	if((e&64)==0){
  27.568 -	  t+=tp[tp_index_t_3+2];
  27.569 -	  t+=(b&inflate_mask[e]);
  27.570 -	  tp_index_t_3=(tp_index+t)*3;
  27.571 -	  if((e=tp[tp_index_t_3])==0){
  27.572 -
  27.573 -	    b>>=(tp[tp_index_t_3+1]); k-=(tp[tp_index_t_3+1]);
  27.574 -
  27.575 -	    s.window[q++]=(byte)tp[tp_index_t_3+2];
  27.576 -	    m--;
  27.577 -	    break;
  27.578 -	  }
  27.579 -	}
  27.580 -	else if((e&32)!=0){
  27.581 -
  27.582 -	  c=z.avail_in-n;c=(k>>3)<c?k>>3:c;n+=c;p-=c;k-=c<<3;
  27.583 - 
  27.584 -	  s.bitb=b;s.bitk=k;
  27.585 -	  z.avail_in=n;z.total_in+=p-z.next_in_index;z.next_in_index=p;
  27.586 -	  s.write=q;
  27.587 -
  27.588 -	  return Z_STREAM_END;
  27.589 -	}
  27.590 -	else{
  27.591 -	  z.msg="invalid literal/length code";
  27.592 -
  27.593 -	  c=z.avail_in-n;c=(k>>3)<c?k>>3:c;n+=c;p-=c;k-=c<<3;
  27.594 -
  27.595 -	  s.bitb=b;s.bitk=k;
  27.596 -	  z.avail_in=n;z.total_in+=p-z.next_in_index;z.next_in_index=p;
  27.597 -	  s.write=q;
  27.598 -
  27.599 -	  return Z_DATA_ERROR;
  27.600 -	}
  27.601 -      } 
  27.602 -      while(true);
  27.603 -    } 
  27.604 -    while(m>=258 && n>= 10);
  27.605 -
  27.606 -    // not enough input or output--restore pointers and return
  27.607 -    c=z.avail_in-n;c=(k>>3)<c?k>>3:c;n+=c;p-=c;k-=c<<3;
  27.608 -
  27.609 -    s.bitb=b;s.bitk=k;
  27.610 -    z.avail_in=n;z.total_in+=p-z.next_in_index;z.next_in_index=p;
  27.611 -    s.write=q;
  27.612 -
  27.613 -    return Z_OK;
  27.614 -  }
  27.615 -}
    28.1 --- a/rt/emul/mini/src/main/java/org/apidesign/bck2brwsr/emul/zip/InfTree.java	Wed May 07 11:55:06 2014 +0200
    28.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    28.3 @@ -1,520 +0,0 @@
    28.4 -/* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */
    28.5 -/*
    28.6 -Copyright (c) 2000,2001,2002,2003 ymnk, JCraft,Inc. All rights reserved.
    28.7 -
    28.8 -Redistribution and use in source and binary forms, with or without
    28.9 -modification, are permitted provided that the following conditions are met:
   28.10 -
   28.11 -  1. Redistributions of source code must retain the above copyright notice,
   28.12 -     this list of conditions and the following disclaimer.
   28.13 -
   28.14 -  2. Redistributions in binary form must reproduce the above copyright 
   28.15 -     notice, this list of conditions and the following disclaimer in 
   28.16 -     the documentation and/or other materials provided with the distribution.
   28.17 -
   28.18 -  3. The names of the authors may not be used to endorse or promote products
   28.19 -     derived from this software without specific prior written permission.
   28.20 -
   28.21 -THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
   28.22 -INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
   28.23 -FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
   28.24 -INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
   28.25 -INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   28.26 -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
   28.27 -OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
   28.28 -LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
   28.29 -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
   28.30 -EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
   28.31 - */
   28.32 -/*
   28.33 - * This program is based on zlib-1.1.3, so all credit should go authors
   28.34 - * Jean-loup Gailly(jloup@gzip.org) and Mark Adler(madler@alumni.caltech.edu)
   28.35 - * and contributors of zlib.
   28.36 - */
   28.37 -
   28.38 -package org.apidesign.bck2brwsr.emul.zip;
   28.39 -
   28.40 -import org.apidesign.bck2brwsr.emul.lang.System;
   28.41 -
   28.42 -final class InfTree{
   28.43 -
   28.44 -  static final private int MANY=1440;
   28.45 -
   28.46 -  static final private int Z_OK=0;
   28.47 -  static final private int Z_STREAM_END=1;
   28.48 -  static final private int Z_NEED_DICT=2;
   28.49 -  static final private int Z_ERRNO=-1;
   28.50 -  static final private int Z_STREAM_ERROR=-2;
   28.51 -  static final private int Z_DATA_ERROR=-3;
   28.52 -  static final private int Z_MEM_ERROR=-4;
   28.53 -  static final private int Z_BUF_ERROR=-5;
   28.54 -  static final private int Z_VERSION_ERROR=-6;
   28.55 -
   28.56 -  static final int fixed_bl = 9;
   28.57 -  static final int fixed_bd = 5;
   28.58 -
   28.59 -  static final int[] fixed_tl = {
   28.60 -    96,7,256, 0,8,80, 0,8,16, 84,8,115,
   28.61 -    82,7,31, 0,8,112, 0,8,48, 0,9,192,
   28.62 -    80,7,10, 0,8,96, 0,8,32, 0,9,160,
   28.63 -    0,8,0, 0,8,128, 0,8,64, 0,9,224,
   28.64 -    80,7,6, 0,8,88, 0,8,24, 0,9,144,
   28.65 -    83,7,59, 0,8,120, 0,8,56, 0,9,208,
   28.66 -    81,7,17, 0,8,104, 0,8,40, 0,9,176,
   28.67 -    0,8,8, 0,8,136, 0,8,72, 0,9,240,
   28.68 -    80,7,4, 0,8,84, 0,8,20, 85,8,227,
   28.69 -    83,7,43, 0,8,116, 0,8,52, 0,9,200,
   28.70 -    81,7,13, 0,8,100, 0,8,36, 0,9,168,
   28.71 -    0,8,4, 0,8,132, 0,8,68, 0,9,232,
   28.72 -    80,7,8, 0,8,92, 0,8,28, 0,9,152,
   28.73 -    84,7,83, 0,8,124, 0,8,60, 0,9,216,
   28.74 -    82,7,23, 0,8,108, 0,8,44, 0,9,184,
   28.75 -    0,8,12, 0,8,140, 0,8,76, 0,9,248,
   28.76 -    80,7,3, 0,8,82, 0,8,18, 85,8,163,
   28.77 -    83,7,35, 0,8,114, 0,8,50, 0,9,196,
   28.78 -    81,7,11, 0,8,98, 0,8,34, 0,9,164,
   28.79 -    0,8,2, 0,8,130, 0,8,66, 0,9,228,
   28.80 -    80,7,7, 0,8,90, 0,8,26, 0,9,148,
   28.81 -    84,7,67, 0,8,122, 0,8,58, 0,9,212,
   28.82 -    82,7,19, 0,8,106, 0,8,42, 0,9,180,
   28.83 -    0,8,10, 0,8,138, 0,8,74, 0,9,244,
   28.84 -    80,7,5, 0,8,86, 0,8,22, 192,8,0,
   28.85 -    83,7,51, 0,8,118, 0,8,54, 0,9,204,
   28.86 -    81,7,15, 0,8,102, 0,8,38, 0,9,172,
   28.87 -    0,8,6, 0,8,134, 0,8,70, 0,9,236,
   28.88 -    80,7,9, 0,8,94, 0,8,30, 0,9,156,
   28.89 -    84,7,99, 0,8,126, 0,8,62, 0,9,220,
   28.90 -    82,7,27, 0,8,110, 0,8,46, 0,9,188,
   28.91 -    0,8,14, 0,8,142, 0,8,78, 0,9,252,
   28.92 -    96,7,256, 0,8,81, 0,8,17, 85,8,131,
   28.93 -    82,7,31, 0,8,113, 0,8,49, 0,9,194,
   28.94 -    80,7,10, 0,8,97, 0,8,33, 0,9,162,
   28.95 -    0,8,1, 0,8,129, 0,8,65, 0,9,226,
   28.96 -    80,7,6, 0,8,89, 0,8,25, 0,9,146,
   28.97 -    83,7,59, 0,8,121, 0,8,57, 0,9,210,
   28.98 -    81,7,17, 0,8,105, 0,8,41, 0,9,178,
   28.99 -    0,8,9, 0,8,137, 0,8,73, 0,9,242,
  28.100 -    80,7,4, 0,8,85, 0,8,21, 80,8,258,
  28.101 -    83,7,43, 0,8,117, 0,8,53, 0,9,202,
  28.102 -    81,7,13, 0,8,101, 0,8,37, 0,9,170,
  28.103 -    0,8,5, 0,8,133, 0,8,69, 0,9,234,
  28.104 -    80,7,8, 0,8,93, 0,8,29, 0,9,154,
  28.105 -    84,7,83, 0,8,125, 0,8,61, 0,9,218,
  28.106 -    82,7,23, 0,8,109, 0,8,45, 0,9,186,
  28.107 -    0,8,13, 0,8,141, 0,8,77, 0,9,250,
  28.108 -    80,7,3, 0,8,83, 0,8,19, 85,8,195,
  28.109 -    83,7,35, 0,8,115, 0,8,51, 0,9,198,
  28.110 -    81,7,11, 0,8,99, 0,8,35, 0,9,166,
  28.111 -    0,8,3, 0,8,131, 0,8,67, 0,9,230,
  28.112 -    80,7,7, 0,8,91, 0,8,27, 0,9,150,
  28.113 -    84,7,67, 0,8,123, 0,8,59, 0,9,214,
  28.114 -    82,7,19, 0,8,107, 0,8,43, 0,9,182,
  28.115 -    0,8,11, 0,8,139, 0,8,75, 0,9,246,
  28.116 -    80,7,5, 0,8,87, 0,8,23, 192,8,0,
  28.117 -    83,7,51, 0,8,119, 0,8,55, 0,9,206,
  28.118 -    81,7,15, 0,8,103, 0,8,39, 0,9,174,
  28.119 -    0,8,7, 0,8,135, 0,8,71, 0,9,238,
  28.120 -    80,7,9, 0,8,95, 0,8,31, 0,9,158,
  28.121 -    84,7,99, 0,8,127, 0,8,63, 0,9,222,
  28.122 -    82,7,27, 0,8,111, 0,8,47, 0,9,190,
  28.123 -    0,8,15, 0,8,143, 0,8,79, 0,9,254,
  28.124 -    96,7,256, 0,8,80, 0,8,16, 84,8,115,
  28.125 -    82,7,31, 0,8,112, 0,8,48, 0,9,193,
  28.126 -
  28.127 -    80,7,10, 0,8,96, 0,8,32, 0,9,161,
  28.128 -    0,8,0, 0,8,128, 0,8,64, 0,9,225,
  28.129 -    80,7,6, 0,8,88, 0,8,24, 0,9,145,
  28.130 -    83,7,59, 0,8,120, 0,8,56, 0,9,209,
  28.131 -    81,7,17, 0,8,104, 0,8,40, 0,9,177,
  28.132 -    0,8,8, 0,8,136, 0,8,72, 0,9,241,
  28.133 -    80,7,4, 0,8,84, 0,8,20, 85,8,227,
  28.134 -    83,7,43, 0,8,116, 0,8,52, 0,9,201,
  28.135 -    81,7,13, 0,8,100, 0,8,36, 0,9,169,
  28.136 -    0,8,4, 0,8,132, 0,8,68, 0,9,233,
  28.137 -    80,7,8, 0,8,92, 0,8,28, 0,9,153,
  28.138 -    84,7,83, 0,8,124, 0,8,60, 0,9,217,
  28.139 -    82,7,23, 0,8,108, 0,8,44, 0,9,185,
  28.140 -    0,8,12, 0,8,140, 0,8,76, 0,9,249,
  28.141 -    80,7,3, 0,8,82, 0,8,18, 85,8,163,
  28.142 -    83,7,35, 0,8,114, 0,8,50, 0,9,197,
  28.143 -    81,7,11, 0,8,98, 0,8,34, 0,9,165,
  28.144 -    0,8,2, 0,8,130, 0,8,66, 0,9,229,
  28.145 -    80,7,7, 0,8,90, 0,8,26, 0,9,149,
  28.146 -    84,7,67, 0,8,122, 0,8,58, 0,9,213,
  28.147 -    82,7,19, 0,8,106, 0,8,42, 0,9,181,
  28.148 -    0,8,10, 0,8,138, 0,8,74, 0,9,245,
  28.149 -    80,7,5, 0,8,86, 0,8,22, 192,8,0,
  28.150 -    83,7,51, 0,8,118, 0,8,54, 0,9,205,
  28.151 -    81,7,15, 0,8,102, 0,8,38, 0,9,173,
  28.152 -    0,8,6, 0,8,134, 0,8,70, 0,9,237,
  28.153 -    80,7,9, 0,8,94, 0,8,30, 0,9,157,
  28.154 -    84,7,99, 0,8,126, 0,8,62, 0,9,221,
  28.155 -    82,7,27, 0,8,110, 0,8,46, 0,9,189,
  28.156 -    0,8,14, 0,8,142, 0,8,78, 0,9,253,
  28.157 -    96,7,256, 0,8,81, 0,8,17, 85,8,131,
  28.158 -    82,7,31, 0,8,113, 0,8,49, 0,9,195,
  28.159 -    80,7,10, 0,8,97, 0,8,33, 0,9,163,
  28.160 -    0,8,1, 0,8,129, 0,8,65, 0,9,227,
  28.161 -    80,7,6, 0,8,89, 0,8,25, 0,9,147,
  28.162 -    83,7,59, 0,8,121, 0,8,57, 0,9,211,
  28.163 -    81,7,17, 0,8,105, 0,8,41, 0,9,179,
  28.164 -    0,8,9, 0,8,137, 0,8,73, 0,9,243,
  28.165 -    80,7,4, 0,8,85, 0,8,21, 80,8,258,
  28.166 -    83,7,43, 0,8,117, 0,8,53, 0,9,203,
  28.167 -    81,7,13, 0,8,101, 0,8,37, 0,9,171,
  28.168 -    0,8,5, 0,8,133, 0,8,69, 0,9,235,
  28.169 -    80,7,8, 0,8,93, 0,8,29, 0,9,155,
  28.170 -    84,7,83, 0,8,125, 0,8,61, 0,9,219,
  28.171 -    82,7,23, 0,8,109, 0,8,45, 0,9,187,
  28.172 -    0,8,13, 0,8,141, 0,8,77, 0,9,251,
  28.173 -    80,7,3, 0,8,83, 0,8,19, 85,8,195,
  28.174 -    83,7,35, 0,8,115, 0,8,51, 0,9,199,
  28.175 -    81,7,11, 0,8,99, 0,8,35, 0,9,167,
  28.176 -    0,8,3, 0,8,131, 0,8,67, 0,9,231,
  28.177 -    80,7,7, 0,8,91, 0,8,27, 0,9,151,
  28.178 -    84,7,67, 0,8,123, 0,8,59, 0,9,215,
  28.179 -    82,7,19, 0,8,107, 0,8,43, 0,9,183,
  28.180 -    0,8,11, 0,8,139, 0,8,75, 0,9,247,
  28.181 -    80,7,5, 0,8,87, 0,8,23, 192,8,0,
  28.182 -    83,7,51, 0,8,119, 0,8,55, 0,9,207,
  28.183 -    81,7,15, 0,8,103, 0,8,39, 0,9,175,
  28.184 -    0,8,7, 0,8,135, 0,8,71, 0,9,239,
  28.185 -    80,7,9, 0,8,95, 0,8,31, 0,9,159,
  28.186 -    84,7,99, 0,8,127, 0,8,63, 0,9,223,
  28.187 -    82,7,27, 0,8,111, 0,8,47, 0,9,191,
  28.188 -    0,8,15, 0,8,143, 0,8,79, 0,9,255
  28.189 -  };
  28.190 -  static final int[] fixed_td = {
  28.191 -    80,5,1, 87,5,257, 83,5,17, 91,5,4097,
  28.192 -    81,5,5, 89,5,1025, 85,5,65, 93,5,16385,
  28.193 -    80,5,3, 88,5,513, 84,5,33, 92,5,8193,
  28.194 -    82,5,9, 90,5,2049, 86,5,129, 192,5,24577,
  28.195 -    80,5,2, 87,5,385, 83,5,25, 91,5,6145,
  28.196 -    81,5,7, 89,5,1537, 85,5,97, 93,5,24577,
  28.197 -    80,5,4, 88,5,769, 84,5,49, 92,5,12289,
  28.198 -    82,5,13, 90,5,3073, 86,5,193, 192,5,24577
  28.199 -  };
  28.200 -
  28.201 -  // Tables for deflate from PKZIP's appnote.txt.
  28.202 -  static final int[] cplens = { // Copy lengths for literal codes 257..285
  28.203 -        3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31,
  28.204 -        35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0
  28.205 -  };
  28.206 -
  28.207 -  // see note #13 above about 258
  28.208 -  static final int[] cplext = { // Extra bits for literal codes 257..285
  28.209 -        0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2,
  28.210 -        3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0, 112, 112  // 112==invalid
  28.211 -  };
  28.212 -
  28.213 -  static final int[] cpdist = { // Copy offsets for distance codes 0..29
  28.214 -        1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193,
  28.215 -        257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145,
  28.216 -        8193, 12289, 16385, 24577
  28.217 -  };
  28.218 -
  28.219 -  static final int[] cpdext = { // Extra bits for distance codes
  28.220 -        0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6,
  28.221 -        7, 7, 8, 8, 9, 9, 10, 10, 11, 11,
  28.222 -        12, 12, 13, 13};
  28.223 -
  28.224 -  // If BMAX needs to be larger than 16, then h and x[] should be uLong.
  28.225 -  static final int BMAX=15;         // maximum bit length of any code
  28.226 -
  28.227 -  int[] hn = null;  // hufts used in space
  28.228 -  int[] v = null;   // work area for huft_build 
  28.229 -  int[] c = null;   // bit length count table
  28.230 -  int[] r = null;   // table entry for structure assignment
  28.231 -  int[] u = null;   // table stack
  28.232 -  int[] x = null;   // bit offsets, then code stack
  28.233 -
  28.234 -  private int huft_build(int[] b, // code lengths in bits (all assumed <= BMAX)
  28.235 -                         int bindex, 
  28.236 -                         int n,   // number of codes (assumed <= 288)
  28.237 -                         int s,   // number of simple-valued codes (0..s-1)
  28.238 -                         int[] d, // list of base values for non-simple codes
  28.239 -                         int[] e, // list of extra bits for non-simple codes
  28.240 -                         int[] t, // result: starting table
  28.241 -                         int[] m, // maximum lookup bits, returns actual
  28.242 -                         int[] hp,// space for trees
  28.243 -                         int[] hn,// hufts used in space
  28.244 -                         int[] v  // working area: values in order of bit length
  28.245 -                         ){
  28.246 -    // Given a list of code lengths and a maximum table size, make a set of
  28.247 -    // tables to decode that set of codes.  Return Z_OK on success, Z_BUF_ERROR
  28.248 -    // if the given code set is incomplete (the tables are still built in this
  28.249 -    // case), Z_DATA_ERROR if the input is invalid (an over-subscribed set of
  28.250 -    // lengths), or Z_MEM_ERROR if not enough memory.
  28.251 -
  28.252 -    int a;                       // counter for codes of length k
  28.253 -    int f;                       // i repeats in table every f entries
  28.254 -    int g;                       // maximum code length
  28.255 -    int h;                       // table level
  28.256 -    int i;                       // counter, current code
  28.257 -    int j;                       // counter
  28.258 -    int k;                       // number of bits in current code
  28.259 -    int l;                       // bits per table (returned in m)
  28.260 -    int mask;                    // (1 << w) - 1, to avoid cc -O bug on HP
  28.261 -    int p;                       // pointer into c[], b[], or v[]
  28.262 -    int q;                       // points to current table
  28.263 -    int w;                       // bits before this table == (l * h)
  28.264 -    int xp;                      // pointer into x
  28.265 -    int y;                       // number of dummy codes added
  28.266 -    int z;                       // number of entries in current table
  28.267 -
  28.268 -    // Generate counts for each bit length
  28.269 -
  28.270 -    p = 0; i = n;
  28.271 -    do {
  28.272 -      c[b[bindex+p]]++; p++; i--;   // assume all entries <= BMAX
  28.273 -    }while(i!=0);
  28.274 -
  28.275 -    if(c[0] == n){                // null input--all zero length codes
  28.276 -      t[0] = -1;
  28.277 -      m[0] = 0;
  28.278 -      return Z_OK;
  28.279 -    }
  28.280 -
  28.281 -    // Find minimum and maximum length, bound *m by those
  28.282 -    l = m[0];
  28.283 -    for (j = 1; j <= BMAX; j++)
  28.284 -      if(c[j]!=0) break;
  28.285 -    k = j;                        // minimum code length
  28.286 -    if(l < j){
  28.287 -      l = j;
  28.288 -    }
  28.289 -    for (i = BMAX; i!=0; i--){
  28.290 -      if(c[i]!=0) break;
  28.291 -    }
  28.292 -    g = i;                        // maximum code length
  28.293 -    if(l > i){
  28.294 -      l = i;
  28.295 -    }
  28.296 -    m[0] = l;
  28.297 -
  28.298 -    // Adjust last length count to fill out codes, if needed
  28.299 -    for (y = 1 << j; j < i; j++, y <<= 1){
  28.300 -      if ((y -= c[j]) < 0){
  28.301 -        return Z_DATA_ERROR;
  28.302 -      }
  28.303 -    }
  28.304 -    if ((y -= c[i]) < 0){
  28.305 -      return Z_DATA_ERROR;
  28.306 -    }
  28.307 -    c[i] += y;
  28.308 -
  28.309 -    // Generate starting offsets into the value table for each length
  28.310 -    x[1] = j = 0;
  28.311 -    p = 1;  xp = 2;
  28.312 -    while (--i!=0) {                 // note that i == g from above
  28.313 -      x[xp] = (j += c[p]);
  28.314 -      xp++;
  28.315 -      p++;
  28.316 -    }
  28.317 -
  28.318 -    // Make a table of values in order of bit lengths
  28.319 -    i = 0; p = 0;
  28.320 -    do {
  28.321 -      if ((j = b[bindex+p]) != 0){
  28.322 -        v[x[j]++] = i;
  28.323 -      }
  28.324 -      p++;
  28.325 -    }
  28.326 -    while (++i < n);
  28.327 -    n = x[g];                     // set n to length of v
  28.328 -
  28.329 -    // Generate the Huffman codes and for each, make the table entries
  28.330 -    x[0] = i = 0;                 // first Huffman code is zero
  28.331 -    p = 0;                        // grab values in bit order
  28.332 -    h = -1;                       // no tables yet--level -1
  28.333 -    w = -l;                       // bits decoded == (l * h)
  28.334 -    u[0] = 0;                     // just to keep compilers happy
  28.335 -    q = 0;                        // ditto
  28.336 -    z = 0;                        // ditto
  28.337 -
  28.338 -    // go through the bit lengths (k already is bits in shortest code)
  28.339 -    for (; k <= g; k++){
  28.340 -      a = c[k];
  28.341 -      while (a--!=0){
  28.342 -	// here i is the Huffman code of length k bits for value *p
  28.343 -	// make tables up to required level
  28.344 -        while (k > w + l){
  28.345 -          h++;
  28.346 -          w += l;                 // previous table always l bits
  28.347 -	  // compute minimum size table less than or equal to l bits
  28.348 -          z = g - w;
  28.349 -          z = (z > l) ? l : z;        // table size upper limit
  28.350 -          if((f=1<<(j=k-w))>a+1){     // try a k-w bit table
  28.351 -                                      // too few codes for k-w bit table
  28.352 -            f -= a + 1;               // deduct codes from patterns left
  28.353 -            xp = k;
  28.354 -            if(j < z){
  28.355 -              while (++j < z){        // try smaller tables up to z bits
  28.356 -                if((f <<= 1) <= c[++xp])
  28.357 -                  break;              // enough codes to use up j bits
  28.358 -                f -= c[xp];           // else deduct codes from patterns
  28.359 -              }
  28.360 -	    }
  28.361 -          }
  28.362 -          z = 1 << j;                 // table entries for j-bit table
  28.363 -
  28.364 -	  // allocate new table
  28.365 -          if (hn[0] + z > MANY){       // (note: doesn't matter for fixed)
  28.366 -            return Z_DATA_ERROR;       // overflow of MANY
  28.367 -          }
  28.368 -          u[h] = q = /*hp+*/ hn[0];   // DEBUG
  28.369 -          hn[0] += z;
  28.370 - 
  28.371 -	  // connect to last table, if there is one
  28.372 -	  if(h!=0){
  28.373 -            x[h]=i;           // save pattern for backing up
  28.374 -            r[0]=(byte)j;     // bits in this table
  28.375 -            r[1]=(byte)l;     // bits to dump before this table
  28.376 -            j=i>>>(w - l);
  28.377 -            r[2] = (int)(q - u[h-1] - j);               // offset to this table
  28.378 -            System.arraycopy(r, 0, hp, (u[h-1]+j)*3, 3); // connect to last table
  28.379 -          }
  28.380 -          else{
  28.381 -            t[0] = q;               // first table is returned result
  28.382 -	  }
  28.383 -        }
  28.384 -
  28.385 -	// set up table entry in r
  28.386 -        r[1] = (byte)(k - w);
  28.387 -        if (p >= n){
  28.388 -          r[0] = 128 + 64;      // out of values--invalid code
  28.389 -	}
  28.390 -        else if (v[p] < s){
  28.391 -          r[0] = (byte)(v[p] < 256 ? 0 : 32 + 64);  // 256 is end-of-block
  28.392 -          r[2] = v[p++];          // simple code is just the value
  28.393 -        }
  28.394 -        else{
  28.395 -          r[0]=(byte)(e[v[p]-s]+16+64); // non-simple--look up in lists
  28.396 -          r[2]=d[v[p++] - s];
  28.397 -        }
  28.398 -
  28.399 -        // fill code-like entries with r
  28.400 -        f=1<<(k-w);
  28.401 -        for (j=i>>>w;j<z;j+=f){
  28.402 -          System.arraycopy(r, 0, hp, (q+j)*3, 3);
  28.403 -	}
  28.404 -
  28.405 -	// backwards increment the k-bit code i
  28.406 -        for (j = 1 << (k - 1); (i & j)!=0; j >>>= 1){
  28.407 -          i ^= j;
  28.408 -	}
  28.409 -        i ^= j;
  28.410 -
  28.411 -	// backup over finished tables
  28.412 -        mask = (1 << w) - 1;      // needed on HP, cc -O bug
  28.413 -        while ((i & mask) != x[h]){
  28.414 -          h--;                    // don't need to update q
  28.415 -          w -= l;
  28.416 -          mask = (1 << w) - 1;
  28.417 -        }
  28.418 -      }
  28.419 -    }
  28.420 -    // Return Z_BUF_ERROR if we were given an incomplete table
  28.421 -    return y != 0 && g != 1 ? Z_BUF_ERROR : Z_OK;
  28.422 -  }
  28.423 -
  28.424 -  int inflate_trees_bits(int[] c,  // 19 code lengths
  28.425 -                         int[] bb, // bits tree desired/actual depth
  28.426 -                         int[] tb, // bits tree result
  28.427 -                         int[] hp, // space for trees
  28.428 -                         ZStream z // for messages
  28.429 -                         ){
  28.430 -    int result;
  28.431 -    initWorkArea(19);
  28.432 -    hn[0]=0;
  28.433 -    result = huft_build(c, 0, 19, 19, null, null, tb, bb, hp, hn, v);
  28.434 -
  28.435 -    if(result == Z_DATA_ERROR){
  28.436 -      z.msg = "oversubscribed dynamic bit lengths tree";
  28.437 -    }
  28.438 -    else if(result == Z_BUF_ERROR || bb[0] == 0){
  28.439 -      z.msg = "incomplete dynamic bit lengths tree";
  28.440 -      result = Z_DATA_ERROR;
  28.441 -    }
  28.442 -    return result;
  28.443 -  }
  28.444 -
  28.445 -  int inflate_trees_dynamic(int nl,   // number of literal/length codes
  28.446 -                            int nd,   // number of distance codes
  28.447 -                            int[] c,  // that many (total) code lengths
  28.448 -                            int[] bl, // literal desired/actual bit depth
  28.449 -                            int[] bd, // distance desired/actual bit depth 
  28.450 -                            int[] tl, // literal/length tree result
  28.451 -                            int[] td, // distance tree result
  28.452 -                            int[] hp, // space for trees
  28.453 -                            ZStream z // for messages
  28.454 -                            ){
  28.455 -    int result;
  28.456 -
  28.457 -    // build literal/length tree
  28.458 -    initWorkArea(288);
  28.459 -    hn[0]=0;
  28.460 -    result = huft_build(c, 0, nl, 257, cplens, cplext, tl, bl, hp, hn, v);
  28.461 -    if (result != Z_OK || bl[0] == 0){
  28.462 -      if(result == Z_DATA_ERROR){
  28.463 -        z.msg = "oversubscribed literal/length tree";
  28.464 -      }
  28.465 -      else if (result != Z_MEM_ERROR){
  28.466 -        z.msg = "incomplete literal/length tree";
  28.467 -        result = Z_DATA_ERROR;
  28.468 -      }
  28.469 -      return result;
  28.470 -    }
  28.471 -
  28.472 -    // build distance tree
  28.473 -    initWorkArea(288);
  28.474 -    result = huft_build(c, nl, nd, 0, cpdist, cpdext, td, bd, hp, hn, v);
  28.475 -
  28.476 -    if (result != Z_OK || (bd[0] == 0 && nl > 257)){
  28.477 -      if (result == Z_DATA_ERROR){
  28.478 -        z.msg = "oversubscribed distance tree";
  28.479 -      }
  28.480 -      else if (result == Z_BUF_ERROR) {
  28.481 -        z.msg = "incomplete distance tree";
  28.482 -        result = Z_DATA_ERROR;
  28.483 -      }
  28.484 -      else if (result != Z_MEM_ERROR){
  28.485 -        z.msg = "empty distance tree with lengths";
  28.486 -        result = Z_DATA_ERROR;
  28.487 -      }
  28.488 -      return result;
  28.489 -    }
  28.490 -
  28.491 -    return Z_OK;
  28.492 -  }
  28.493 -
  28.494 -  static int inflate_trees_fixed(int[] bl,  //literal desired/actual bit depth
  28.495 -                                 int[] bd,  //distance desired/actual bit depth
  28.496 -                                 int[][] tl,//literal/length tree result
  28.497 -                                 int[][] td,//distance tree result 
  28.498 -                                 ZStream z  //for memory allocation
  28.499 -				 ){
  28.500 -    bl[0]=fixed_bl;
  28.501 -    bd[0]=fixed_bd;
  28.502 -    tl[0]=fixed_tl;
  28.503 -    td[0]=fixed_td;
  28.504 -    return Z_OK;
  28.505 -  }
  28.506 -
  28.507 -  private void initWorkArea(int vsize){
  28.508 -    if(hn==null){
  28.509 -      hn=new int[1];
  28.510 -      v=new int[vsize];
  28.511 -      c=new int[BMAX+1];
  28.512 -      r=new int[3];
  28.513 -      u=new int[BMAX];
  28.514 -      x=new int[BMAX+1];
  28.515 -    }
  28.516 -    if(v.length<vsize){ v=new int[vsize]; }
  28.517 -    for(int i=0; i<vsize; i++){v[i]=0;}
  28.518 -    for(int i=0; i<BMAX+1; i++){c[i]=0;}
  28.519 -    for(int i=0; i<3; i++){r[i]=0;}
  28.520 -    System.arraycopy(c, 0, u, 0, BMAX);
  28.521 -    System.arraycopy(c, 0, x, 0, BMAX+1);
  28.522 -  }
  28.523 -}
    29.1 --- a/rt/emul/mini/src/main/java/org/apidesign/bck2brwsr/emul/zip/Inflate.java	Wed May 07 11:55:06 2014 +0200
    29.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    29.3 @@ -1,727 +0,0 @@
    29.4 -/* -*-mode:java; c-basic-offset:2; -*- */
    29.5 -/*
    29.6 -Copyright (c) 2000-2011 ymnk, JCraft,Inc. All rights reserved.
    29.7 -
    29.8 -Redistribution and use in source and binary forms, with or without
    29.9 -modification, are permitted provided that the following conditions are met:
   29.10 -
   29.11 -  1. Redistributions of source code must retain the above copyright notice,
   29.12 -     this list of conditions and the following disclaimer.
   29.13 -
   29.14 -  2. Redistributions in binary form must reproduce the above copyright 
   29.15 -     notice, this list of conditions and the following disclaimer in 
   29.16 -     the documentation and/or other materials provided with the distribution.
   29.17 -
   29.18 -  3. The names of the authors may not be used to endorse or promote products
   29.19 -     derived from this software without specific prior written permission.
   29.20 -
   29.21 -THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
   29.22 -INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
   29.23 -FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
   29.24 -INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
   29.25 -INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   29.26 -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
   29.27 -OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
   29.28 -LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
   29.29 -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
   29.30 -EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
   29.31 - */
   29.32 -/*
   29.33 - * This program is based on zlib-1.1.3, so all credit should go authors
   29.34 - * Jean-loup Gailly(jloup@gzip.org) and Mark Adler(madler@alumni.caltech.edu)
   29.35 - * and contributors of zlib.
   29.36 - */
   29.37 -
   29.38 -package org.apidesign.bck2brwsr.emul.zip;
   29.39 -
   29.40 -import org.apidesign.bck2brwsr.emul.lang.System;
   29.41 -
   29.42 -final class Inflate{
   29.43 -  
   29.44 -  static final private int MAX_WBITS=15; // 32K LZ77 window
   29.45 -
   29.46 -  // preset dictionary flag in zlib header
   29.47 -  static final private int PRESET_DICT=0x20;
   29.48 -
   29.49 -  static final int Z_NO_FLUSH=0;
   29.50 -  static final int Z_PARTIAL_FLUSH=1;
   29.51 -  static final int Z_SYNC_FLUSH=2;
   29.52 -  static final int Z_FULL_FLUSH=3;
   29.53 -  static final int Z_FINISH=4;
   29.54 -
   29.55 -  static final private int Z_DEFLATED=8;
   29.56 -
   29.57 -  static final private int Z_OK=0;
   29.58 -  static final private int Z_STREAM_END=1;
   29.59 -  static final private int Z_NEED_DICT=2;
   29.60 -  static final private int Z_ERRNO=-1;
   29.61 -  static final private int Z_STREAM_ERROR=-2;
   29.62 -  static final private int Z_DATA_ERROR=-3;
   29.63 -  static final private int Z_MEM_ERROR=-4;
   29.64 -  static final private int Z_BUF_ERROR=-5;
   29.65 -  static final private int Z_VERSION_ERROR=-6;
   29.66 -
   29.67 -  static final private int METHOD=0;   // waiting for method byte
   29.68 -  static final private int FLAG=1;     // waiting for flag byte
   29.69 -  static final private int DICT4=2;    // four dictionary check bytes to go
   29.70 -  static final private int DICT3=3;    // three dictionary check bytes to go
   29.71 -  static final private int DICT2=4;    // two dictionary check bytes to go
   29.72 -  static final private int DICT1=5;    // one dictionary check byte to go
   29.73 -  static final int DICT0=6;    // waiting for inflateSetDictionary
   29.74 -  static final private int BLOCKS=7;   // decompressing blocks
   29.75 -  static final private int CHECK4=8;   // four check bytes to go
   29.76 -  static final private int CHECK3=9;   // three check bytes to go
   29.77 -  static final private int CHECK2=10;  // two check bytes to go
   29.78 -  static final private int CHECK1=11;  // one check byte to go
   29.79 -  static final private int DONE=12;    // finished check, done
   29.80 -  static final private int BAD=13;     // got an error--stay here
   29.81 -
   29.82 -  static final private int HEAD=14;
   29.83 -  static final private int LENGTH=15;
   29.84 -  static final private int TIME=16;
   29.85 -  static final private int OS=17;
   29.86 -  static final private int EXLEN=18;
   29.87 -  static final private int EXTRA=19;
   29.88 -  static final private int NAME=20;
   29.89 -  static final private int COMMENT=21;
   29.90 -  static final private int HCRC=22;
   29.91 -  static final private int FLAGS=23;
   29.92 -
   29.93 -  int mode;                            // current inflate mode
   29.94 -
   29.95 -  // mode dependent information
   29.96 -  int method;        // if FLAGS, method byte
   29.97 -
   29.98 -  // if CHECK, check values to compare
   29.99 -  long was = -1;           // computed check value
  29.100 -  long need;               // stream check value
  29.101 -
  29.102 -  // if BAD, inflateSync's marker bytes count
  29.103 -  int marker;
  29.104 -
  29.105 -  // mode independent information
  29.106 -  int  wrap;          // flag for no wrapper
  29.107 -  int wbits;            // log2(window size)  (8..15, defaults to 15)
  29.108 -
  29.109 -  InfBlocks blocks;     // current inflate_blocks state
  29.110 -
  29.111 -  private final ZStream z;
  29.112 -
  29.113 -  private int flags; 
  29.114 -
  29.115 -  private int need_bytes = -1;
  29.116 -  private byte[] crcbuf=new byte[4];
  29.117 -
  29.118 -  GZIPHeader gheader = null;
  29.119 -
  29.120 -  int inflateReset(){
  29.121 -    if(z == null) return Z_STREAM_ERROR;
  29.122 -    
  29.123 -    z.total_in = z.total_out = 0;
  29.124 -    z.msg = null;
  29.125 -    this.mode = HEAD;
  29.126 -    this.need_bytes = -1;
  29.127 -    this.blocks.reset();
  29.128 -    return Z_OK;
  29.129 -  }
  29.130 -
  29.131 -  int inflateEnd(){
  29.132 -    if(blocks != null){
  29.133 -      blocks.free();
  29.134 -    }
  29.135 -    return Z_OK;
  29.136 -  }
  29.137 -
  29.138 -  Inflate(ZStream z){
  29.139 -    this.z=z;
  29.140 -  }
  29.141 -
  29.142 -  int inflateInit(int w){
  29.143 -    z.msg = null;
  29.144 -    blocks = null;
  29.145 -
  29.146 -    // handle undocumented wrap option (no zlib header or check)
  29.147 -    wrap = 0;
  29.148 -    if(w < 0){
  29.149 -      w = - w;
  29.150 -    }
  29.151 -    else {
  29.152 -      wrap = (w >> 4) + 1;
  29.153 -      if(w < 48)
  29.154 -        w &= 15;
  29.155 -    }
  29.156 -
  29.157 -    if(w<8 ||w>15){
  29.158 -      inflateEnd();
  29.159 -      return Z_STREAM_ERROR;
  29.160 -    }
  29.161 -    if(blocks != null && wbits != w){
  29.162 -      blocks.free();
  29.163 -      blocks=null;
  29.164 -    }
  29.165 -
  29.166 -    // set window size
  29.167 -    wbits=w;
  29.168 -
  29.169 -    this.blocks=new InfBlocks(z, 1<<w);
  29.170 -
  29.171 -    // reset state
  29.172 -    inflateReset();
  29.173 -
  29.174 -    return Z_OK;
  29.175 -  }
  29.176 -
  29.177 -  int inflate(int f){
  29.178 -    int hold = 0;
  29.179 -
  29.180 -    int r;
  29.181 -    int b;
  29.182 -
  29.183 -    if(z == null || z.next_in == null){
  29.184 -      if(f == Z_FINISH && this.mode==HEAD)
  29.185 -        return Z_OK; 
  29.186 -      return Z_STREAM_ERROR;
  29.187 -    }
  29.188 -
  29.189 -    f = f == Z_FINISH ? Z_BUF_ERROR : Z_OK;
  29.190 -    r = Z_BUF_ERROR;
  29.191 -    while (true){
  29.192 -
  29.193 -      switch (this.mode){
  29.194 -      case HEAD:
  29.195 -        if(wrap==0){
  29.196 -	  this.mode = BLOCKS;
  29.197 -          break;
  29.198 -        } 
  29.199 -
  29.200 -        try { r=readBytes(2, r, f); }
  29.201 -        catch(Return e){ return e.r; }
  29.202 -
  29.203 -        if((wrap&2)!=0 && this.need == 0x8b1fL) {   // gzip header
  29.204 -	  z.adler=new CRC32();
  29.205 -          checksum(2, this.need);
  29.206 -
  29.207 -          if(gheader==null) 
  29.208 -            gheader=new GZIPHeader();
  29.209 -
  29.210 -          this.mode = FLAGS;
  29.211 -          break;
  29.212 -        }
  29.213 -
  29.214 -        flags = 0;
  29.215 -
  29.216 -        this.method = ((int)this.need)&0xff;
  29.217 -        b=((int)(this.need>>8))&0xff;
  29.218 -
  29.219 -        if((wrap&1)==0 ||  // check if zlib header allowed
  29.220 -           (((this.method << 8)+b) % 31)!=0){
  29.221 -          this.mode = BAD;
  29.222 -          z.msg = "incorrect header check";
  29.223 -          // since zlib 1.2, it is allowted to inflateSync for this case.
  29.224 -          /*
  29.225 -          this.marker = 5;       // can't try inflateSync
  29.226 -          */
  29.227 -          break;
  29.228 -        }
  29.229 -
  29.230 -        if((this.method&0xf)!=Z_DEFLATED){
  29.231 -          this.mode = BAD;
  29.232 -          z.msg="unknown compression method";
  29.233 -          // since zlib 1.2, it is allowted to inflateSync for this case.
  29.234 -	  /*
  29.235 -          this.marker = 5;       // can't try inflateSync
  29.236 -	  */
  29.237 -          break;
  29.238 -        }
  29.239 -
  29.240 -        if((this.method>>4)+8>this.wbits){
  29.241 -          this.mode = BAD;
  29.242 -          z.msg="invalid window size";
  29.243 -          // since zlib 1.2, it is allowted to inflateSync for this case.
  29.244 -	  /*
  29.245 -          this.marker = 5;       // can't try inflateSync
  29.246 -	  */
  29.247 -          break;
  29.248 -        }
  29.249 -
  29.250 -        z.adler=new Adler32();
  29.251 -
  29.252 -        if((b&PRESET_DICT)==0){
  29.253 -          this.mode = BLOCKS;
  29.254 -          break;
  29.255 -        }
  29.256 -        this.mode = DICT4;
  29.257 -      case DICT4:
  29.258 -
  29.259 -        if(z.avail_in==0)return r;r=f;
  29.260 -
  29.261 -        z.avail_in--; z.total_in++;
  29.262 -        this.need=((z.next_in[z.next_in_index++]&0xff)<<24)&0xff000000L;
  29.263 -        this.mode=DICT3;
  29.264 -      case DICT3:
  29.265 -
  29.266 -        if(z.avail_in==0)return r;r=f;
  29.267 -
  29.268 -        z.avail_in--; z.total_in++;
  29.269 -        this.need+=((z.next_in[z.next_in_index++]&0xff)<<16)&0xff0000L;
  29.270 -        this.mode=DICT2;
  29.271 -      case DICT2:
  29.272 -
  29.273 -        if(z.avail_in==0)return r;r=f;
  29.274 -
  29.275 -        z.avail_in--; z.total_in++;
  29.276 -        this.need+=((z.next_in[z.next_in_index++]&0xff)<<8)&0xff00L;
  29.277 -        this.mode=DICT1;
  29.278 -      case DICT1:
  29.279 -
  29.280 -        if(z.avail_in==0)return r;r=f;
  29.281 -
  29.282 -        z.avail_in--; z.total_in++;
  29.283 -        this.need += (z.next_in[z.next_in_index++]&0xffL);
  29.284 -        z.adler.reset(this.need);
  29.285 -        this.mode = DICT0;
  29.286 -        return Z_NEED_DICT;
  29.287 -      case DICT0:
  29.288 -        this.mode = BAD;
  29.289 -        z.msg = "need dictionary";
  29.290 -        this.marker = 0;       // can try inflateSync
  29.291 -        return Z_STREAM_ERROR;
  29.292 -      case BLOCKS:
  29.293 -        r = this.blocks.proc(r);
  29.294 -        if(r == Z_DATA_ERROR){
  29.295 -          this.mode = BAD;
  29.296 -          this.marker = 0;     // can try inflateSync
  29.297 -          break;
  29.298 -        }
  29.299 -        if(r == Z_OK){
  29.300 -          r = f;
  29.301 -        }
  29.302 -        if(r != Z_STREAM_END){
  29.303 -          return r;
  29.304 -        }
  29.305 -        r = f;
  29.306 -        this.was=z.adler.getValue();
  29.307 -        this.blocks.reset();
  29.308 -        if(this.wrap==0){
  29.309 -          this.mode=DONE;
  29.310 -          break;
  29.311 -        }
  29.312 -        this.mode=CHECK4;
  29.313 -      case CHECK4:
  29.314 -
  29.315 -        if(z.avail_in==0)return r;r=f;
  29.316 -
  29.317 -        z.avail_in--; z.total_in++;
  29.318 -        this.need=((z.next_in[z.next_in_index++]&0xff)<<24)&0xff000000L;
  29.319 -        this.mode=CHECK3;
  29.320 -      case CHECK3:
  29.321 -
  29.322 -        if(z.avail_in==0)return r;r=f;
  29.323 -
  29.324 -        z.avail_in--; z.total_in++;
  29.325 -        this.need+=((z.next_in[z.next_in_index++]&0xff)<<16)&0xff0000L;
  29.326 -        this.mode = CHECK2;
  29.327 -      case CHECK2:
  29.328 -
  29.329 -        if(z.avail_in==0)return r;r=f;
  29.330 -
  29.331 -        z.avail_in--; z.total_in++;
  29.332 -        this.need+=((z.next_in[z.next_in_index++]&0xff)<<8)&0xff00L;
  29.333 -        this.mode = CHECK1;
  29.334 -      case CHECK1:
  29.335 -
  29.336 -        if(z.avail_in==0)return r;r=f;
  29.337 -
  29.338 -        z.avail_in--; z.total_in++;
  29.339 -        this.need+=(z.next_in[z.next_in_index++]&0xffL);
  29.340 -
  29.341 -        if(flags!=0){  // gzip
  29.342 -          this.need = ((this.need&0xff000000)>>24 | 
  29.343 -                          (this.need&0x00ff0000)>>8 | 
  29.344 -                          (this.need&0x0000ff00)<<8 | 
  29.345 -                          (this.need&0x0000ffff)<<24)&0xffffffffL;
  29.346 -        }
  29.347 -
  29.348 -        if(((int)(this.was)) != ((int)(this.need))){
  29.349 -          z.msg = "incorrect data check";
  29.350 -          // chack is delayed
  29.351 -          /*
  29.352 -          this.mode = BAD;
  29.353 -          this.marker = 5;       // can't try inflateSync
  29.354 -          break;
  29.355 -	  */
  29.356 -        }
  29.357 -        else if(flags!=0 && gheader!=null){
  29.358 -          gheader.crc = this.need; 
  29.359 -        }
  29.360 -
  29.361 -        this.mode = LENGTH;
  29.362 -      case LENGTH:
  29.363 -        if (wrap!=0 && flags!=0) {
  29.364 -
  29.365 -          try { r=readBytes(4, r, f); }
  29.366 -          catch(Return e){ return e.r; }
  29.367 -
  29.368 -          if(z.msg!=null && z.msg.equals("incorrect data check")){
  29.369 -            this.mode = BAD;
  29.370 -            this.marker = 5;       // can't try inflateSync
  29.371 -            break;
  29.372 -          }
  29.373 -
  29.374 -          if (this.need != (z.total_out & 0xffffffffL)) {
  29.375 -            z.msg = "incorrect length check";
  29.376 -            this.mode = BAD;
  29.377 -            break;
  29.378 -          }
  29.379 -          z.msg = null;
  29.380 -        }
  29.381 -        else {
  29.382 -          if(z.msg!=null && z.msg.equals("incorrect data check")){
  29.383 -            this.mode = BAD;
  29.384 -            this.marker = 5;       // can't try inflateSync
  29.385 -            break;
  29.386 -          }
  29.387 -        }
  29.388 -
  29.389 -        this.mode = DONE;
  29.390 -      case DONE:
  29.391 -        return Z_STREAM_END;
  29.392 -      case BAD:
  29.393 -        return Z_DATA_ERROR;
  29.394 -
  29.395 -      case FLAGS:
  29.396 -
  29.397 -        try { r=readBytes(2, r, f); }
  29.398 -        catch(Return e){ return e.r; }
  29.399 -
  29.400 -        flags = ((int)this.need)&0xffff;
  29.401 -
  29.402 -        if ((flags & 0xff) != Z_DEFLATED) {
  29.403 -          z.msg = "unknown compression method";
  29.404 -          this.mode = BAD; 
  29.405 -          break;
  29.406 -        }
  29.407 -        if ((flags & 0xe000)!=0) {
  29.408 -          z.msg = "unknown header flags set";
  29.409 -          this.mode = BAD; 
  29.410 -          break;
  29.411 -        }
  29.412 -
  29.413 -        if ((flags & 0x0200)!=0){
  29.414 -          checksum(2, this.need);
  29.415 -        } 
  29.416 -
  29.417 -        this.mode = TIME;
  29.418 -
  29.419 -      case TIME:
  29.420 -        try { r=readBytes(4, r, f); }
  29.421 -        catch(Return e){ return e.r; }
  29.422 -        if(gheader!=null)
  29.423 -          gheader.time = this.need;
  29.424 -        if ((flags & 0x0200)!=0){
  29.425 -          checksum(4, this.need);
  29.426 -        }
  29.427 -        this.mode = OS;
  29.428 -      case OS:
  29.429 -        try { r=readBytes(2, r, f); }
  29.430 -        catch(Return e){ return e.r; }
  29.431 -        if(gheader!=null){
  29.432 -          gheader.xflags = ((int)this.need)&0xff;
  29.433 -          gheader.os = (((int)this.need)>>8)&0xff;
  29.434 -        }
  29.435 -        if ((flags & 0x0200)!=0){
  29.436 -          checksum(2, this.need);
  29.437 -        }
  29.438 -        this.mode = EXLEN;
  29.439 -      case EXLEN:
  29.440 -        if ((flags & 0x0400)!=0) {
  29.441 -          try { r=readBytes(2, r, f); }
  29.442 -          catch(Return e){ return e.r; }
  29.443 -          if(gheader!=null){
  29.444 -            gheader.extra = new byte[((int)this.need)&0xffff];
  29.445 -          }
  29.446 -          if ((flags & 0x0200)!=0){
  29.447 -            checksum(2, this.need);
  29.448 -          }
  29.449 -        }
  29.450 -        else if(gheader!=null){
  29.451 -          gheader.extra=null;
  29.452 -        }
  29.453 -        this.mode = EXTRA;
  29.454 -
  29.455 -      case EXTRA:
  29.456 -        if ((flags & 0x0400)!=0) {
  29.457 -          try { 
  29.458 -            r=readBytes(r, f);
  29.459 -            if(gheader!=null){
  29.460 -              byte[] foo = tmp_array;
  29.461 -              tmp_array=null;
  29.462 -              if(foo.length == gheader.extra.length){
  29.463 -                System.arraycopy(foo, 0, gheader.extra, 0, foo.length);
  29.464 -	      }
  29.465 -              else{
  29.466 -                z.msg = "bad extra field length";
  29.467 -                this.mode = BAD; 
  29.468 -                break;
  29.469 -	      }
  29.470 -            }
  29.471 -          }
  29.472 -          catch(Return e){ return e.r; }
  29.473 -        }
  29.474 -        else if(gheader!=null){
  29.475 -          gheader.extra=null;
  29.476 -	}
  29.477 -	this.mode = NAME;
  29.478 -      case NAME:
  29.479 -	if ((flags & 0x0800)!=0) {
  29.480 -          try { 
  29.481 -            r=readString(r, f);
  29.482 -            if(gheader!=null){
  29.483 -              gheader.name=tmp_array;
  29.484 -            }
  29.485 -            tmp_array=null;
  29.486 -          }
  29.487 -          catch(Return e){ return e.r; }
  29.488 -        }
  29.489 -        else if(gheader!=null){
  29.490 -          gheader.name=null;
  29.491 -	}
  29.492 -        this.mode = COMMENT;
  29.493 -      case COMMENT:
  29.494 -        if ((flags & 0x1000)!=0) {
  29.495 -          try { 
  29.496 -            r=readString(r, f);
  29.497 -            if(gheader!=null){
  29.498 -              gheader.comment=tmp_array;
  29.499 -            }
  29.500 -            tmp_array=null;
  29.501 -          }
  29.502 -          catch(Return e){ return e.r; }
  29.503 -        }
  29.504 -        else if(gheader!=null){
  29.505 -          gheader.comment=null;
  29.506 -	}
  29.507 -        this.mode = HCRC;
  29.508 -      case HCRC:
  29.509 -	if ((flags & 0x0200)!=0) {
  29.510 -          try { r=readBytes(2, r, f); }
  29.511 -          catch(Return e){ return e.r; }
  29.512 -          if(gheader!=null){
  29.513 -            gheader.hcrc=(int)(this.need&0xffff);
  29.514 -          }
  29.515 -          if(this.need != (z.adler.getValue()&0xffffL)){
  29.516 -            this.mode = BAD;
  29.517 -            z.msg = "header crc mismatch";
  29.518 -            this.marker = 5;       // can't try inflateSync
  29.519 -            break;
  29.520 -          }
  29.521 -        }
  29.522 -        z.adler = new CRC32();
  29.523 -
  29.524 -        this.mode = BLOCKS;
  29.525 -        break;
  29.526 -      default:
  29.527 -        return Z_STREAM_ERROR;
  29.528 -      }
  29.529 -    }
  29.530 -  }
  29.531 -
  29.532 -  int inflateSetDictionary(byte[] dictionary, int dictLength){
  29.533 -    if(z==null || (this.mode != DICT0 && this.wrap != 0)){
  29.534 -      return Z_STREAM_ERROR;
  29.535 -    }
  29.536 -
  29.537 -    int index=0;
  29.538 -    int length = dictLength;
  29.539 -
  29.540 -    if(this.mode==DICT0){
  29.541 -      long adler_need=z.adler.getValue();
  29.542 -      z.adler.reset();
  29.543 -      z.adler.update(dictionary, 0, dictLength);
  29.544 -      if(z.adler.getValue()!=adler_need){
  29.545 -        return Z_DATA_ERROR;
  29.546 -      }
  29.547 -    }
  29.548 -
  29.549 -    z.adler.reset();
  29.550 -
  29.551 -    if(length >= (1<<this.wbits)){
  29.552 -      length = (1<<this.wbits)-1;
  29.553 -      index=dictLength - length;
  29.554 -    }
  29.555 -    this.blocks.set_dictionary(dictionary, index, length);
  29.556 -    this.mode = BLOCKS;
  29.557 -    return Z_OK;
  29.558 -  }
  29.559 -
  29.560 -  static private byte[] mark = {(byte)0, (byte)0, (byte)0xff, (byte)0xff};
  29.561 -
  29.562 -  int inflateSync(){
  29.563 -    int n;       // number of bytes to look at
  29.564 -    int p;       // pointer to bytes
  29.565 -    int m;       // number of marker bytes found in a row
  29.566 -    long r, w;   // temporaries to save total_in and total_out
  29.567 -
  29.568 -    // set up
  29.569 -    if(z == null)
  29.570 -      return Z_STREAM_ERROR;
  29.571 -    if(this.mode != BAD){
  29.572 -      this.mode = BAD;
  29.573 -      this.marker = 0;
  29.574 -    }
  29.575 -    if((n=z.avail_in)==0)
  29.576 -      return Z_BUF_ERROR;
  29.577 -
  29.578 -    p=z.next_in_index;
  29.579 -    m=this.marker;
  29.580 -    // search
  29.581 -    while (n!=0 && m < 4){
  29.582 -      if(z.next_in[p] == mark[m]){
  29.583 -        m++;
  29.584 -      }
  29.585 -      else if(z.next_in[p]!=0){
  29.586 -        m = 0;
  29.587 -      }
  29.588 -      else{
  29.589 -        m = 4 - m;
  29.590 -      }
  29.591 -      p++; n--;
  29.592 -    }
  29.593 -
  29.594 -    // restore
  29.595 -    z.total_in += p-z.next_in_index;
  29.596 -    z.next_in_index = p;
  29.597 -    z.avail_in = n;
  29.598 -    this.marker = m;
  29.599 -
  29.600 -    // return no joy or set up to restart on a new block
  29.601 -    if(m != 4){
  29.602 -      return Z_DATA_ERROR;
  29.603 -    }
  29.604 -    r=z.total_in;  w=z.total_out;
  29.605 -    inflateReset();
  29.606 -    z.total_in=r;  z.total_out = w;
  29.607 -    this.mode = BLOCKS;
  29.608 -
  29.609 -    return Z_OK;
  29.610 -  }
  29.611 -
  29.612 -  // Returns true if inflate is currently at the end of a block generated
  29.613 -  // by Z_SYNC_FLUSH or Z_FULL_FLUSH. This function is used by one PPP
  29.614 -  // implementation to provide an additional safety check. PPP uses Z_SYNC_FLUSH
  29.615 -  // but removes the length bytes of the resulting empty stored block. When
  29.616 -  // decompressing, PPP checks that at the end of input packet, inflate is
  29.617 -  // waiting for these length bytes.
  29.618 -  int inflateSyncPoint(){
  29.619 -    if(z == null || this.blocks == null)
  29.620 -      return Z_STREAM_ERROR;
  29.621 -    return this.blocks.sync_point();
  29.622 -  }
  29.623 -
  29.624 -  private int readBytes(int n, int r, int f) throws Return{
  29.625 -    if(need_bytes == -1){
  29.626 -      need_bytes=n;
  29.627 -      this.need=0;
  29.628 -    }
  29.629 -    while(need_bytes>0){
  29.630 -      if(z.avail_in==0){ throw new Return(r); }; r=f;
  29.631 -      z.avail_in--; z.total_in++;
  29.632 -      this.need = this.need | 
  29.633 -	((z.next_in[z.next_in_index++]&0xff)<<((n-need_bytes)*8));
  29.634 -      need_bytes--;
  29.635 -    }
  29.636 -    if(n==2){
  29.637 -      this.need&=0xffffL;
  29.638 -    }
  29.639 -    else if(n==4) {
  29.640 -      this.need&=0xffffffffL;
  29.641 -    }
  29.642 -    need_bytes=-1;
  29.643 -    return r;
  29.644 -  }
  29.645 -  class Return extends Exception{
  29.646 -    int r;
  29.647 -    Return(int r){this.r=r; }
  29.648 -  }
  29.649 -
  29.650 -  private byte[] tmp_array;
  29.651 -  private int readString(int r, int f) throws Return{
  29.652 -    int b=0; 
  29.653 -    byte[] arr = new byte[4092];
  29.654 -    int at = 0;
  29.655 -    do {
  29.656 -      if(z.avail_in==0){ throw new Return(r); }; r=f;
  29.657 -      z.avail_in--; z.total_in++;
  29.658 -      b = z.next_in[z.next_in_index];
  29.659 -      if(b!=0) arr = append(arr, z.next_in[z.next_in_index], at++);
  29.660 -      z.adler.update(z.next_in, z.next_in_index, 1);
  29.661 -      z.next_in_index++;
  29.662 -    }while(b!=0);
  29.663 -    
  29.664 -    tmp_array = copy(arr, at);
  29.665 -    
  29.666 -    return r;
  29.667 -  }
  29.668 -
  29.669 -  private int readBytes(int r, int f) throws Return{
  29.670 -    int b=0; 
  29.671 -    byte[] arr = new byte[4092];
  29.672 -    int at = 0;
  29.673 -    while(this.need>0){
  29.674 -      if(z.avail_in==0){ throw new Return(r); }; r=f;
  29.675 -      z.avail_in--; z.total_in++;
  29.676 -      b = z.next_in[z.next_in_index];
  29.677 -      arr = append(arr, z.next_in[z.next_in_index], at++);
  29.678 -      z.adler.update(z.next_in, z.next_in_index, 1);
  29.679 -      z.next_in_index++;
  29.680 -      this.need--;
  29.681 -    }
  29.682 -    
  29.683 -    tmp_array = copy(arr, at);
  29.684 -    
  29.685 -    return r;
  29.686 -  }
  29.687 -  
  29.688 -  private static byte[] copy(byte[] arr, int len) {
  29.689 -      byte[] ret = new byte[len];
  29.690 -      org.apidesign.bck2brwsr.emul.lang.System.arraycopy(arr, 0, ret, 0, len);
  29.691 -      return ret;
  29.692 -  }
  29.693 -  private static byte[] append(byte[] arr, byte b, int index) {
  29.694 -      arr[index] = b;
  29.695 -      return arr;
  29.696 -  }
  29.697 -
  29.698 -  private void checksum(int n, long v){
  29.699 -    for(int i=0; i<n; i++){
  29.700 -      crcbuf[i]=(byte)(v&0xff);
  29.701 -      v>>=8;
  29.702 -    }
  29.703 -    z.adler.update(crcbuf, 0, n);
  29.704 -  }
  29.705 -
  29.706 -  public GZIPHeader getGZIPHeader(){
  29.707 -    return gheader;
  29.708 -  }
  29.709 -
  29.710 -  boolean inParsingHeader(){
  29.711 -    switch(mode){
  29.712 -      case HEAD:
  29.713 -      case DICT4:
  29.714 -      case DICT3:
  29.715 -      case DICT2:
  29.716 -      case DICT1:
  29.717 -      case FLAGS:
  29.718 -      case TIME:
  29.719 -      case OS:
  29.720 -      case EXLEN:
  29.721 -      case EXTRA:
  29.722 -      case NAME:
  29.723 -      case COMMENT:
  29.724 -      case HCRC:
  29.725 -	return true;
  29.726 -      default:
  29.727 -	return false;
  29.728 -    }
  29.729 -  }
  29.730 -}
    30.1 --- a/rt/emul/mini/src/main/java/org/apidesign/bck2brwsr/emul/zip/Inflater.java	Wed May 07 11:55:06 2014 +0200
    30.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    30.3 @@ -1,338 +0,0 @@
    30.4 -/*
    30.5 - * Copyright (c) 1996, 2011, Oracle and/or its affiliates. All rights reserved.
    30.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    30.7 - *
    30.8 - * This code is free software; you can redistribute it and/or modify it
    30.9 - * under the terms of the GNU General Public License version 2 only, as
   30.10 - * published by the Free Software Foundation.  Oracle designates this
   30.11 - * particular file as subject to the "Classpath" exception as provided
   30.12 - * by Oracle in the LICENSE file that accompanied this code.
   30.13 - *
   30.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
   30.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   30.16 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   30.17 - * version 2 for more details (a copy is included in the LICENSE file that
   30.18 - * accompanied this code).
   30.19 - *
   30.20 - * You should have received a copy of the GNU General Public License version
   30.21 - * 2 along with this work; if not, write to the Free Software Foundation,
   30.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   30.23 - *
   30.24 - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   30.25 - * or visit www.oracle.com if you need additional information or have any
   30.26 - * questions.
   30.27 - */
   30.28 -
   30.29 -package org.apidesign.bck2brwsr.emul.zip;
   30.30 -
   30.31 -import java.util.zip.*;
   30.32 -import java.io.IOException;
   30.33 -
   30.34 -/**
   30.35 - * This class provides support for general purpose decompression using the
   30.36 - * popular ZLIB compression library. The ZLIB compression library was
   30.37 - * initially developed as part of the PNG graphics standard and is not
   30.38 - * protected by patents. It is fully described in the specifications at
   30.39 - * the <a href="package-summary.html#package_description">java.util.zip
   30.40 - * package description</a>.
   30.41 - *
   30.42 - * <p>The following code fragment demonstrates a trivial compression
   30.43 - * and decompression of a string using <tt>Deflater</tt> and
   30.44 - * <tt>Inflater</tt>.
   30.45 - *
   30.46 - * <blockquote><pre>
   30.47 - * try {
   30.48 - *     // Encode a String into bytes
   30.49 - *     String inputString = "blahblahblah\u20AC\u20AC";
   30.50 - *     byte[] input = inputString.getBytes("UTF-8");
   30.51 - *
   30.52 - *     // Compress the bytes
   30.53 - *     byte[] output = new byte[100];
   30.54 - *     Deflater compresser = new Deflater();
   30.55 - *     compresser.setInput(input);
   30.56 - *     compresser.finish();
   30.57 - *     int compressedDataLength = compresser.deflate(output);
   30.58 - *
   30.59 - *     // Decompress the bytes
   30.60 - *     Inflater decompresser = new Inflater();
   30.61 - *     decompresser.setInput(output, 0, compressedDataLength);
   30.62 - *     byte[] result = new byte[100];
   30.63 - *     int resultLength = decompresser.inflate(result);
   30.64 - *     decompresser.end();
   30.65 - *
   30.66 - *     // Decode the bytes into a String
   30.67 - *     String outputString = new String(result, 0, resultLength, "UTF-8");
   30.68 - * } catch(java.io.UnsupportedEncodingException ex) {
   30.69 - *     // handle
   30.70 - * } catch (java.util.zip.DataFormatException ex) {
   30.71 - *     // handle
   30.72 - * }
   30.73 - * </pre></blockquote>
   30.74 - *
   30.75 - * @see         Deflater
   30.76 - * @author      David Connelly
   30.77 - *
   30.78 - */
   30.79 -public
   30.80 -class Inflater extends java.util.zip.Inflater {
   30.81 -    private final boolean nowrap;
   30.82 -    private JzLibInflater impl;
   30.83 -    
   30.84 -    /**
   30.85 -     * Creates a new decompressor. If the parameter 'nowrap' is true then
   30.86 -     * the ZLIB header and checksum fields will not be used. This provides
   30.87 -     * compatibility with the compression format used by both GZIP and PKZIP.
   30.88 -     * <p>
   30.89 -     * Note: When using the 'nowrap' option it is also necessary to provide
   30.90 -     * an extra "dummy" byte as input. This is required by the ZLIB native
   30.91 -     * library in order to support certain optimizations.
   30.92 -     *
   30.93 -     * @param nowrap if true then support GZIP compatible compression
   30.94 -     */
   30.95 -    public Inflater(boolean nowrap) {
   30.96 -        this.nowrap = nowrap;
   30.97 -        reset();
   30.98 -    }
   30.99 -
  30.100 -    /**
  30.101 -     * Creates a new decompressor.
  30.102 -     */
  30.103 -    public Inflater() {
  30.104 -        this(false);
  30.105 -    }
  30.106 -
  30.107 -    /**
  30.108 -     * Sets input data for decompression. Should be called whenever
  30.109 -     * needsInput() returns true indicating that more input data is
  30.110 -     * required.
  30.111 -     * @param b the input data bytes
  30.112 -     * @param off the start offset of the input data
  30.113 -     * @param len the length of the input data
  30.114 -     * @see Inflater#needsInput
  30.115 -     */
  30.116 -    public void setInput(byte[] b, int off, int len) {
  30.117 -        if (b == null) {
  30.118 -            throw new NullPointerException();
  30.119 -        }
  30.120 -        if (off < 0 || len < 0 || off > b.length - len) {
  30.121 -            throw new ArrayIndexOutOfBoundsException();
  30.122 -        }
  30.123 -        impl.setInput(b, off, len, false);
  30.124 -    }
  30.125 -
  30.126 -    /**
  30.127 -     * Sets input data for decompression. Should be called whenever
  30.128 -     * needsInput() returns true indicating that more input data is
  30.129 -     * required.
  30.130 -     * @param b the input data bytes
  30.131 -     * @see Inflater#needsInput
  30.132 -     */
  30.133 -    public void setInput(byte[] b) {
  30.134 -        setInput(b, 0, b.length);
  30.135 -    }
  30.136 -
  30.137 -    /**
  30.138 -     * Sets the preset dictionary to the given array of bytes. Should be
  30.139 -     * called when inflate() returns 0 and needsDictionary() returns true
  30.140 -     * indicating that a preset dictionary is required. The method getAdler()
  30.141 -     * can be used to get the Adler-32 value of the dictionary needed.
  30.142 -     * @param b the dictionary data bytes
  30.143 -     * @param off the start offset of the data
  30.144 -     * @param len the length of the data
  30.145 -     * @see Inflater#needsDictionary
  30.146 -     * @see Inflater#getAdler
  30.147 -     */
  30.148 -    public void setDictionary(byte[] b, int off, int len) {
  30.149 -        if (b == null) {
  30.150 -            throw new NullPointerException();
  30.151 -        }
  30.152 -        if (off < 0 || len < 0 || off > b.length - len) {
  30.153 -            throw new ArrayIndexOutOfBoundsException();
  30.154 -        }
  30.155 -        byte[] arr;
  30.156 -        if (off == 0) {
  30.157 -            arr = b;
  30.158 -        } else {
  30.159 -            arr = new byte[len];
  30.160 -            org.apidesign.bck2brwsr.emul.lang.System.arraycopy(b, off, arr, 0, len);
  30.161 -        }
  30.162 -        impl.setDictionary(arr, len);
  30.163 -    }
  30.164 -
  30.165 -    /**
  30.166 -     * Sets the preset dictionary to the given array of bytes. Should be
  30.167 -     * called when inflate() returns 0 and needsDictionary() returns true
  30.168 -     * indicating that a preset dictionary is required. The method getAdler()
  30.169 -     * can be used to get the Adler-32 value of the dictionary needed.
  30.170 -     * @param b the dictionary data bytes
  30.171 -     * @see Inflater#needsDictionary
  30.172 -     * @see Inflater#getAdler
  30.173 -     */
  30.174 -    public void setDictionary(byte[] b) {
  30.175 -        impl.setDictionary(b, b.length);
  30.176 -    }
  30.177 -
  30.178 -    /**
  30.179 -     * Returns the total number of bytes remaining in the input buffer.
  30.180 -     * This can be used to find out what bytes still remain in the input
  30.181 -     * buffer after decompression has finished.
  30.182 -     * @return the total number of bytes remaining in the input buffer
  30.183 -     */
  30.184 -    public int getRemaining() {
  30.185 -        return impl.getAvailIn();
  30.186 -    }
  30.187 -
  30.188 -    /**
  30.189 -     * Returns true if no data remains in the input buffer. This can
  30.190 -     * be used to determine if #setInput should be called in order
  30.191 -     * to provide more input.
  30.192 -     * @return true if no data remains in the input buffer
  30.193 -     */
  30.194 -    public boolean needsInput() {
  30.195 -        return getRemaining() <= 0;
  30.196 -    }
  30.197 -
  30.198 -    /**
  30.199 -     * Returns true if a preset dictionary is needed for decompression.
  30.200 -     * @return true if a preset dictionary is needed for decompression
  30.201 -     * @see Inflater#setDictionary
  30.202 -     */
  30.203 -    public boolean needsDictionary() {
  30.204 -        return impl.needDict();
  30.205 -    }
  30.206 -
  30.207 -    /**
  30.208 -     * Returns true if the end of the compressed data stream has been
  30.209 -     * reached.
  30.210 -     * @return true if the end of the compressed data stream has been
  30.211 -     * reached
  30.212 -     */
  30.213 -    public boolean finished() {
  30.214 -        return impl.finished();
  30.215 -    }
  30.216 -
  30.217 -    /**
  30.218 -     * Uncompresses bytes into specified buffer. Returns actual number
  30.219 -     * of bytes uncompressed. A return value of 0 indicates that
  30.220 -     * needsInput() or needsDictionary() should be called in order to
  30.221 -     * determine if more input data or a preset dictionary is required.
  30.222 -     * In the latter case, getAdler() can be used to get the Adler-32
  30.223 -     * value of the dictionary required.
  30.224 -     * @param b the buffer for the uncompressed data
  30.225 -     * @param off the start offset of the data
  30.226 -     * @param len the maximum number of uncompressed bytes
  30.227 -     * @return the actual number of uncompressed bytes
  30.228 -     * @exception DataFormatException if the compressed data format is invalid
  30.229 -     * @see Inflater#needsInput
  30.230 -     * @see Inflater#needsDictionary
  30.231 -     */
  30.232 -    public int inflate(byte[] b, int off, int len)
  30.233 -        throws DataFormatException
  30.234 -    {
  30.235 -        if (b == null) {
  30.236 -            throw new NullPointerException();
  30.237 -        }
  30.238 -        if (off < 0 || len < 0 || off > b.length - len) {
  30.239 -            throw new ArrayIndexOutOfBoundsException();
  30.240 -        }
  30.241 -        impl.setOutput(b, off, len);
  30.242 -        int err = impl.inflate(JzLibInflater.Z_NO_FLUSH);
  30.243 -        return impl.next_out_index - off;
  30.244 -    }
  30.245 -
  30.246 -    /**
  30.247 -     * Uncompresses bytes into specified buffer. Returns actual number
  30.248 -     * of bytes uncompressed. A return value of 0 indicates that
  30.249 -     * needsInput() or needsDictionary() should be called in order to
  30.250 -     * determine if more input data or a preset dictionary is required.
  30.251 -     * In the latter case, getAdler() can be used to get the Adler-32
  30.252 -     * value of the dictionary required.
  30.253 -     * @param b the buffer for the uncompressed data
  30.254 -     * @return the actual number of uncompressed bytes
  30.255 -     * @exception DataFormatException if the compressed data format is invalid
  30.256 -     * @see Inflater#needsInput
  30.257 -     * @see Inflater#needsDictionary
  30.258 -     */
  30.259 -    public int inflate(byte[] b) throws DataFormatException {
  30.260 -        return inflate(b, 0, b.length);
  30.261 -    }
  30.262 -
  30.263 -    /**
  30.264 -     * Returns the ADLER-32 value of the uncompressed data.
  30.265 -     * @return the ADLER-32 value of the uncompressed data
  30.266 -     */
  30.267 -    public int getAdler() {
  30.268 -        return (int) impl.getAdler();
  30.269 -    }
  30.270 -
  30.271 -    /**
  30.272 -     * Returns the total number of compressed bytes input so far.
  30.273 -     *
  30.274 -     * <p>Since the number of bytes may be greater than
  30.275 -     * Integer.MAX_VALUE, the {@link #getBytesRead()} method is now
  30.276 -     * the preferred means of obtaining this information.</p>
  30.277 -     *
  30.278 -     * @return the total number of compressed bytes input so far
  30.279 -     */
  30.280 -    public int getTotalIn() {
  30.281 -        return (int) getBytesRead();
  30.282 -    }
  30.283 -
  30.284 -    /**
  30.285 -     * Returns the total number of compressed bytes input so far.</p>
  30.286 -     *
  30.287 -     * @return the total (non-negative) number of compressed bytes input so far
  30.288 -     * @since 1.5
  30.289 -     */
  30.290 -    public long getBytesRead() {
  30.291 -        return impl.total_in;
  30.292 -    }
  30.293 -
  30.294 -    /**
  30.295 -     * Returns the total number of uncompressed bytes output so far.
  30.296 -     *
  30.297 -     * <p>Since the number of bytes may be greater than
  30.298 -     * Integer.MAX_VALUE, the {@link #getBytesWritten()} method is now
  30.299 -     * the preferred means of obtaining this information.</p>
  30.300 -     *
  30.301 -     * @return the total number of uncompressed bytes output so far
  30.302 -     */
  30.303 -    public int getTotalOut() {
  30.304 -        return (int) getBytesWritten();
  30.305 -    }
  30.306 -
  30.307 -    /**
  30.308 -     * Returns the total number of uncompressed bytes output so far.</p>
  30.309 -     *
  30.310 -     * @return the total (non-negative) number of uncompressed bytes output so far
  30.311 -     * @since 1.5
  30.312 -     */
  30.313 -    public long getBytesWritten() {
  30.314 -        return impl.total_out;
  30.315 -    }
  30.316 -
  30.317 -    /**
  30.318 -     * Resets inflater so that a new set of input data can be processed.
  30.319 -     */
  30.320 -    public void reset() {
  30.321 -        impl = new JzLibInflater(15, nowrap);
  30.322 -    }
  30.323 -
  30.324 -    /**
  30.325 -     * Closes the decompressor and discards any unprocessed input.
  30.326 -     * This method should be called when the decompressor is no longer
  30.327 -     * being used, but will also be called automatically by the finalize()
  30.328 -     * method. Once this method is called, the behavior of the Inflater
  30.329 -     * object is undefined.
  30.330 -     */
  30.331 -    public void end() {
  30.332 -        impl.end();
  30.333 -    }
  30.334 -
  30.335 -    /**
  30.336 -     * Closes the decompressor when garbage is collected.
  30.337 -     */
  30.338 -    protected void finalize() {
  30.339 -        end();
  30.340 -    }
  30.341 -}
    31.1 --- a/rt/emul/mini/src/main/java/org/apidesign/bck2brwsr/emul/zip/JzLibInflater.java	Wed May 07 11:55:06 2014 +0200
    31.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    31.3 @@ -1,137 +0,0 @@
    31.4 -/* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */
    31.5 -/*
    31.6 -Copyright (c) 2011 ymnk, JCraft,Inc. All rights reserved.
    31.7 -
    31.8 -Redistribution and use in source and binary forms, with or without
    31.9 -modification, are permitted provided that the following conditions are met:
   31.10 -
   31.11 -  1. Redistributions of source code must retain the above copyright notice,
   31.12 -     this list of conditions and the following disclaimer.
   31.13 -
   31.14 -  2. Redistributions in binary form must reproduce the above copyright 
   31.15 -     notice, this list of conditions and the following disclaimer in 
   31.16 -     the documentation and/or other materials provided with the distribution.
   31.17 -
   31.18 -  3. The names of the authors may not be used to endorse or promote products
   31.19 -     derived from this software without specific prior written permission.
   31.20 -
   31.21 -THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
   31.22 -INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
   31.23 -FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
   31.24 -INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
   31.25 -INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   31.26 -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
   31.27 -OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
   31.28 -LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
   31.29 -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
   31.30 -EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
   31.31 - */
   31.32 -/*
   31.33 - * This program is based on zlib-1.1.3, so all credit should go authors
   31.34 - * Jean-loup Gailly(jloup@gzip.org) and Mark Adler(madler@alumni.caltech.edu)
   31.35 - * and contributors of zlib.
   31.36 - */
   31.37 -
   31.38 -package org.apidesign.bck2brwsr.emul.zip;
   31.39 -
   31.40 -final class JzLibInflater extends ZStream{
   31.41 -
   31.42 -  static final private int MAX_WBITS=15;        // 32K LZ77 window
   31.43 -  static final private int DEF_WBITS=MAX_WBITS;
   31.44 -
   31.45 -  public static final int Z_NO_FLUSH=0;
   31.46 -  static final private int Z_PARTIAL_FLUSH=1;
   31.47 -  static final private int Z_SYNC_FLUSH=2;
   31.48 -  static final private int Z_FULL_FLUSH=3;
   31.49 -  static final private int Z_FINISH=4;
   31.50 -
   31.51 -  static final private int MAX_MEM_LEVEL=9;
   31.52 -
   31.53 -  static final private int Z_OK=0;
   31.54 -  static final private int Z_STREAM_END=1;
   31.55 -  static final private int Z_NEED_DICT=2;
   31.56 -  static final private int Z_ERRNO=-1;
   31.57 -  static final private int Z_STREAM_ERROR=-2;
   31.58 -  static final private int Z_DATA_ERROR=-3;
   31.59 -  static final private int Z_MEM_ERROR=-4;
   31.60 -  static final private int Z_BUF_ERROR=-5;
   31.61 -  static final private int Z_VERSION_ERROR=-6;
   31.62 -
   31.63 -  public JzLibInflater() {
   31.64 -    super();
   31.65 -    init();
   31.66 -  }
   31.67 -
   31.68 -  public JzLibInflater(int w)  {
   31.69 -    this(w, false);
   31.70 -  }
   31.71 -
   31.72 -  public JzLibInflater(int w, boolean nowrap)  {
   31.73 -    super();
   31.74 -    int ret = init(w, nowrap);
   31.75 -    if(ret!=Z_OK)
   31.76 -      throw new IllegalStateException(ret+": "+msg);
   31.77 -  }
   31.78 -
   31.79 -  private boolean finished = false;
   31.80 -
   31.81 -  public int init(){
   31.82 -    return init(DEF_WBITS);
   31.83 -  }
   31.84 -
   31.85 -  public int init(boolean nowrap){
   31.86 -    return init(DEF_WBITS, nowrap);
   31.87 -  }
   31.88 -
   31.89 -  public int init(int w){
   31.90 -    return init(w, false);
   31.91 -  }
   31.92 -
   31.93 -  public int init(int w, boolean nowrap){
   31.94 -    finished = false;
   31.95 -    istate=new Inflate(this);
   31.96 -    return istate.inflateInit(nowrap?-w:w);
   31.97 -  }
   31.98 -
   31.99 -  public int inflate(int f){
  31.100 -    if(istate==null) return Z_STREAM_ERROR;
  31.101 -    int ret = istate.inflate(f);
  31.102 -    if(ret == Z_STREAM_END) 
  31.103 -      finished = true;
  31.104 -    return ret;
  31.105 -  }
  31.106 -
  31.107 -  public int end(){
  31.108 -    finished = true;
  31.109 -    if(istate==null) return Z_STREAM_ERROR;
  31.110 -    int ret=istate.inflateEnd();
  31.111 -//    istate = null;
  31.112 -    return ret;
  31.113 -  }
  31.114 -
  31.115 -  public int sync(){
  31.116 -    if(istate == null)
  31.117 -      return Z_STREAM_ERROR;
  31.118 -    return istate.inflateSync();
  31.119 -  }
  31.120 -
  31.121 -  public int syncPoint(){
  31.122 -    if(istate == null)
  31.123 -      return Z_STREAM_ERROR;
  31.124 -    return istate.inflateSyncPoint();
  31.125 -  }
  31.126 -
  31.127 -  public int setDictionary(byte[] dictionary, int dictLength){
  31.128 -    if(istate == null)
  31.129 -      return Z_STREAM_ERROR;
  31.130 -    return istate.inflateSetDictionary(dictionary, dictLength);
  31.131 -  }
  31.132 -
  31.133 -  public boolean finished(){
  31.134 -    return istate.mode==12 /*DONE*/;
  31.135 -  }
  31.136 -
  31.137 -  public boolean needDict() {
  31.138 -    return istate == null ? false : istate.mode == Inflate.DICT0;
  31.139 -  }
  31.140 -}
    32.1 --- a/rt/emul/mini/src/main/java/org/apidesign/bck2brwsr/emul/zip/ZStream.java	Wed May 07 11:55:06 2014 +0200
    32.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    32.3 @@ -1,253 +0,0 @@
    32.4 -/* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */
    32.5 -/*
    32.6 -Copyright (c) 2000-2011 ymnk, JCraft,Inc. All rights reserved.
    32.7 -
    32.8 -Redistribution and use in source and binary forms, with or without
    32.9 -modification, are permitted provided that the following conditions are met:
   32.10 -
   32.11 -  1. Redistributions of source code must retain the above copyright notice,
   32.12 -     this list of conditions and the following disclaimer.
   32.13 -
   32.14 -  2. Redistributions in binary form must reproduce the above copyright 
   32.15 -     notice, this list of conditions and the following disclaimer in 
   32.16 -     the documentation and/or other materials provided with the distribution.
   32.17 -
   32.18 -  3. The names of the authors may not be used to endorse or promote products
   32.19 -     derived from this software without specific prior written permission.
   32.20 -
   32.21 -THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
   32.22 -INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
   32.23 -FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
   32.24 -INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
   32.25 -INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   32.26 -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
   32.27 -OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
   32.28 -LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
   32.29 -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
   32.30 -EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
   32.31 - */
   32.32 -/*
   32.33 - * This program is based on zlib-1.1.3, so all credit should go authors
   32.34 - * Jean-loup Gailly(jloup@gzip.org) and Mark Adler(madler@alumni.caltech.edu)
   32.35 - * and contributors of zlib.
   32.36 - */
   32.37 -
   32.38 -package org.apidesign.bck2brwsr.emul.zip;
   32.39 -
   32.40 -import org.apidesign.bck2brwsr.emul.lang.System;
   32.41 -
   32.42 -/**
   32.43 - * ZStream
   32.44 - *
   32.45 - * @deprecated  Not for public use in the future.
   32.46 - */
   32.47 -@Deprecated
   32.48 -class ZStream{
   32.49 -
   32.50 -  static final private int MAX_WBITS=15;        // 32K LZ77 window
   32.51 -  static final private int DEF_WBITS=MAX_WBITS;
   32.52 -
   32.53 -  static final private int Z_NO_FLUSH=0;
   32.54 -  static final private int Z_PARTIAL_FLUSH=1;
   32.55 -  static final private int Z_SYNC_FLUSH=2;
   32.56 -  static final private int Z_FULL_FLUSH=3;
   32.57 -  static final private int Z_FINISH=4;
   32.58 -
   32.59 -  static final private int MAX_MEM_LEVEL=9;
   32.60 -
   32.61 -  static final private int Z_OK=0;
   32.62 -  static final private int Z_STREAM_END=1;
   32.63 -  static final private int Z_NEED_DICT=2;
   32.64 -  static final private int Z_ERRNO=-1;
   32.65 -  static final private int Z_STREAM_ERROR=-2;
   32.66 -  static final private int Z_DATA_ERROR=-3;
   32.67 -  static final private int Z_MEM_ERROR=-4;
   32.68 -  static final private int Z_BUF_ERROR=-5;
   32.69 -  static final private int Z_VERSION_ERROR=-6;
   32.70 -
   32.71 -  public byte[] next_in;     // next input byte
   32.72 -  public int next_in_index;
   32.73 -  public int avail_in;       // number of bytes available at next_in
   32.74 -  public long total_in;      // total nb of input bytes read so far
   32.75 -
   32.76 -  public byte[] next_out;    // next output byte should be put there
   32.77 -  public int next_out_index;
   32.78 -  public int avail_out;      // remaining free space at next_out
   32.79 -  public long total_out;     // total nb of bytes output so far
   32.80 -
   32.81 -  public String msg;
   32.82 -
   32.83 -  Inflate istate; 
   32.84 -
   32.85 -  int data_type; // best guess about the data type: ascii or binary
   32.86 -
   32.87 -  Checksum adler;
   32.88 -
   32.89 -  public ZStream(){
   32.90 -    this(new Adler32());
   32.91 -  }
   32.92 -
   32.93 -  public ZStream(Checksum adler){
   32.94 -    this.adler=adler;
   32.95 -  }
   32.96 -
   32.97 -  public int inflateInit(){
   32.98 -    return inflateInit(DEF_WBITS);
   32.99 -  }
  32.100 -  public int inflateInit(boolean nowrap){
  32.101 -    return inflateInit(DEF_WBITS, nowrap);
  32.102 -  }
  32.103 -  public int inflateInit(int w){
  32.104 -    return inflateInit(w, false);
  32.105 -  }
  32.106 -
  32.107 -  public int inflateInit(int w, boolean nowrap){
  32.108 -    istate=new Inflate(this);
  32.109 -    return istate.inflateInit(nowrap?-w:w);
  32.110 -  }
  32.111 -
  32.112 -  public int inflate(int f){
  32.113 -    if(istate==null) return Z_STREAM_ERROR;
  32.114 -    return istate.inflate(f);
  32.115 -  }
  32.116 -  public int inflateEnd(){
  32.117 -    if(istate==null) return Z_STREAM_ERROR;
  32.118 -    int ret=istate.inflateEnd();
  32.119 -//    istate = null;
  32.120 -    return ret;
  32.121 -  }
  32.122 -  
  32.123 -  public int inflateSync(){
  32.124 -    if(istate == null)
  32.125 -      return Z_STREAM_ERROR;
  32.126 -    return istate.inflateSync();
  32.127 -  }
  32.128 -  public int inflateSyncPoint(){
  32.129 -    if(istate == null)
  32.130 -      return Z_STREAM_ERROR;
  32.131 -    return istate.inflateSyncPoint();
  32.132 -  }
  32.133 -  public int inflateSetDictionary(byte[] dictionary, int dictLength){
  32.134 -    if(istate == null)
  32.135 -      return Z_STREAM_ERROR;
  32.136 -    return istate.inflateSetDictionary(dictionary, dictLength);
  32.137 -  }
  32.138 -  public boolean inflateFinished(){
  32.139 -    return istate.mode==12 /*DONE*/;
  32.140 -  }
  32.141 -
  32.142 -
  32.143 -  public long getAdler(){
  32.144 -    return adler.getValue();
  32.145 -  }
  32.146 -
  32.147 -  public void free(){
  32.148 -    next_in=null;
  32.149 -    next_out=null;
  32.150 -    msg=null;
  32.151 -  }
  32.152 -
  32.153 -  public void setOutput(byte[] buf){
  32.154 -    setOutput(buf, 0, buf.length); 
  32.155 -  }
  32.156 -
  32.157 -  public void setOutput(byte[] buf, int off, int len){
  32.158 -    next_out = buf;
  32.159 -    next_out_index = off;
  32.160 -    avail_out = len;
  32.161 -  }
  32.162 -
  32.163 -  public void setInput(byte[] buf){
  32.164 -    setInput(buf, 0, buf.length, false); 
  32.165 -  }
  32.166 -
  32.167 -  public void setInput(byte[] buf, boolean append){
  32.168 -    setInput(buf, 0, buf.length, append); 
  32.169 -  }
  32.170 -
  32.171 -  public void setInput(byte[] buf, int off, int len, boolean append){
  32.172 -    if(len<=0 && append && next_in!=null) return;
  32.173 -
  32.174 -    if(avail_in>0 && append){  
  32.175 -      byte[] tmp = new byte[avail_in+len];
  32.176 -      System.arraycopy(next_in, next_in_index, tmp, 0, avail_in);
  32.177 -      System.arraycopy(buf, off, tmp, avail_in, len);
  32.178 -      next_in=tmp;
  32.179 -      next_in_index=0;
  32.180 -      avail_in+=len;
  32.181 -    }
  32.182 -    else{
  32.183 -      next_in=buf;
  32.184 -      next_in_index=off;
  32.185 -      avail_in=len;
  32.186 -    }
  32.187 -  }
  32.188 -
  32.189 -  public byte[] getNextIn(){
  32.190 -    return next_in;
  32.191 -  }
  32.192 -
  32.193 -  public void setNextIn(byte[] next_in){
  32.194 -    this.next_in = next_in;
  32.195 -  }
  32.196 -
  32.197 -  public int getNextInIndex(){
  32.198 -    return next_in_index;
  32.199 -  }
  32.200 -
  32.201 -  public void setNextInIndex(int next_in_index){
  32.202 -    this.next_in_index = next_in_index;
  32.203 -  }
  32.204 -
  32.205 -  public int getAvailIn(){
  32.206 -    return avail_in;
  32.207 -  }
  32.208 -
  32.209 -  public void setAvailIn(int avail_in){
  32.210 -    this.avail_in = avail_in;
  32.211 -  }
  32.212 -
  32.213 -  public byte[] getNextOut(){
  32.214 -    return next_out;
  32.215 -  }
  32.216 -
  32.217 -  public void setNextOut(byte[] next_out){
  32.218 -    this.next_out = next_out;
  32.219 -  }
  32.220 -
  32.221 -  public int getNextOutIndex(){
  32.222 -    return next_out_index;
  32.223 -  }
  32.224 -
  32.225 -  public void setNextOutIndex(int next_out_index){
  32.226 -    this.next_out_index = next_out_index;
  32.227 -  }
  32.228 -
  32.229 -  public int getAvailOut(){
  32.230 -    return avail_out;
  32.231 -
  32.232 -  }
  32.233 -
  32.234 -  public void setAvailOut(int avail_out){
  32.235 -    this.avail_out = avail_out;
  32.236 -  }
  32.237 -
  32.238 -  public long getTotalOut(){
  32.239 -    return total_out;
  32.240 -  }
  32.241 -
  32.242 -  public long getTotalIn(){
  32.243 -    return total_in;
  32.244 -  }
  32.245 -
  32.246 -  public String getMessage(){
  32.247 -    return msg;
  32.248 -  }
  32.249 -
  32.250 -  /**
  32.251 -   * Those methods are expected to be override by Inflater and Deflater.
  32.252 -   * In the future, they will become abstract methods.
  32.253 -   */ 
  32.254 -  public int end(){ return Z_OK; }
  32.255 -  public boolean finished(){ return false; }
  32.256 -}
    33.1 --- a/rt/emul/mini/src/main/java/org/apidesign/bck2brwsr/emul/zip/ZipConstants64.java	Wed May 07 11:55:06 2014 +0200
    33.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    33.3 @@ -1,84 +0,0 @@
    33.4 -/*
    33.5 - * Copyright (c) 1995, 1996, Oracle and/or its affiliates. All rights reserved.
    33.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    33.7 - *
    33.8 - * This code is free software; you can redistribute it and/or modify it
    33.9 - * under the terms of the GNU General Public License version 2 only, as
   33.10 - * published by the Free Software Foundation.  Oracle designates this
   33.11 - * particular file as subject to the "Classpath" exception as provided
   33.12 - * by Oracle in the LICENSE file that accompanied this code.
   33.13 - *
   33.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
   33.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   33.16 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   33.17 - * version 2 for more details (a copy is included in the LICENSE file that
   33.18 - * accompanied this code).
   33.19 - *
   33.20 - * You should have received a copy of the GNU General Public License version
   33.21 - * 2 along with this work; if not, write to the Free Software Foundation,
   33.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   33.23 - *
   33.24 - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   33.25 - * or visit www.oracle.com if you need additional information or have any
   33.26 - * questions.
   33.27 - */
   33.28 -
   33.29 -package org.apidesign.bck2brwsr.emul.zip;
   33.30 -
   33.31 -/*
   33.32 - * This class defines the constants that are used by the classes
   33.33 - * which manipulate Zip64 files.
   33.34 - */
   33.35 -
   33.36 -public class ZipConstants64 {
   33.37 -
   33.38 -    /*
   33.39 -     * ZIP64 constants
   33.40 -     */
   33.41 -    static final long ZIP64_ENDSIG = 0x06064b50L;  // "PK\006\006"
   33.42 -    static final long ZIP64_LOCSIG = 0x07064b50L;  // "PK\006\007"
   33.43 -    static final int  ZIP64_ENDHDR = 56;           // ZIP64 end header size
   33.44 -    static final int  ZIP64_LOCHDR = 20;           // ZIP64 end loc header size
   33.45 -    static final int  ZIP64_EXTHDR = 24;           // EXT header size
   33.46 -    static final int  ZIP64_EXTID  = 0x0001;       // Extra field Zip64 header ID
   33.47 -
   33.48 -    static final int  ZIP64_MAGICCOUNT = 0xFFFF;
   33.49 -    static final long ZIP64_MAGICVAL = 0xFFFFFFFFL;
   33.50 -
   33.51 -    /*
   33.52 -     * Zip64 End of central directory (END) header field offsets
   33.53 -     */
   33.54 -    static final int  ZIP64_ENDLEN = 4;       // size of zip64 end of central dir
   33.55 -    static final int  ZIP64_ENDVEM = 12;      // version made by
   33.56 -    static final int  ZIP64_ENDVER = 14;      // version needed to extract
   33.57 -    static final int  ZIP64_ENDNMD = 16;      // number of this disk
   33.58 -    static final int  ZIP64_ENDDSK = 20;      // disk number of start
   33.59 -    static final int  ZIP64_ENDTOD = 24;      // total number of entries on this disk
   33.60 -    static final int  ZIP64_ENDTOT = 32;      // total number of entries
   33.61 -    static final int  ZIP64_ENDSIZ = 40;      // central directory size in bytes
   33.62 -    static final int  ZIP64_ENDOFF = 48;      // offset of first CEN header
   33.63 -    static final int  ZIP64_ENDEXT = 56;      // zip64 extensible data sector
   33.64 -
   33.65 -    /*
   33.66 -     * Zip64 End of central directory locator field offsets
   33.67 -     */
   33.68 -    static final int  ZIP64_LOCDSK = 4;       // disk number start
   33.69 -    static final int  ZIP64_LOCOFF = 8;       // offset of zip64 end
   33.70 -    static final int  ZIP64_LOCTOT = 16;      // total number of disks
   33.71 -
   33.72 -    /*
   33.73 -     * Zip64 Extra local (EXT) header field offsets
   33.74 -     */
   33.75 -    static final int  ZIP64_EXTCRC = 4;       // uncompressed file crc-32 value
   33.76 -    static final int  ZIP64_EXTSIZ = 8;       // compressed size, 8-byte
   33.77 -    static final int  ZIP64_EXTLEN = 16;      // uncompressed size, 8-byte
   33.78 -
   33.79 -    /*
   33.80 -     * Language encoding flag EFS
   33.81 -     */
   33.82 -    static final int EFS = 0x800;       // If this bit is set the filename and
   33.83 -                                        // comment fields for this file must be
   33.84 -                                        // encoded using UTF-8.
   33.85 -
   33.86 -    private ZipConstants64() {}
   33.87 -}
    34.1 --- a/rt/emul/mini/src/main/java/org/apidesign/bck2brwsr/emul/zip/ZipInputStream.java	Wed May 07 11:55:06 2014 +0200
    34.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    34.3 @@ -1,468 +0,0 @@
    34.4 -/*
    34.5 - * Copyright (c) 1996, 2009, Oracle and/or its affiliates. All rights reserved.
    34.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    34.7 - *
    34.8 - * This code is free software; you can redistribute it and/or modify it
    34.9 - * under the terms of the GNU General Public License version 2 only, as
   34.10 - * published by the Free Software Foundation.  Oracle designates this
   34.11 - * particular file as subject to the "Classpath" exception as provided
   34.12 - * by Oracle in the LICENSE file that accompanied this code.
   34.13 - *
   34.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
   34.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   34.16 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   34.17 - * version 2 for more details (a copy is included in the LICENSE file that
   34.18 - * accompanied this code).
   34.19 - *
   34.20 - * You should have received a copy of the GNU General Public License version
   34.21 - * 2 along with this work; if not, write to the Free Software Foundation,
   34.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   34.23 - *
   34.24 - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   34.25 - * or visit www.oracle.com if you need additional information or have any
   34.26 - * questions.
   34.27 - */
   34.28 -
   34.29 -package org.apidesign.bck2brwsr.emul.zip;
   34.30 -
   34.31 -import java.util.zip.*;
   34.32 -import java.io.InputStream;
   34.33 -import java.io.IOException;
   34.34 -import java.io.EOFException;
   34.35 -import java.io.PushbackInputStream;
   34.36 -import static org.apidesign.bck2brwsr.emul.zip.ZipConstants64.*;
   34.37 -import static java.util.zip.ZipInputStream.*;
   34.38 -
   34.39 -/**
   34.40 - * This class implements an input stream filter for reading files in the
   34.41 - * ZIP file format. Includes support for both compressed and uncompressed
   34.42 - * entries.
   34.43 - *
   34.44 - * @author      David Connelly
   34.45 - */
   34.46 -public
   34.47 -class ZipInputStream extends InflaterInputStream  {
   34.48 -    private ZipEntry entry;
   34.49 -    private int flag;
   34.50 -    private CRC32 crc = new CRC32();
   34.51 -    private long remaining;
   34.52 -    private byte[] tmpbuf = new byte[512];
   34.53 -
   34.54 -    private static final int STORED = ZipEntry.STORED;
   34.55 -    private static final int DEFLATED = ZipEntry.DEFLATED;
   34.56 -
   34.57 -    private boolean closed = false;
   34.58 -    // this flag is set to true after EOF has reached for
   34.59 -    // one entry
   34.60 -    private boolean entryEOF = false;
   34.61 -
   34.62 -    /**
   34.63 -     * Check to make sure that this stream has not been closed
   34.64 -     */
   34.65 -    private void ensureOpen() throws IOException {
   34.66 -        if (closed) {
   34.67 -            throw new IOException("Stream closed");
   34.68 -        }
   34.69 -    }
   34.70 -
   34.71 -    /**
   34.72 -     * Creates a new ZIP input stream.
   34.73 -     *
   34.74 -     * <p>The UTF-8 {@link java.nio.charset.Charset charset} is used to
   34.75 -     * decode the entry names.
   34.76 -     *
   34.77 -     * @param in the actual input stream
   34.78 -     */
   34.79 -    public ZipInputStream(InputStream in) {
   34.80 -//        this(in, "UTF-8");
   34.81 -        super(new PushbackInputStream(in, 512), new Inflater(true), 512);
   34.82 -        //usesDefaultInflater = true;
   34.83 -        if(in == null) {
   34.84 -            throw new NullPointerException("in is null");
   34.85 -        }
   34.86 -    }
   34.87 -
   34.88 -    /**
   34.89 -     * Creates a new ZIP input stream.
   34.90 -     *
   34.91 -     * @param in the actual input stream
   34.92 -     *
   34.93 -     * @param charset
   34.94 -     *        The {@linkplain java.nio.charset.Charset charset} to be
   34.95 -     *        used to decode the ZIP entry name (ignored if the
   34.96 -     *        <a href="package-summary.html#lang_encoding"> language
   34.97 -     *        encoding bit</a> of the ZIP entry's general purpose bit
   34.98 -     *        flag is set).
   34.99 -     *
  34.100 -     * @since 1.7
  34.101 -     *
  34.102 -    public ZipInputStream(InputStream in, Charset charset) {
  34.103 -        super(new PushbackInputStream(in, 512), new Inflater(true), 512);
  34.104 -        usesDefaultInflater = true;
  34.105 -        if(in == null) {
  34.106 -            throw new NullPointerException("in is null");
  34.107 -        }
  34.108 -        if (charset == null)
  34.109 -            throw new NullPointerException("charset is null");
  34.110 -        this.zc = ZipCoder.get(charset);
  34.111 -    }
  34.112 -    */
  34.113 -
  34.114 -    /**
  34.115 -     * Reads the next ZIP file entry and positions the stream at the
  34.116 -     * beginning of the entry data.
  34.117 -     * @return the next ZIP file entry, or null if there are no more entries
  34.118 -     * @exception ZipException if a ZIP file error has occurred
  34.119 -     * @exception IOException if an I/O error has occurred
  34.120 -     */
  34.121 -    public ZipEntry getNextEntry() throws IOException {
  34.122 -        ensureOpen();
  34.123 -        if (entry != null) {
  34.124 -            closeEntry();
  34.125 -        }
  34.126 -        crc.reset();
  34.127 -        inf.reset();
  34.128 -        if ((entry = readLOC()) == null) {
  34.129 -            return null;
  34.130 -        }
  34.131 -        if (entry.getMethod() == STORED) {
  34.132 -            remaining = entry.getSize();
  34.133 -        }
  34.134 -        entryEOF = false;
  34.135 -        return entry;
  34.136 -    }
  34.137 -
  34.138 -    /**
  34.139 -     * Closes the current ZIP entry and positions the stream for reading the
  34.140 -     * next entry.
  34.141 -     * @exception ZipException if a ZIP file error has occurred
  34.142 -     * @exception IOException if an I/O error has occurred
  34.143 -     */
  34.144 -    public void closeEntry() throws IOException {
  34.145 -        ensureOpen();
  34.146 -        while (read(tmpbuf, 0, tmpbuf.length) != -1) ;
  34.147 -        entryEOF = true;
  34.148 -    }
  34.149 -
  34.150 -    /**
  34.151 -     * Returns 0 after EOF has reached for the current entry data,
  34.152 -     * otherwise always return 1.
  34.153 -     * <p>
  34.154 -     * Programs should not count on this method to return the actual number
  34.155 -     * of bytes that could be read without blocking.
  34.156 -     *
  34.157 -     * @return     1 before EOF and 0 after EOF has reached for current entry.
  34.158 -     * @exception  IOException  if an I/O error occurs.
  34.159 -     *
  34.160 -     */
  34.161 -    public int available() throws IOException {
  34.162 -        ensureOpen();
  34.163 -        if (entryEOF) {
  34.164 -            return 0;
  34.165 -        } else {
  34.166 -            return 1;
  34.167 -        }
  34.168 -    }
  34.169 -
  34.170 -    /**
  34.171 -     * Reads from the current ZIP entry into an array of bytes.
  34.172 -     * If <code>len</code> is not zero, the method
  34.173 -     * blocks until some input is available; otherwise, no
  34.174 -     * bytes are read and <code>0</code> is returned.
  34.175 -     * @param b the buffer into which the data is read
  34.176 -     * @param off the start offset in the destination array <code>b</code>
  34.177 -     * @param len the maximum number of bytes read
  34.178 -     * @return the actual number of bytes read, or -1 if the end of the
  34.179 -     *         entry is reached
  34.180 -     * @exception  NullPointerException if <code>b</code> is <code>null</code>.
  34.181 -     * @exception  IndexOutOfBoundsException if <code>off</code> is negative,
  34.182 -     * <code>len</code> is negative, or <code>len</code> is greater than
  34.183 -     * <code>b.length - off</code>
  34.184 -     * @exception ZipException if a ZIP file error has occurred
  34.185 -     * @exception IOException if an I/O error has occurred
  34.186 -     */
  34.187 -    public int read(byte[] b, int off, int len) throws IOException {
  34.188 -        ensureOpen();
  34.189 -        if (off < 0 || len < 0 || off > b.length - len) {
  34.190 -            throw new IndexOutOfBoundsException();
  34.191 -        } else if (len == 0) {
  34.192 -            return 0;
  34.193 -        }
  34.194 -
  34.195 -        if (entry == null) {
  34.196 -            return -1;
  34.197 -        }
  34.198 -        switch (entry.getMethod()) {
  34.199 -        case DEFLATED:
  34.200 -            len = super.read(b, off, len);
  34.201 -            if (len == -1) {
  34.202 -                readEnd(entry);
  34.203 -                entryEOF = true;
  34.204 -                entry = null;
  34.205 -            } else {
  34.206 -                crc.update(b, off, len);
  34.207 -            }
  34.208 -            return len;
  34.209 -        case STORED:
  34.210 -            if (remaining <= 0) {
  34.211 -                entryEOF = true;
  34.212 -                entry = null;
  34.213 -                return -1;
  34.214 -            }
  34.215 -            if (len > remaining) {
  34.216 -                len = (int)remaining;
  34.217 -            }
  34.218 -            len = in.read(b, off, len);
  34.219 -            if (len == -1) {
  34.220 -                throw new ZipException("unexpected EOF");
  34.221 -            }
  34.222 -            crc.update(b, off, len);
  34.223 -            remaining -= len;
  34.224 -            if (remaining == 0 && entry.getCrc() != crc.getValue()) {
  34.225 -                throw new ZipException(
  34.226 -                    "invalid entry CRC (expected 0x" + Long.toHexString(entry.getCrc()) +
  34.227 -                    " but got 0x" + Long.toHexString(crc.getValue()) + ")");
  34.228 -            }
  34.229 -            return len;
  34.230 -        default:
  34.231 -            throw new ZipException("invalid compression method");
  34.232 -        }
  34.233 -    }
  34.234 -
  34.235 -    /**
  34.236 -     * Skips specified number of bytes in the current ZIP entry.
  34.237 -     * @param n the number of bytes to skip
  34.238 -     * @return the actual number of bytes skipped
  34.239 -     * @exception ZipException if a ZIP file error has occurred
  34.240 -     * @exception IOException if an I/O error has occurred
  34.241 -     * @exception IllegalArgumentException if n < 0
  34.242 -     */
  34.243 -    public long skip(long n) throws IOException {
  34.244 -        if (n < 0) {
  34.245 -            throw new IllegalArgumentException("negative skip length");
  34.246 -        }
  34.247 -        ensureOpen();
  34.248 -        int max = (int)Math.min(n, Integer.MAX_VALUE);
  34.249 -        int total = 0;
  34.250 -        while (total < max) {
  34.251 -            int len = max - total;
  34.252 -            if (len > tmpbuf.length) {
  34.253 -                len = tmpbuf.length;
  34.254 -            }
  34.255 -            len = read(tmpbuf, 0, len);
  34.256 -            if (len == -1) {
  34.257 -                entryEOF = true;
  34.258 -                break;
  34.259 -            }
  34.260 -            total += len;
  34.261 -        }
  34.262 -        return total;
  34.263 -    }
  34.264 -
  34.265 -    /**
  34.266 -     * Closes this input stream and releases any system resources associated
  34.267 -     * with the stream.
  34.268 -     * @exception IOException if an I/O error has occurred
  34.269 -     */
  34.270 -    public void close() throws IOException {
  34.271 -        if (!closed) {
  34.272 -            super.close();
  34.273 -            closed = true;
  34.274 -        }
  34.275 -    }
  34.276 -
  34.277 -    private byte[] b = new byte[256];
  34.278 -
  34.279 -    /*
  34.280 -     * Reads local file (LOC) header for next entry.
  34.281 -     */
  34.282 -    private ZipEntry readLOC() throws IOException {
  34.283 -        try {
  34.284 -            readFully(tmpbuf, 0, LOCHDR);
  34.285 -        } catch (EOFException e) {
  34.286 -            return null;
  34.287 -        }
  34.288 -        if (get32(tmpbuf, 0) != LOCSIG) {
  34.289 -            return null;
  34.290 -        }
  34.291 -        // get flag first, we need check EFS.
  34.292 -        flag = get16(tmpbuf, LOCFLG);
  34.293 -        // get the entry name and create the ZipEntry first
  34.294 -        int len = get16(tmpbuf, LOCNAM);
  34.295 -        int blen = b.length;
  34.296 -        if (len > blen) {
  34.297 -            do
  34.298 -                blen = blen * 2;
  34.299 -            while (len > blen);
  34.300 -            b = new byte[blen];
  34.301 -        }
  34.302 -        readFully(b, 0, len);
  34.303 -        // Force to use UTF-8 if the EFS bit is ON, even the cs is NOT UTF-8
  34.304 -        ZipEntry e = createZipEntry(((flag & EFS) != 0)
  34.305 -                                    ? toStringUTF8(b, len)
  34.306 -                                    : toString(b, len));
  34.307 -        // now get the remaining fields for the entry
  34.308 -        if ((flag & 1) == 1) {
  34.309 -            throw new ZipException("encrypted ZIP entry not supported");
  34.310 -        }
  34.311 -        e.setMethod(get16(tmpbuf, LOCHOW));
  34.312 -        e.setTime(get32(tmpbuf, LOCTIM));
  34.313 -        if ((flag & 8) == 8) {
  34.314 -            /* "Data Descriptor" present */
  34.315 -            if (e.getMethod() != DEFLATED) {
  34.316 -                throw new ZipException(
  34.317 -                        "only DEFLATED entries can have EXT descriptor");
  34.318 -            }
  34.319 -        } else {
  34.320 -            e.setCrc(get32(tmpbuf, LOCCRC));
  34.321 -            e.setCompressedSize(get32(tmpbuf, LOCSIZ));
  34.322 -            e.setSize(get32(tmpbuf, LOCLEN));
  34.323 -        }
  34.324 -        len = get16(tmpbuf, LOCEXT);
  34.325 -        if (len > 0) {
  34.326 -            byte[] bb = new byte[len];
  34.327 -            readFully(bb, 0, len);
  34.328 -            e.setExtra(bb);
  34.329 -            // extra fields are in "HeaderID(2)DataSize(2)Data... format
  34.330 -            if (e.getCompressedSize() == ZIP64_MAGICVAL || e.getCompressedSize() == ZIP64_MAGICVAL) {
  34.331 -                int off = 0;
  34.332 -                while (off + 4 < len) {
  34.333 -                    int sz = get16(bb, off + 2);
  34.334 -                    if (get16(bb, off) == ZIP64_EXTID) {
  34.335 -                        off += 4;
  34.336 -                        // LOC extra zip64 entry MUST include BOTH original and
  34.337 -                        // compressed file size fields
  34.338 -                        if (sz < 16 || (off + sz) > len ) {
  34.339 -                            // Invalid zip64 extra fields, simply skip. Even it's
  34.340 -                            // rare, it's possible the entry size happens to be
  34.341 -                            // the magic value and it "accidnetly" has some bytes
  34.342 -                            // in extra match the id.
  34.343 -                            return e;
  34.344 -                        }
  34.345 -                        e.setSize(get64(bb, off));
  34.346 -                        e.setCompressedSize(get64(bb, off + 8));
  34.347 -                        break;
  34.348 -                    }
  34.349 -                    off += (sz + 4);
  34.350 -                }
  34.351 -            }
  34.352 -        }
  34.353 -        return e;
  34.354 -    }
  34.355 -
  34.356 -    /**
  34.357 -     * Creates a new <code>ZipEntry</code> object for the specified
  34.358 -     * entry name.
  34.359 -     *
  34.360 -     * @param name the ZIP file entry name
  34.361 -     * @return the ZipEntry just created
  34.362 -     */
  34.363 -    protected ZipEntry createZipEntry(String name) {
  34.364 -        return new ZipEntry(name);
  34.365 -    }
  34.366 -
  34.367 -    /*
  34.368 -     * Reads end of deflated entry as well as EXT descriptor if present.
  34.369 -     */
  34.370 -    private void readEnd(ZipEntry e) throws IOException {
  34.371 -        int n = inf.getRemaining();
  34.372 -        if (n > 0) {
  34.373 -            ((PushbackInputStream)in).unread(buf, len - n, n);
  34.374 -        }
  34.375 -        if ((flag & 8) == 8) {
  34.376 -            /* "Data Descriptor" present */
  34.377 -            if (inf.getBytesWritten() > ZIP64_MAGICVAL ||
  34.378 -                inf.getBytesRead() > ZIP64_MAGICVAL) {
  34.379 -                // ZIP64 format
  34.380 -                readFully(tmpbuf, 0, ZIP64_EXTHDR);
  34.381 -                long sig = get32(tmpbuf, 0);
  34.382 -                if (sig != EXTSIG) { // no EXTSIG present
  34.383 -                    e.setCrc(sig);
  34.384 -                    e.setCompressedSize(get64(tmpbuf, ZIP64_EXTSIZ - ZIP64_EXTCRC));
  34.385 -                    e.setSize(get64(tmpbuf, ZIP64_EXTLEN - ZIP64_EXTCRC));
  34.386 -                    ((PushbackInputStream)in).unread(
  34.387 -                        tmpbuf, ZIP64_EXTHDR - ZIP64_EXTCRC - 1, ZIP64_EXTCRC);
  34.388 -                } else {
  34.389 -                    e.setCrc(get32(tmpbuf, ZIP64_EXTCRC));
  34.390 -                    e.setCompressedSize(get64(tmpbuf, ZIP64_EXTSIZ));
  34.391 -                    e.setSize(get64(tmpbuf, ZIP64_EXTLEN));
  34.392 -                }
  34.393 -            } else {
  34.394 -                readFully(tmpbuf, 0, EXTHDR);
  34.395 -                long sig = get32(tmpbuf, 0);
  34.396 -                if (sig != EXTSIG) { // no EXTSIG present
  34.397 -                    e.setCrc(sig);
  34.398 -                    e.setCompressedSize(get32(tmpbuf, EXTSIZ - EXTCRC));
  34.399 -                    e.setSize(get32(tmpbuf, EXTLEN - EXTCRC));
  34.400 -                    ((PushbackInputStream)in).unread(
  34.401 -                                               tmpbuf, EXTHDR - EXTCRC - 1, EXTCRC);
  34.402 -                } else {
  34.403 -                    e.setCrc(get32(tmpbuf, EXTCRC));
  34.404 -                    e.setCompressedSize(get32(tmpbuf, EXTSIZ));
  34.405 -                    e.setSize(get32(tmpbuf, EXTLEN));
  34.406 -                }
  34.407 -            }
  34.408 -        }
  34.409 -        if (e.getSize() != inf.getBytesWritten()) {
  34.410 -            throw new ZipException(
  34.411 -                "invalid entry size (expected " + e.getSize() +
  34.412 -                " but got " + inf.getBytesWritten() + " bytes)");
  34.413 -        }
  34.414 -        if (e.getCompressedSize() != inf.getBytesRead()) {
  34.415 -            throw new ZipException(
  34.416 -                "invalid entry compressed size (expected " + e.getCompressedSize() +
  34.417 -                " but got " + inf.getBytesRead() + " bytes)");
  34.418 -        }
  34.419 -        if (e.getCrc() != crc.getValue()) {
  34.420 -            throw new ZipException(
  34.421 -                "invalid entry CRC (expected 0x" + Long.toHexString(e.getCrc()) +
  34.422 -                " but got 0x" + Long.toHexString(crc.getValue()) + ")");
  34.423 -        }
  34.424 -    }
  34.425 -
  34.426 -    /*
  34.427 -     * Reads bytes, blocking until all bytes are read.
  34.428 -     */
  34.429 -    private void readFully(byte[] b, int off, int len) throws IOException {
  34.430 -        while (len > 0) {
  34.431 -            int n = in.read(b, off, len);
  34.432 -            if (n == -1) {
  34.433 -                throw new EOFException();
  34.434 -            }
  34.435 -            off += n;
  34.436 -            len -= n;
  34.437 -        }
  34.438 -    }
  34.439 -
  34.440 -    /*
  34.441 -     * Fetches unsigned 16-bit value from byte array at specified offset.
  34.442 -     * The bytes are assumed to be in Intel (little-endian) byte order.
  34.443 -     */
  34.444 -    private static final int get16(byte b[], int off) {
  34.445 -        return (b[off] & 0xff) | ((b[off+1] & 0xff) << 8);
  34.446 -    }
  34.447 -
  34.448 -    /*
  34.449 -     * Fetches unsigned 32-bit value from byte array at specified offset.
  34.450 -     * The bytes are assumed to be in Intel (little-endian) byte order.
  34.451 -     */
  34.452 -    private static final long get32(byte b[], int off) {
  34.453 -        return (get16(b, off) | ((long)get16(b, off+2) << 16)) & 0xffffffffL;
  34.454 -    }
  34.455 -
  34.456 -    /*
  34.457 -     * Fetches signed 64-bit value from byte array at specified offset.
  34.458 -     * The bytes are assumed to be in Intel (little-endian) byte order.
  34.459 -     */
  34.460 -    private static final long get64(byte b[], int off) {
  34.461 -        return get32(b, off) | (get32(b, off+4) << 32);
  34.462 -    }
  34.463 -
  34.464 -    private static String toStringUTF8(byte[] arr, int len) {
  34.465 -        return new String(arr, 0, len);
  34.466 -    }
  34.467 -    
  34.468 -    private static String toString(byte[] b, int len) {
  34.469 -        return new String(b, 0, len);
  34.470 -    }
  34.471 -}
    35.1 --- a/rt/emul/pom.xml	Wed May 07 11:55:06 2014 +0200
    35.2 +++ b/rt/emul/pom.xml	Wed May 07 16:47:24 2014 +0200
    35.3 @@ -16,5 +16,6 @@
    35.4      <module>compact</module>
    35.5      <module>brwsrtest</module>
    35.6      <module>fake</module>
    35.7 +    <module>zip</module>
    35.8    </modules>
    35.9  </project>
    36.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    36.2 +++ b/rt/emul/zip/pom.xml	Wed May 07 16:47:24 2014 +0200
    36.3 @@ -0,0 +1,51 @@
    36.4 +<?xml version="1.0" encoding="UTF-8"?>
    36.5 +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    36.6 +    <modelVersion>4.0.0</modelVersion>
    36.7 +    <parent>
    36.8 +        <groupId>org.apidesign.bck2brwsr</groupId>
    36.9 +        <artifactId>emul.pom</artifactId>
   36.10 +        <version>0.9-SNAPSHOT</version>
   36.11 +    </parent>
   36.12 +    <artifactId>emul.zip</artifactId>
   36.13 +    <name>Unzip by JCraft for Bck2Brwsr</name>
   36.14 +    <description>>
   36.15 +        100% pure Java re-implementation of Zlib
   36.16 +        that allows usage of JAR files with Bck2Brwsr 
   36.17 +        virtual machine.
   36.18 +    </description>
   36.19 +    <packaging>jar</packaging>
   36.20 +    <dependencies>
   36.21 +        <dependency>
   36.22 +            <groupId>org.apidesign.bck2brwsr</groupId>
   36.23 +            <artifactId>core</artifactId>
   36.24 +            <version>${project.version}</version>
   36.25 +            <type>jar</type>
   36.26 +        </dependency>
   36.27 +        <dependency>
   36.28 +            <groupId>org.testng</groupId>
   36.29 +            <artifactId>testng</artifactId>
   36.30 +            <scope>test</scope>
   36.31 +        </dependency>
   36.32 +        <dependency>
   36.33 +            <groupId>org.apidesign.bck2brwsr</groupId>
   36.34 +            <artifactId>emul.mini</artifactId>
   36.35 +            <version>${project.version}</version>
   36.36 +            <scope>compile</scope>
   36.37 +            <type>jar</type>
   36.38 +        </dependency>
   36.39 +        <dependency>
   36.40 +            <groupId>org.apidesign.bck2brwsr</groupId>
   36.41 +            <artifactId>vmtest</artifactId>
   36.42 +            <version>${project.version}</version>
   36.43 +            <scope>test</scope>
   36.44 +            <type>jar</type>
   36.45 +        </dependency>
   36.46 +        <dependency>
   36.47 +            <groupId>org.apidesign.bck2brwsr</groupId>
   36.48 +            <artifactId>launcher.http</artifactId>
   36.49 +            <version>${project.version}</version>
   36.50 +            <scope>test</scope>
   36.51 +            <type>jar</type>
   36.52 +        </dependency>
   36.53 +    </dependencies>
   36.54 +</project>
   36.55 \ No newline at end of file
    37.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    37.2 +++ b/rt/emul/zip/src/main/java/java/util/zip/Adler32.java	Wed May 07 16:47:24 2014 +0200
    37.3 @@ -0,0 +1,205 @@
    37.4 +/* Adler32.java - Computes Adler32 data checksum of a data stream
    37.5 +   Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc.
    37.6 +
    37.7 +This file is part of GNU Classpath.
    37.8 +
    37.9 +GNU Classpath is free software; you can redistribute it and/or modify
   37.10 +it under the terms of the GNU General Public License as published by
   37.11 +the Free Software Foundation; either version 2, or (at your option)
   37.12 +any later version.
   37.13 +
   37.14 +GNU Classpath is distributed in the hope that it will be useful, but
   37.15 +WITHOUT ANY WARRANTY; without even the implied warranty of
   37.16 +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   37.17 +General Public License for more details.
   37.18 +
   37.19 +You should have received a copy of the GNU General Public License
   37.20 +along with GNU Classpath; see the file COPYING.  If not, write to the
   37.21 +Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
   37.22 +02111-1307 USA.
   37.23 +
   37.24 +Linking this library statically or dynamically with other modules is
   37.25 +making a combined work based on this library.  Thus, the terms and
   37.26 +conditions of the GNU General Public License cover the whole
   37.27 +combination.
   37.28 +
   37.29 +As a special exception, the copyright holders of this library give you
   37.30 +permission to link this library with independent modules to produce an
   37.31 +executable, regardless of the license terms of these independent
   37.32 +modules, and to copy and distribute the resulting executable under
   37.33 +terms of your choice, provided that you also meet, for each linked
   37.34 +independent module, the terms and conditions of the license of that
   37.35 +module.  An independent module is a module which is not derived from
   37.36 +or based on this library.  If you modify this library, you may extend
   37.37 +this exception to your version of the library, but you are not
   37.38 +obligated to do so.  If you do not wish to do so, delete this
   37.39 +exception statement from your version. */
   37.40 +
   37.41 +package java.util.zip;
   37.42 +
   37.43 +/*
   37.44 + * Written using on-line Java Platform 1.2 API Specification, as well
   37.45 + * as "The Java Class Libraries", 2nd edition (Addison-Wesley, 1998).
   37.46 + * The actual Adler32 algorithm is taken from RFC 1950.
   37.47 + * Status:  Believed complete and correct.
   37.48 + */
   37.49 +
   37.50 +/**
   37.51 + * Computes Adler32 checksum for a stream of data. An Adler32 
   37.52 + * checksum is not as reliable as a CRC32 checksum, but a lot faster to 
   37.53 + * compute.
   37.54 + *<p>
   37.55 + * The specification for Adler32 may be found in RFC 1950.
   37.56 + * (ZLIB Compressed Data Format Specification version 3.3)
   37.57 + *<p>
   37.58 + *<p>
   37.59 + * From that document:
   37.60 + *<p>
   37.61 + *      "ADLER32 (Adler-32 checksum)
   37.62 + *       This contains a checksum value of the uncompressed data
   37.63 + *       (excluding any dictionary data) computed according to Adler-32
   37.64 + *       algorithm. This algorithm is a 32-bit extension and improvement
   37.65 + *       of the Fletcher algorithm, used in the ITU-T X.224 / ISO 8073
   37.66 + *       standard. 
   37.67 + *<p>
   37.68 + *       Adler-32 is composed of two sums accumulated per byte: s1 is
   37.69 + *       the sum of all bytes, s2 is the sum of all s1 values. Both sums
   37.70 + *       are done modulo 65521. s1 is initialized to 1, s2 to zero.  The
   37.71 + *       Adler-32 checksum is stored as s2*65536 + s1 in most-
   37.72 + *       significant-byte first (network) order."
   37.73 + *<p>
   37.74 + * "8.2. The Adler-32 algorithm
   37.75 + *<p>
   37.76 + *    The Adler-32 algorithm is much faster than the CRC32 algorithm yet
   37.77 + *    still provides an extremely low probability of undetected errors.
   37.78 + *<p>
   37.79 + *    The modulo on unsigned long accumulators can be delayed for 5552
   37.80 + *    bytes, so the modulo operation time is negligible.  If the bytes
   37.81 + *    are a, b, c, the second sum is 3a + 2b + c + 3, and so is position
   37.82 + *    and order sensitive, unlike the first sum, which is just a
   37.83 + *    checksum.  That 65521 is prime is important to avoid a possible
   37.84 + *    large class of two-byte errors that leave the check unchanged.
   37.85 + *    (The Fletcher checksum uses 255, which is not prime and which also
   37.86 + *    makes the Fletcher check insensitive to single byte changes 0 <->
   37.87 + *    255.)
   37.88 + *<p>
   37.89 + *    The sum s1 is initialized to 1 instead of zero to make the length
   37.90 + *    of the sequence part of s2, so that the length does not have to be
   37.91 + *   checked separately. (Any sequence of zeroes has a Fletcher
   37.92 + *    checksum of zero.)"
   37.93 + *
   37.94 + * @author John Leuner, Per Bothner
   37.95 + * @since JDK 1.1
   37.96 + *
   37.97 + * @see InflaterInputStream
   37.98 + * @see DeflaterOutputStream
   37.99 + */
  37.100 +public class Adler32 implements Checksum
  37.101 +{
  37.102 +
  37.103 +  /** largest prime smaller than 65536 */
  37.104 +  private static final int BASE = 65521;
  37.105 +
  37.106 +  private int checksum; //we do all in int.
  37.107 +
  37.108 +  //Note that java doesn't have unsigned integers,
  37.109 +  //so we have to be careful with what arithmetic 
  37.110 +  //we do. We return the checksum as a long to 
  37.111 +  //avoid sign confusion.
  37.112 +
  37.113 +  /**
  37.114 +   * Creates a new instance of the <code>Adler32</code> class. 
  37.115 +   * The checksum starts off with a value of 1. 
  37.116 +   */
  37.117 +  public Adler32 ()
  37.118 +  {
  37.119 +    reset();
  37.120 +  }
  37.121 +
  37.122 +  /**
  37.123 +   * Resets the Adler32 checksum to the initial value.
  37.124 +   */
  37.125 +  public void reset () 
  37.126 +  {
  37.127 +    checksum = 1; //Initialize to 1    
  37.128 +  }
  37.129 +
  37.130 +  /**
  37.131 +   * Updates the checksum with the byte b. 
  37.132 +   *
  37.133 +   * @param bval the data value to add. The high byte of the int is ignored.
  37.134 +   */
  37.135 +  public void update (int bval)
  37.136 +  {
  37.137 +    //We could make a length 1 byte array and call update again, but I
  37.138 +    //would rather not have that overhead
  37.139 +    int s1 = checksum & 0xffff;
  37.140 +    int s2 = checksum >>> 16;
  37.141 +    
  37.142 +    s1 = (s1 + (bval & 0xFF)) % BASE;
  37.143 +    s2 = (s1 + s2) % BASE;
  37.144 +    
  37.145 +    checksum = (s2 << 16) + s1;
  37.146 +  }
  37.147 +
  37.148 +  /**
  37.149 +   * Updates the checksum with the bytes taken from the array. 
  37.150 +   * 
  37.151 +   * @param buffer an array of bytes
  37.152 +   */
  37.153 +  public void update (byte[] buffer)
  37.154 +  {
  37.155 +    update(buffer, 0, buffer.length);
  37.156 +  }
  37.157 +
  37.158 +  /**
  37.159 +   * Updates the checksum with the bytes taken from the array. 
  37.160 +   * 
  37.161 +   * @param buf an array of bytes
  37.162 +   * @param off the start of the data used for this update
  37.163 +   * @param len the number of bytes to use for this update
  37.164 +   */
  37.165 +  public void update (byte[] buf, int off, int len)
  37.166 +  {
  37.167 +    //(By Per Bothner)
  37.168 +    int s1 = checksum & 0xffff;
  37.169 +    int s2 = checksum >>> 16;
  37.170 +
  37.171 +    while (len > 0)
  37.172 +      {
  37.173 +	// We can defer the modulo operation:
  37.174 +	// s1 maximally grows from 65521 to 65521 + 255 * 3800
  37.175 +	// s2 maximally grows by 3800 * median(s1) = 2090079800 < 2^31
  37.176 +	int n = 3800;
  37.177 +	if (n > len)
  37.178 +	  n = len;
  37.179 +	len -= n;
  37.180 +	while (--n >= 0)
  37.181 +	  {
  37.182 +	    s1 = s1 + (buf[off++] & 0xFF);
  37.183 +	    s2 = s2 + s1;
  37.184 +	  }
  37.185 +	s1 %= BASE;
  37.186 +	s2 %= BASE;
  37.187 +      }
  37.188 +
  37.189 +    /*Old implementation, borrowed from somewhere:
  37.190 +    int n;
  37.191 +    
  37.192 +    while (len-- > 0) {
  37.193 +
  37.194 +      s1 = (s1 + (bs[offset++] & 0xff)) % BASE; 
  37.195 +      s2 = (s2 + s1) % BASE;
  37.196 +    }*/
  37.197 +    
  37.198 +    checksum = (s2 << 16) | s1;
  37.199 +  }
  37.200 +
  37.201 +  /**
  37.202 +   * Returns the Adler32 data checksum computed so far.
  37.203 +   */
  37.204 +  public long getValue()
  37.205 +  {
  37.206 +    return (long) checksum & 0xffffffffL;
  37.207 +  }
  37.208 +}
    38.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    38.2 +++ b/rt/emul/zip/src/main/java/java/util/zip/CRC32.java	Wed May 07 16:47:24 2014 +0200
    38.3 @@ -0,0 +1,132 @@
    38.4 +/* CRC32.java - Computes CRC32 data checksum of a data stream
    38.5 +   Copyright (C) 1999. 2000, 2001 Free Software Foundation, Inc.
    38.6 +
    38.7 +This file is part of GNU Classpath.
    38.8 +
    38.9 +GNU Classpath is free software; you can redistribute it and/or modify
   38.10 +it under the terms of the GNU General Public License as published by
   38.11 +the Free Software Foundation; either version 2, or (at your option)
   38.12 +any later version.
   38.13 +
   38.14 +GNU Classpath is distributed in the hope that it will be useful, but
   38.15 +WITHOUT ANY WARRANTY; without even the implied warranty of
   38.16 +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   38.17 +General Public License for more details.
   38.18 +
   38.19 +You should have received a copy of the GNU General Public License
   38.20 +along with GNU Classpath; see the file COPYING.  If not, write to the
   38.21 +Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
   38.22 +02111-1307 USA.
   38.23 +
   38.24 +Linking this library statically or dynamically with other modules is
   38.25 +making a combined work based on this library.  Thus, the terms and
   38.26 +conditions of the GNU General Public License cover the whole
   38.27 +combination.
   38.28 +
   38.29 +As a special exception, the copyright holders of this library give you
   38.30 +permission to link this library with independent modules to produce an
   38.31 +executable, regardless of the license terms of these independent
   38.32 +modules, and to copy and distribute the resulting executable under
   38.33 +terms of your choice, provided that you also meet, for each linked
   38.34 +independent module, the terms and conditions of the license of that
   38.35 +module.  An independent module is a module which is not derived from
   38.36 +or based on this library.  If you modify this library, you may extend
   38.37 +this exception to your version of the library, but you are not
   38.38 +obligated to do so.  If you do not wish to do so, delete this
   38.39 +exception statement from your version. */
   38.40 +
   38.41 +package java.util.zip;
   38.42 +
   38.43 +/*
   38.44 + * Written using on-line Java Platform 1.2 API Specification, as well
   38.45 + * as "The Java Class Libraries", 2nd edition (Addison-Wesley, 1998).
   38.46 + * The actual CRC32 algorithm is taken from RFC 1952.
   38.47 + * Status:  Believed complete and correct.
   38.48 + */
   38.49 +
   38.50 +/**
   38.51 + * Computes CRC32 data checksum of a data stream.
   38.52 + * The actual CRC32 algorithm is described in RFC 1952
   38.53 + * (GZIP file format specification version 4.3).
   38.54 + * Can be used to get the CRC32 over a stream if used with checked input/output
   38.55 + * streams.
   38.56 + *
   38.57 + * @see InflaterInputStream
   38.58 + * @see DeflaterOutputStream
   38.59 + *
   38.60 + * @author Per Bothner
   38.61 + * @date April 1, 1999.
   38.62 + */
   38.63 +public class CRC32 implements Checksum
   38.64 +{
   38.65 +  /** The crc data checksum so far. */
   38.66 +  private int crc = 0;
   38.67 +
   38.68 +  /** The fast CRC table. Computed once when the CRC32 class is loaded. */
   38.69 +  private static int[] crc_table = make_crc_table();
   38.70 +
   38.71 +  /** Make the table for a fast CRC. */
   38.72 +  private static int[] make_crc_table ()
   38.73 +  {
   38.74 +    int[] crc_table = new int[256];
   38.75 +    for (int n = 0; n < 256; n++)
   38.76 +      {
   38.77 +	int c = n;
   38.78 +	for (int k = 8;  --k >= 0; )
   38.79 +	  {
   38.80 +	    if ((c & 1) != 0)
   38.81 +	      c = 0xedb88320 ^ (c >>> 1);
   38.82 +	    else
   38.83 +	      c = c >>> 1;
   38.84 +	  }
   38.85 +	crc_table[n] = c;
   38.86 +      }
   38.87 +    return crc_table;
   38.88 +  }
   38.89 +
   38.90 +  /**
   38.91 +   * Returns the CRC32 data checksum computed so far.
   38.92 +   */
   38.93 +  public long getValue ()
   38.94 +  {
   38.95 +    return (long) crc & 0xffffffffL;
   38.96 +  }
   38.97 +
   38.98 +  /**
   38.99 +   * Resets the CRC32 data checksum as if no update was ever called.
  38.100 +   */
  38.101 +  public void reset () { crc = 0; }
  38.102 +
  38.103 +  /**
  38.104 +   * Updates the checksum with the int bval. 
  38.105 +   *
  38.106 +   * @param bval (the byte is taken as the lower 8 bits of bval)
  38.107 +   */
  38.108 +
  38.109 +  public void update (int bval)
  38.110 +  {
  38.111 +    int c = ~crc;
  38.112 +    c = crc_table[(c ^ bval) & 0xff] ^ (c >>> 8);
  38.113 +    crc = ~c;
  38.114 +  }
  38.115 +
  38.116 +  /**
  38.117 +   * Adds the byte array to the data checksum.
  38.118 +   *
  38.119 +   * @param buf the buffer which contains the data
  38.120 +   * @param off the offset in the buffer where the data starts
  38.121 +   * @param len the length of the data
  38.122 +   */
  38.123 +  public void update (byte[] buf, int off, int len)
  38.124 +  {
  38.125 +    int c = ~crc;
  38.126 +    while (--len >= 0)
  38.127 +      c = crc_table[(c ^ buf[off++]) & 0xff] ^ (c >>> 8);
  38.128 +    crc = ~c;
  38.129 +  }
  38.130 +
  38.131 +  /**
  38.132 +   * Adds the complete byte array to the data checksum.
  38.133 +   */
  38.134 +  public void update (byte[] buf) { update(buf, 0, buf.length); }
  38.135 +}
    39.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    39.2 +++ b/rt/emul/zip/src/main/java/java/util/zip/Checksum.java	Wed May 07 16:47:24 2014 +0200
    39.3 @@ -0,0 +1,60 @@
    39.4 +/*
    39.5 + * Copyright (c) 1996, 1999, Oracle and/or its affiliates. All rights reserved.
    39.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    39.7 + *
    39.8 + * This code is free software; you can redistribute it and/or modify it
    39.9 + * under the terms of the GNU General Public License version 2 only, as
   39.10 + * published by the Free Software Foundation.  Oracle designates this
   39.11 + * particular file as subject to the "Classpath" exception as provided
   39.12 + * by Oracle in the LICENSE file that accompanied this code.
   39.13 + *
   39.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
   39.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   39.16 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   39.17 + * version 2 for more details (a copy is included in the LICENSE file that
   39.18 + * accompanied this code).
   39.19 + *
   39.20 + * You should have received a copy of the GNU General Public License version
   39.21 + * 2 along with this work; if not, write to the Free Software Foundation,
   39.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   39.23 + *
   39.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   39.25 + * or visit www.oracle.com if you need additional information or have any
   39.26 + * questions.
   39.27 + */
   39.28 +
   39.29 +package java.util.zip;
   39.30 +
   39.31 +/**
   39.32 + * An interface representing a data checksum.
   39.33 + *
   39.34 + * @author      David Connelly
   39.35 + */
   39.36 +public
   39.37 +interface Checksum {
   39.38 +    /**
   39.39 +     * Updates the current checksum with the specified byte.
   39.40 +     *
   39.41 +     * @param b the byte to update the checksum with
   39.42 +     */
   39.43 +    public void update(int b);
   39.44 +
   39.45 +    /**
   39.46 +     * Updates the current checksum with the specified array of bytes.
   39.47 +     * @param b the byte array to update the checksum with
   39.48 +     * @param off the start offset of the data
   39.49 +     * @param len the number of bytes to use for the update
   39.50 +     */
   39.51 +    public void update(byte[] b, int off, int len);
   39.52 +
   39.53 +    /**
   39.54 +     * Returns the current checksum value.
   39.55 +     * @return the current checksum value
   39.56 +     */
   39.57 +    public long getValue();
   39.58 +
   39.59 +    /**
   39.60 +     * Resets the checksum to its initial value.
   39.61 +     */
   39.62 +    public void reset();
   39.63 +}
    40.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    40.2 +++ b/rt/emul/zip/src/main/java/java/util/zip/DataFormatException.java	Wed May 07 16:47:24 2014 +0200
    40.3 @@ -0,0 +1,52 @@
    40.4 +/*
    40.5 + * Copyright (c) 1996, 2008, Oracle and/or its affiliates. All rights reserved.
    40.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    40.7 + *
    40.8 + * This code is free software; you can redistribute it and/or modify it
    40.9 + * under the terms of the GNU General Public License version 2 only, as
   40.10 + * published by the Free Software Foundation.  Oracle designates this
   40.11 + * particular file as subject to the "Classpath" exception as provided
   40.12 + * by Oracle in the LICENSE file that accompanied this code.
   40.13 + *
   40.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
   40.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   40.16 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   40.17 + * version 2 for more details (a copy is included in the LICENSE file that
   40.18 + * accompanied this code).
   40.19 + *
   40.20 + * You should have received a copy of the GNU General Public License version
   40.21 + * 2 along with this work; if not, write to the Free Software Foundation,
   40.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   40.23 + *
   40.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   40.25 + * or visit www.oracle.com if you need additional information or have any
   40.26 + * questions.
   40.27 + */
   40.28 +
   40.29 +package java.util.zip;
   40.30 +
   40.31 +/**
   40.32 + * Signals that a data format error has occurred.
   40.33 + *
   40.34 + * @author      David Connelly
   40.35 + */
   40.36 +public
   40.37 +class DataFormatException extends Exception {
   40.38 +    private static final long serialVersionUID = 2219632870893641452L;
   40.39 +
   40.40 +    /**
   40.41 +     * Constructs a DataFormatException with no detail message.
   40.42 +     */
   40.43 +    public DataFormatException() {
   40.44 +        super();
   40.45 +    }
   40.46 +
   40.47 +    /**
   40.48 +     * Constructs a DataFormatException with the specified detail message.
   40.49 +     * A detail message is a String that describes this particular exception.
   40.50 +     * @param s the String containing a detail message
   40.51 +     */
   40.52 +    public DataFormatException(String s) {
   40.53 +        super(s);
   40.54 +    }
   40.55 +}
    41.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    41.2 +++ b/rt/emul/zip/src/main/java/java/util/zip/Inflater.java	Wed May 07 16:47:24 2014 +0200
    41.3 @@ -0,0 +1,310 @@
    41.4 +/*
    41.5 + * Copyright (c) 1996, 2011, Oracle and/or its affiliates. All rights reserved.
    41.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    41.7 + *
    41.8 + * This code is free software; you can redistribute it and/or modify it
    41.9 + * under the terms of the GNU General Public License version 2 only, as
   41.10 + * published by the Free Software Foundation.  Oracle designates this
   41.11 + * particular file as subject to the "Classpath" exception as provided
   41.12 + * by Oracle in the LICENSE file that accompanied this code.
   41.13 + *
   41.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
   41.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   41.16 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   41.17 + * version 2 for more details (a copy is included in the LICENSE file that
   41.18 + * accompanied this code).
   41.19 + *
   41.20 + * You should have received a copy of the GNU General Public License version
   41.21 + * 2 along with this work; if not, write to the Free Software Foundation,
   41.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   41.23 + *
   41.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   41.25 + * or visit www.oracle.com if you need additional information or have any
   41.26 + * questions.
   41.27 + */
   41.28 +
   41.29 +package java.util.zip;
   41.30 +
   41.31 +/**
   41.32 + * This class provides support for general purpose decompression using the
   41.33 + * popular ZLIB compression library. The ZLIB compression library was
   41.34 + * initially developed as part of the PNG graphics standard and is not
   41.35 + * protected by patents. It is fully described in the specifications at
   41.36 + * the <a href="package-summary.html#package_description">java.util.zip
   41.37 + * package description</a>.
   41.38 + *
   41.39 + * <p>The following code fragment demonstrates a trivial compression
   41.40 + * and decompression of a string using <tt>Deflater</tt> and
   41.41 + * <tt>Inflater</tt>.
   41.42 + *
   41.43 + * <blockquote><pre>
   41.44 + * try {
   41.45 + *     // Encode a String into bytes
   41.46 + *     String inputString = "blahblahblah\u20AC\u20AC";
   41.47 + *     byte[] input = inputString.getBytes("UTF-8");
   41.48 + *
   41.49 + *     // Compress the bytes
   41.50 + *     byte[] output = new byte[100];
   41.51 + *     Deflater compresser = new Deflater();
   41.52 + *     compresser.setInput(input);
   41.53 + *     compresser.finish();
   41.54 + *     int compressedDataLength = compresser.deflate(output);
   41.55 + *
   41.56 + *     // Decompress the bytes
   41.57 + *     Inflater decompresser = new Inflater();
   41.58 + *     decompresser.setInput(output, 0, compressedDataLength);
   41.59 + *     byte[] result = new byte[100];
   41.60 + *     int resultLength = decompresser.inflate(result);
   41.61 + *     decompresser.end();
   41.62 + *
   41.63 + *     // Decode the bytes into a String
   41.64 + *     String outputString = new String(result, 0, resultLength, "UTF-8");
   41.65 + * } catch(java.io.UnsupportedEncodingException ex) {
   41.66 + *     // handle
   41.67 + * } catch (java.util.zip.DataFormatException ex) {
   41.68 + *     // handle
   41.69 + * }
   41.70 + * </pre></blockquote>
   41.71 + *
   41.72 + * @see         Deflater
   41.73 + * @author      David Connelly
   41.74 + *
   41.75 + */
   41.76 +public
   41.77 +class Inflater {
   41.78 +    private final org.apidesign.bck2brwsr.emul.zip.Inflater impl;
   41.79 +    
   41.80 +    /**
   41.81 +     * Creates a new decompressor. If the parameter 'nowrap' is true then
   41.82 +     * the ZLIB header and checksum fields will not be used. This provides
   41.83 +     * compatibility with the compression format used by both GZIP and PKZIP.
   41.84 +     * <p>
   41.85 +     * Note: When using the 'nowrap' option it is also necessary to provide
   41.86 +     * an extra "dummy" byte as input. This is required by the ZLIB native
   41.87 +     * library in order to support certain optimizations.
   41.88 +     *
   41.89 +     * @param nowrap if true then support GZIP compatible compression
   41.90 +     */
   41.91 +    public Inflater(boolean nowrap) {
   41.92 +        if (getClass() == org.apidesign.bck2brwsr.emul.zip.Inflater.class) {
   41.93 +            impl = null;
   41.94 +        } else {
   41.95 +            impl = new org.apidesign.bck2brwsr.emul.zip.Inflater(nowrap);
   41.96 +        }
   41.97 +    }
   41.98 +
   41.99 +    /**
  41.100 +     * Creates a new decompressor.
  41.101 +     */
  41.102 +    public Inflater() {
  41.103 +        this(false);
  41.104 +    }
  41.105 +
  41.106 +    /**
  41.107 +     * Sets input data for decompression. Should be called whenever
  41.108 +     * needsInput() returns true indicating that more input data is
  41.109 +     * required.
  41.110 +     * @param b the input data bytes
  41.111 +     * @param off the start offset of the input data
  41.112 +     * @param len the length of the input data
  41.113 +     * @see Inflater#needsInput
  41.114 +     */
  41.115 +    public void setInput(byte[] b, int off, int len) {
  41.116 +        impl.setInput(b, off, len);
  41.117 +    }
  41.118 +
  41.119 +    /**
  41.120 +     * Sets input data for decompression. Should be called whenever
  41.121 +     * needsInput() returns true indicating that more input data is
  41.122 +     * required.
  41.123 +     * @param b the input data bytes
  41.124 +     * @see Inflater#needsInput
  41.125 +     */
  41.126 +    public void setInput(byte[] b) {
  41.127 +        impl.setInput(b);
  41.128 +    }
  41.129 +
  41.130 +    /**
  41.131 +     * Sets the preset dictionary to the given array of bytes. Should be
  41.132 +     * called when inflate() returns 0 and needsDictionary() returns true
  41.133 +     * indicating that a preset dictionary is required. The method getAdler()
  41.134 +     * can be used to get the Adler-32 value of the dictionary needed.
  41.135 +     * @param b the dictionary data bytes
  41.136 +     * @param off the start offset of the data
  41.137 +     * @param len the length of the data
  41.138 +     * @see Inflater#needsDictionary
  41.139 +     * @see Inflater#getAdler
  41.140 +     */
  41.141 +    public void setDictionary(byte[] b, int off, int len) {
  41.142 +        impl.setDictionary(b, off, len);
  41.143 +    }
  41.144 +
  41.145 +    /**
  41.146 +     * Sets the preset dictionary to the given array of bytes. Should be
  41.147 +     * called when inflate() returns 0 and needsDictionary() returns true
  41.148 +     * indicating that a preset dictionary is required. The method getAdler()
  41.149 +     * can be used to get the Adler-32 value of the dictionary needed.
  41.150 +     * @param b the dictionary data bytes
  41.151 +     * @see Inflater#needsDictionary
  41.152 +     * @see Inflater#getAdler
  41.153 +     */
  41.154 +    public void setDictionary(byte[] b) {
  41.155 +        impl.setDictionary(b);
  41.156 +    }
  41.157 +
  41.158 +    /**
  41.159 +     * Returns the total number of bytes remaining in the input buffer.
  41.160 +     * This can be used to find out what bytes still remain in the input
  41.161 +     * buffer after decompression has finished.
  41.162 +     * @return the total number of bytes remaining in the input buffer
  41.163 +     */
  41.164 +    public int getRemaining() {
  41.165 +        return impl.getRemaining();
  41.166 +    }
  41.167 +
  41.168 +    /**
  41.169 +     * Returns true if no data remains in the input buffer. This can
  41.170 +     * be used to determine if #setInput should be called in order
  41.171 +     * to provide more input.
  41.172 +     * @return true if no data remains in the input buffer
  41.173 +     */
  41.174 +    public boolean needsInput() {
  41.175 +        return impl.needsInput();
  41.176 +    }
  41.177 +
  41.178 +    /**
  41.179 +     * Returns true if a preset dictionary is needed for decompression.
  41.180 +     * @return true if a preset dictionary is needed for decompression
  41.181 +     * @see Inflater#setDictionary
  41.182 +     */
  41.183 +    public boolean needsDictionary() {
  41.184 +        return impl.needsDictionary();
  41.185 +    }
  41.186 +
  41.187 +    /**
  41.188 +     * Returns true if the end of the compressed data stream has been
  41.189 +     * reached.
  41.190 +     * @return true if the end of the compressed data stream has been
  41.191 +     * reached
  41.192 +     */
  41.193 +    public boolean finished() {
  41.194 +        return impl.finished();
  41.195 +    }
  41.196 +
  41.197 +    /**
  41.198 +     * Uncompresses bytes into specified buffer. Returns actual number
  41.199 +     * of bytes uncompressed. A return value of 0 indicates that
  41.200 +     * needsInput() or needsDictionary() should be called in order to
  41.201 +     * determine if more input data or a preset dictionary is required.
  41.202 +     * In the latter case, getAdler() can be used to get the Adler-32
  41.203 +     * value of the dictionary required.
  41.204 +     * @param b the buffer for the uncompressed data
  41.205 +     * @param off the start offset of the data
  41.206 +     * @param len the maximum number of uncompressed bytes
  41.207 +     * @return the actual number of uncompressed bytes
  41.208 +     * @exception DataFormatException if the compressed data format is invalid
  41.209 +     * @see Inflater#needsInput
  41.210 +     * @see Inflater#needsDictionary
  41.211 +     */
  41.212 +    public int inflate(byte[] b, int off, int len)
  41.213 +        throws DataFormatException
  41.214 +    {
  41.215 +        return impl.inflate(b, off, len);
  41.216 +    }
  41.217 +
  41.218 +    /**
  41.219 +     * Uncompresses bytes into specified buffer. Returns actual number
  41.220 +     * of bytes uncompressed. A return value of 0 indicates that
  41.221 +     * needsInput() or needsDictionary() should be called in order to
  41.222 +     * determine if more input data or a preset dictionary is required.
  41.223 +     * In the latter case, getAdler() can be used to get the Adler-32
  41.224 +     * value of the dictionary required.
  41.225 +     * @param b the buffer for the uncompressed data
  41.226 +     * @return the actual number of uncompressed bytes
  41.227 +     * @exception DataFormatException if the compressed data format is invalid
  41.228 +     * @see Inflater#needsInput
  41.229 +     * @see Inflater#needsDictionary
  41.230 +     */
  41.231 +    public int inflate(byte[] b) throws DataFormatException {
  41.232 +        return impl.inflate(b);
  41.233 +    }
  41.234 +
  41.235 +    /**
  41.236 +     * Returns the ADLER-32 value of the uncompressed data.
  41.237 +     * @return the ADLER-32 value of the uncompressed data
  41.238 +     */
  41.239 +    public int getAdler() {
  41.240 +        return impl.getAdler();
  41.241 +    }
  41.242 +
  41.243 +    /**
  41.244 +     * Returns the total number of compressed bytes input so far.
  41.245 +     *
  41.246 +     * <p>Since the number of bytes may be greater than
  41.247 +     * Integer.MAX_VALUE, the {@link #getBytesRead()} method is now
  41.248 +     * the preferred means of obtaining this information.</p>
  41.249 +     *
  41.250 +     * @return the total number of compressed bytes input so far
  41.251 +     */
  41.252 +    public int getTotalIn() {
  41.253 +        return impl.getTotalIn();
  41.254 +    }
  41.255 +
  41.256 +    /**
  41.257 +     * Returns the total number of compressed bytes input so far.</p>
  41.258 +     *
  41.259 +     * @return the total (non-negative) number of compressed bytes input so far
  41.260 +     * @since 1.5
  41.261 +     */
  41.262 +    public long getBytesRead() {
  41.263 +        return impl.getBytesRead();
  41.264 +    }
  41.265 +
  41.266 +    /**
  41.267 +     * Returns the total number of uncompressed bytes output so far.
  41.268 +     *
  41.269 +     * <p>Since the number of bytes may be greater than
  41.270 +     * Integer.MAX_VALUE, the {@link #getBytesWritten()} method is now
  41.271 +     * the preferred means of obtaining this information.</p>
  41.272 +     *
  41.273 +     * @return the total number of uncompressed bytes output so far
  41.274 +     */
  41.275 +    public int getTotalOut()