xref: /aosp_15_r20/external/apache-commons-compress/src/site/xdoc/pack200.xml (revision ba8755cb0ae00084b4d58129cd522613d3299f27)
1*ba8755cbSAndroid Build Coastguard Worker<?xml version="1.0"?>
2*ba8755cbSAndroid Build Coastguard Worker<!--
3*ba8755cbSAndroid Build Coastguard Worker
4*ba8755cbSAndroid Build Coastguard Worker   Licensed to the Apache Software Foundation (ASF) under one or more
5*ba8755cbSAndroid Build Coastguard Worker   contributor license agreements.  See the NOTICE file distributed with
6*ba8755cbSAndroid Build Coastguard Worker   this work for additional information regarding copyright ownership.
7*ba8755cbSAndroid Build Coastguard Worker   The ASF licenses this file to You under the Apache License, Version 2.0
8*ba8755cbSAndroid Build Coastguard Worker   (the "License"); you may not use this file except in compliance with
9*ba8755cbSAndroid Build Coastguard Worker   the License.  You may obtain a copy of the License at
10*ba8755cbSAndroid Build Coastguard Worker
11*ba8755cbSAndroid Build Coastguard Worker       http://www.apache.org/licenses/LICENSE-2.0
12*ba8755cbSAndroid Build Coastguard Worker
13*ba8755cbSAndroid Build Coastguard Worker   Unless required by applicable law or agreed to in writing, software
14*ba8755cbSAndroid Build Coastguard Worker   distributed under the License is distributed on an "AS IS" BASIS,
15*ba8755cbSAndroid Build Coastguard Worker   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16*ba8755cbSAndroid Build Coastguard Worker   See the License for the specific language governing permissions and
17*ba8755cbSAndroid Build Coastguard Worker   limitations under the License.
18*ba8755cbSAndroid Build Coastguard Worker
19*ba8755cbSAndroid Build Coastguard Worker-->
20*ba8755cbSAndroid Build Coastguard Worker<document>
21*ba8755cbSAndroid Build Coastguard Worker  <properties>
22*ba8755cbSAndroid Build Coastguard Worker    <title>Commons Compress Pack200 Package</title>
23*ba8755cbSAndroid Build Coastguard Worker    <author email="[email protected]">Commons Documentation Team</author>
24*ba8755cbSAndroid Build Coastguard Worker  </properties>
25*ba8755cbSAndroid Build Coastguard Worker  <body>
26*ba8755cbSAndroid Build Coastguard Worker    <section name="The Pack200 package">
27*ba8755cbSAndroid Build Coastguard Worker
28*ba8755cbSAndroid Build Coastguard Worker      <p>The Pack200 algorithm is not a general purpose compression
29*ba8755cbSAndroid Build Coastguard Worker      algorithm but one specialized for compressing JAR archives.  JAR
30*ba8755cbSAndroid Build Coastguard Worker      archives compressed with Pack200 will in general be different
31*ba8755cbSAndroid Build Coastguard Worker      from the original archive when decompressed again.  More
32*ba8755cbSAndroid Build Coastguard Worker      information can be found in the Javadocs of the <a
33*ba8755cbSAndroid Build Coastguard Worker      href="https://docs.oracle.com/javase/7/docs/api/java/util/jar/Pack200.Packer.html">Pack200.Packer
34*ba8755cbSAndroid Build Coastguard Worker      class</a>.</p>
35*ba8755cbSAndroid Build Coastguard Worker
36*ba8755cbSAndroid Build Coastguard Worker      <p>While the <code>pack200</code> command line utility of the
37*ba8755cbSAndroid Build Coastguard Worker      JDK creates GZip compressed archives (<code>.pack.gz</code>) by
38*ba8755cbSAndroid Build Coastguard Worker      default, the streams provided by the Pack200 package only
39*ba8755cbSAndroid Build Coastguard Worker      perform the actual Pack200 operation.  Wrap them in an
40*ba8755cbSAndroid Build Coastguard Worker      additional <code>GzipCompressor(In|Out)putStream</code> in order to deal
41*ba8755cbSAndroid Build Coastguard Worker      with deflated streams.</p>
42*ba8755cbSAndroid Build Coastguard Worker
43*ba8755cbSAndroid Build Coastguard Worker      <subsection name="Pack200Strategy">
44*ba8755cbSAndroid Build Coastguard Worker
45*ba8755cbSAndroid Build Coastguard Worker        <p>The Pack200-API provided by the java class library is not
46*ba8755cbSAndroid Build Coastguard Worker        streaming friendly as it wants to consume its input completely
47*ba8755cbSAndroid Build Coastguard Worker        in a single operation.  Because of this
48*ba8755cbSAndroid Build Coastguard Worker        <code>Pack200CompressorInputStream</code>'s constructor will immediately
49*ba8755cbSAndroid Build Coastguard Worker        unpack the stream, cache the results and provide an input
50*ba8755cbSAndroid Build Coastguard Worker        stream to the cache.</p>
51*ba8755cbSAndroid Build Coastguard Worker
52*ba8755cbSAndroid Build Coastguard Worker        <p><code>Pack200CompressorOutputStream</code> will cache all data that
53*ba8755cbSAndroid Build Coastguard Worker        is written to it and then pack it once the <code>finish</code>
54*ba8755cbSAndroid Build Coastguard Worker        or <code>close</code> method is called.</p>
55*ba8755cbSAndroid Build Coastguard Worker
56*ba8755cbSAndroid Build Coastguard Worker        <p>Two different caching modes are available - "in memory",
57*ba8755cbSAndroid Build Coastguard Worker        which is the default, and "temporary file".  By default data
58*ba8755cbSAndroid Build Coastguard Worker        is cached in memory but you should switch to the temporary
59*ba8755cbSAndroid Build Coastguard Worker        file option if your archives are really big.</p>
60*ba8755cbSAndroid Build Coastguard Worker
61*ba8755cbSAndroid Build Coastguard Worker        <p>Given there always is an intermediate result
62*ba8755cbSAndroid Build Coastguard Worker        the <code>getBytesRead</code> and <code>getCount</code>
63*ba8755cbSAndroid Build Coastguard Worker        methods of <code>Pack200CompressorInputStream</code> are
64*ba8755cbSAndroid Build Coastguard Worker        meaningless (read from the real stream or from the
65*ba8755cbSAndroid Build Coastguard Worker        intermediate result?)  and always return 0.</p>
66*ba8755cbSAndroid Build Coastguard Worker
67*ba8755cbSAndroid Build Coastguard Worker      </subsection>
68*ba8755cbSAndroid Build Coastguard Worker
69*ba8755cbSAndroid Build Coastguard Worker      <subsection name="Normalization">
70*ba8755cbSAndroid Build Coastguard Worker
71*ba8755cbSAndroid Build Coastguard Worker        <p>As a pack/unpack cycle may create a JAR archive that is
72*ba8755cbSAndroid Build Coastguard Worker        different from the original, digital signatures created for
73*ba8755cbSAndroid Build Coastguard Worker        the initial JAR will be broken by the process.  There is a way
74*ba8755cbSAndroid Build Coastguard Worker        to "normalize" JAR archives prior to packing them that ensures
75*ba8755cbSAndroid Build Coastguard Worker        signatures applied to the "normalized" JAR will still be valid
76*ba8755cbSAndroid Build Coastguard Worker        aftre a pack/unpack cycle - see <a
77*ba8755cbSAndroid Build Coastguard Worker        href="https://download.oracle.com/javase/7/docs/api/java/util/jar/Pack200.Packer.html">Pack200.Packer</a>'s
78*ba8755cbSAndroid Build Coastguard Worker        javadocs.</p>
79*ba8755cbSAndroid Build Coastguard Worker
80*ba8755cbSAndroid Build Coastguard Worker        <p>The <code>Pack200Utils</code> class in the
81*ba8755cbSAndroid Build Coastguard Worker        <code>pack200</code> package provides several overloads of a
82*ba8755cbSAndroid Build Coastguard Worker        <code>normalize</code> method that can be used to prepare a
83*ba8755cbSAndroid Build Coastguard Worker        JAR archive in place or to a separate file.</p>
84*ba8755cbSAndroid Build Coastguard Worker
85*ba8755cbSAndroid Build Coastguard Worker      </subsection>
86*ba8755cbSAndroid Build Coastguard Worker
87*ba8755cbSAndroid Build Coastguard Worker    </section>
88*ba8755cbSAndroid Build Coastguard Worker</body>
89*ba8755cbSAndroid Build Coastguard Worker</document>
90