Share via


Pack200.IPacker Interface

Definition

The packer engine applies various transformations to the input JAR file, making the pack stream highly compressible by a compressor such as gzip or zip.

[Android.Runtime.Register("java/util/jar/Pack200$Packer", "", "Java.Util.Jar.Pack200/IPackerInvoker")]
public interface Pack200.IPacker : Android.Runtime.IJavaObject, IDisposable, Java.Interop.IJavaPeerable
[<Android.Runtime.Register("java/util/jar/Pack200$Packer", "", "Java.Util.Jar.Pack200/IPackerInvoker")>]
type Pack200.IPacker = interface
    interface IJavaObject
    interface IDisposable
    interface IJavaPeerable
Attributes
Implements

Remarks

The packer engine applies various transformations to the input JAR file, making the pack stream highly compressible by a compressor such as gzip or zip. An instance of the engine can be obtained using #newPacker.

The high degree of compression is achieved by using a number of techniques described in the JSR 200 specification. Some of the techniques are sorting, re-ordering and co-location of the constant pool.

The pack engine is initialized to an initial state as described by their properties below. The initial state can be manipulated by getting the engine properties (using #properties) and storing the modified properties on the map. The resource files will be passed through with no changes at all. The class files will not contain identical bytes, since the unpacker is free to change minor class file features such as constant pool order. However, the class files will be semantically identical, as specified in <cite>The Java&trade; Virtual Machine Specification</cite>.

By default, the packer does not change the order of JAR elements. Also, the modification time and deflation hint of each JAR element is passed unchanged. (Any other ZIP-archive information, such as extra attributes giving Unix file permissions, are lost.)

Note that packing and unpacking a JAR will in general alter the bytewise contents of classfiles in the JAR. This means that packing and unpacking will in general invalidate any digital signatures which rely on bytewise images of JAR elements. In order both to sign and to pack a JAR, you must first pack and unpack the JAR to "normalize" it, then compute signatures on the unpacked JAR elements, and finally repack the signed JAR. Both packing steps should use precisely the same options, and the segment limit may also need to be set to "-1", to prevent accidental variation of segment boundaries as class file sizes change slightly.

(Here's why this works: Any reordering the packer does of any classfile structures is idempotent, so the second packing does not change the orderings produced by the first packing. Also, the unpacker is guaranteed by the JSR 200 specification to produce a specific bytewise image for any given transmission ordering of archive elements.)

In order to maintain backward compatibility, the pack file's version is set to accommodate the class files present in the input JAR file. In other words, the pack file version will be the latest, if the class files are the latest and conversely the pack file version will be the oldest if the class file versions are also the oldest. For intermediate class file versions the corresponding pack file version will be used. For example: If the input JAR-files are solely comprised of 1.5 (or lesser) class files, a 1.5 compatible pack file is produced. This will also be the case for archives that have no class files. If the input JAR-files contains a 1.6 class file, then the pack file version will be set to 1.6.

Note: Unless otherwise noted, passing a null argument to a constructor or method in this class will cause a NullPointerException to be thrown.

Added in 1.5.

Java documentation for java.util.jar.Pack200.Packer.

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Fields

ClassAttributePfx

When concatenated with a class attribute name, indicates the format of that attribute, using the layout language specified in the JSR 200 specification.

CodeAttributePfx

When concatenated with a code attribute name, indicates the format of that attribute.

DeflateHint

If this property is set to #TRUE or #FALSE, the packer will set the deflation hint accordingly in the output archive, and will not transmit the individual deflation hints of archive elements.

Effort

If this property is set to a single decimal digit, the packer will use the indicated amount of effort in compressing the archive.

Error

The string "error", a possible value for certain properties.

False

The string "false", a possible value for certain properties.

FieldAttributePfx

When concatenated with a field attribute name, indicates the format of that attribute.

Keep

The string "keep", a possible value for certain properties.

KeepFileOrder

If this property is set to #TRUE, the packer will transmit all elements in their original order within the source archive.

Latest

The string "latest", a possible value for certain properties.

MethodAttributePfx

When concatenated with a method attribute name, indicates the format of that attribute.

ModificationTime

If this property is set to the special string #LATEST, the packer will attempt to determine the latest modification time, among all the available entries in the original archive or the latest modification time of all the available entries in each segment.

Pass

The string "pass", a possible value for certain properties.

PassFilePfx

Indicates that a file should be passed through bytewise, with no compression.

Progress

The unpacker's progress as a percentage, as periodically updated by the unpacker.

SegmentLimit

This property is a numeral giving the estimated target size N (in bytes) of each archive segment.

Strip

The string "strip", a possible value for certain properties.

True

The string "true", a possible value for certain properties.

UnknownAttribute

Indicates the action to take when a class-file containing an unknown attribute is encountered.

Properties

Handle

Gets the JNI value of the underlying Android object.

(Inherited from IJavaObject)
JniIdentityHashCode

Returns the value of java.lang.System.identityHashCode() for the wrapped instance.

(Inherited from IJavaPeerable)
JniManagedPeerState

State of the managed peer.

(Inherited from IJavaPeerable)
JniPeerMembers

Member access and invocation support.

(Inherited from IJavaPeerable)
PeerReference

Returns a JniObjectReference of the wrapped Java object instance.

(Inherited from IJavaPeerable)

Methods

AddPropertyChangeListener(IPropertyChangeListener)

Registers a listener for PropertyChange events on the properties map.

Disposed()

Called when the instance has been disposed.

(Inherited from IJavaPeerable)
DisposeUnlessReferenced()

If there are no outstanding references to this instance, then calls Dispose(); otherwise, does nothing.

(Inherited from IJavaPeerable)
Finalized()

Called when the instance has been finalized.

(Inherited from IJavaPeerable)
Pack(JarFile, Stream)

Takes a JarFile and converts it into a Pack200 archive.

Pack(JarInputStream, Stream)

Takes a JarInputStream and converts it into a Pack200 archive.

Properties()

Get the set of this engine's properties.

RemovePropertyChangeListener(IPropertyChangeListener)

Remove a listener for PropertyChange events, added by the #addPropertyChangeListener.

SetJniIdentityHashCode(Int32)

Set the value returned by JniIdentityHashCode.

(Inherited from IJavaPeerable)
SetJniManagedPeerState(JniManagedPeerStates) (Inherited from IJavaPeerable)
SetPeerReference(JniObjectReference)

Set the value returned by PeerReference.

(Inherited from IJavaPeerable)
UnregisterFromRuntime()

Unregister this instance so that the runtime will not return it from future Java.Interop.JniRuntime+JniValueManager.PeekValue invocations.

(Inherited from IJavaPeerable)

Extension Methods

JavaCast<TResult>(IJavaObject)

Performs an Android runtime-checked type conversion.

JavaCast<TResult>(IJavaObject)
GetJniTypeName(IJavaPeerable)
PackAsync(Pack200+IPacker, JarFile, Stream)
PackAsync(Pack200+IPacker, JarInputStream, Stream)

Applies to