Merge
This commit is contained in:
commit
44196168b9
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 1996-2006 Sun Microsystems, Inc. All Rights Reserved.
|
* Copyright 1996-2009 Sun Microsystems, Inc. All Rights Reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -72,7 +72,8 @@ package java.util.zip;
|
|||||||
*/
|
*/
|
||||||
public
|
public
|
||||||
class Deflater {
|
class Deflater {
|
||||||
private long strm;
|
|
||||||
|
private final ZStreamRef zsRef;
|
||||||
private byte[] buf = new byte[0];
|
private byte[] buf = new byte[0];
|
||||||
private int off, len;
|
private int off, len;
|
||||||
private int level, strategy;
|
private int level, strategy;
|
||||||
@ -165,7 +166,7 @@ class Deflater {
|
|||||||
public Deflater(int level, boolean nowrap) {
|
public Deflater(int level, boolean nowrap) {
|
||||||
this.level = level;
|
this.level = level;
|
||||||
this.strategy = DEFAULT_STRATEGY;
|
this.strategy = DEFAULT_STRATEGY;
|
||||||
strm = init(level, DEFAULT_STRATEGY, nowrap);
|
this.zsRef = new ZStreamRef(init(level, DEFAULT_STRATEGY, nowrap));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -193,17 +194,19 @@ class Deflater {
|
|||||||
* @param len the length of the data
|
* @param len the length of the data
|
||||||
* @see Deflater#needsInput
|
* @see Deflater#needsInput
|
||||||
*/
|
*/
|
||||||
public synchronized void setInput(byte[] b, int off, int len) {
|
public void setInput(byte[] b, int off, int len) {
|
||||||
if (b== null) {
|
if (b== null) {
|
||||||
throw new NullPointerException();
|
throw new NullPointerException();
|
||||||
}
|
}
|
||||||
if (off < 0 || len < 0 || off > b.length - len) {
|
if (off < 0 || len < 0 || off > b.length - len) {
|
||||||
throw new ArrayIndexOutOfBoundsException();
|
throw new ArrayIndexOutOfBoundsException();
|
||||||
}
|
}
|
||||||
|
synchronized (zsRef) {
|
||||||
this.buf = b;
|
this.buf = b;
|
||||||
this.off = off;
|
this.off = off;
|
||||||
this.len = len;
|
this.len = len;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets input data for compression. This should be called whenever
|
* Sets input data for compression. This should be called whenever
|
||||||
@ -227,14 +230,17 @@ class Deflater {
|
|||||||
* @see Inflater#inflate
|
* @see Inflater#inflate
|
||||||
* @see Inflater#getAdler
|
* @see Inflater#getAdler
|
||||||
*/
|
*/
|
||||||
public synchronized void setDictionary(byte[] b, int off, int len) {
|
public void setDictionary(byte[] b, int off, int len) {
|
||||||
if (strm == 0 || b == null) {
|
if (b == null) {
|
||||||
throw new NullPointerException();
|
throw new NullPointerException();
|
||||||
}
|
}
|
||||||
if (off < 0 || len < 0 || off > b.length - len) {
|
if (off < 0 || len < 0 || off > b.length - len) {
|
||||||
throw new ArrayIndexOutOfBoundsException();
|
throw new ArrayIndexOutOfBoundsException();
|
||||||
}
|
}
|
||||||
setDictionary(strm, b, off, len);
|
synchronized (zsRef) {
|
||||||
|
ensureOpen();
|
||||||
|
setDictionary(zsRef.address(), b, off, len);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -257,7 +263,7 @@ class Deflater {
|
|||||||
* @exception IllegalArgumentException if the compression strategy is
|
* @exception IllegalArgumentException if the compression strategy is
|
||||||
* invalid
|
* invalid
|
||||||
*/
|
*/
|
||||||
public synchronized void setStrategy(int strategy) {
|
public void setStrategy(int strategy) {
|
||||||
switch (strategy) {
|
switch (strategy) {
|
||||||
case DEFAULT_STRATEGY:
|
case DEFAULT_STRATEGY:
|
||||||
case FILTERED:
|
case FILTERED:
|
||||||
@ -266,26 +272,30 @@ class Deflater {
|
|||||||
default:
|
default:
|
||||||
throw new IllegalArgumentException();
|
throw new IllegalArgumentException();
|
||||||
}
|
}
|
||||||
|
synchronized (zsRef) {
|
||||||
if (this.strategy != strategy) {
|
if (this.strategy != strategy) {
|
||||||
this.strategy = strategy;
|
this.strategy = strategy;
|
||||||
setParams = true;
|
setParams = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the current compression level to the specified value.
|
* Sets the current compression level to the specified value.
|
||||||
* @param level the new compression level (0-9)
|
* @param level the new compression level (0-9)
|
||||||
* @exception IllegalArgumentException if the compression level is invalid
|
* @exception IllegalArgumentException if the compression level is invalid
|
||||||
*/
|
*/
|
||||||
public synchronized void setLevel(int level) {
|
public void setLevel(int level) {
|
||||||
if ((level < 0 || level > 9) && level != DEFAULT_COMPRESSION) {
|
if ((level < 0 || level > 9) && level != DEFAULT_COMPRESSION) {
|
||||||
throw new IllegalArgumentException("invalid compression level");
|
throw new IllegalArgumentException("invalid compression level");
|
||||||
}
|
}
|
||||||
|
synchronized (zsRef) {
|
||||||
if (this.level != level) {
|
if (this.level != level) {
|
||||||
this.level = level;
|
this.level = level;
|
||||||
setParams = true;
|
setParams = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns true if the input data buffer is empty and setInput()
|
* Returns true if the input data buffer is empty and setInput()
|
||||||
@ -301,9 +311,11 @@ class Deflater {
|
|||||||
* When called, indicates that compression should end with the current
|
* When called, indicates that compression should end with the current
|
||||||
* contents of the input buffer.
|
* contents of the input buffer.
|
||||||
*/
|
*/
|
||||||
public synchronized void finish() {
|
public void finish() {
|
||||||
|
synchronized (zsRef) {
|
||||||
finish = true;
|
finish = true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns true if the end of the compressed data output stream has
|
* Returns true if the end of the compressed data output stream has
|
||||||
@ -311,9 +323,11 @@ class Deflater {
|
|||||||
* @return true if the end of the compressed data output stream has
|
* @return true if the end of the compressed data output stream has
|
||||||
* been reached
|
* been reached
|
||||||
*/
|
*/
|
||||||
public synchronized boolean finished() {
|
public boolean finished() {
|
||||||
|
synchronized (zsRef) {
|
||||||
return finished;
|
return finished;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Compresses the input data and fills specified buffer with compressed
|
* Compresses the input data and fills specified buffer with compressed
|
||||||
@ -399,26 +413,31 @@ class Deflater {
|
|||||||
* @throws IllegalArgumentException if the flush mode is invalid
|
* @throws IllegalArgumentException if the flush mode is invalid
|
||||||
* @since 1.7
|
* @since 1.7
|
||||||
*/
|
*/
|
||||||
public synchronized int deflate(byte[] b, int off, int len, int flush) {
|
public int deflate(byte[] b, int off, int len, int flush) {
|
||||||
if (b == null) {
|
if (b == null) {
|
||||||
throw new NullPointerException();
|
throw new NullPointerException();
|
||||||
}
|
}
|
||||||
if (off < 0 || len < 0 || off > b.length - len) {
|
if (off < 0 || len < 0 || off > b.length - len) {
|
||||||
throw new ArrayIndexOutOfBoundsException();
|
throw new ArrayIndexOutOfBoundsException();
|
||||||
}
|
}
|
||||||
|
synchronized (zsRef) {
|
||||||
|
ensureOpen();
|
||||||
if (flush == NO_FLUSH || flush == SYNC_FLUSH ||
|
if (flush == NO_FLUSH || flush == SYNC_FLUSH ||
|
||||||
flush == FULL_FLUSH)
|
flush == FULL_FLUSH)
|
||||||
return deflateBytes(b, off, len, flush);
|
return deflateBytes(zsRef.address(), b, off, len, flush);
|
||||||
throw new IllegalArgumentException();
|
throw new IllegalArgumentException();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the ADLER-32 value of the uncompressed data.
|
* Returns the ADLER-32 value of the uncompressed data.
|
||||||
* @return the ADLER-32 value of the uncompressed data
|
* @return the ADLER-32 value of the uncompressed data
|
||||||
*/
|
*/
|
||||||
public synchronized int getAdler() {
|
public int getAdler() {
|
||||||
|
synchronized (zsRef) {
|
||||||
ensureOpen();
|
ensureOpen();
|
||||||
return getAdler(strm);
|
return getAdler(zsRef.address());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -440,9 +459,11 @@ class Deflater {
|
|||||||
* @return the total (non-negative) number of uncompressed bytes input so far
|
* @return the total (non-negative) number of uncompressed bytes input so far
|
||||||
* @since 1.5
|
* @since 1.5
|
||||||
*/
|
*/
|
||||||
public synchronized long getBytesRead() {
|
public long getBytesRead() {
|
||||||
|
synchronized (zsRef) {
|
||||||
ensureOpen();
|
ensureOpen();
|
||||||
return getBytesRead(strm);
|
return getBytesRead(zsRef.address());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -464,22 +485,26 @@ class Deflater {
|
|||||||
* @return the total (non-negative) number of compressed bytes output so far
|
* @return the total (non-negative) number of compressed bytes output so far
|
||||||
* @since 1.5
|
* @since 1.5
|
||||||
*/
|
*/
|
||||||
public synchronized long getBytesWritten() {
|
public long getBytesWritten() {
|
||||||
|
synchronized (zsRef) {
|
||||||
ensureOpen();
|
ensureOpen();
|
||||||
return getBytesWritten(strm);
|
return getBytesWritten(zsRef.address());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Resets deflater so that a new set of input data can be processed.
|
* Resets deflater so that a new set of input data can be processed.
|
||||||
* Keeps current compression level and strategy settings.
|
* Keeps current compression level and strategy settings.
|
||||||
*/
|
*/
|
||||||
public synchronized void reset() {
|
public void reset() {
|
||||||
|
synchronized (zsRef) {
|
||||||
ensureOpen();
|
ensureOpen();
|
||||||
reset(strm);
|
reset(zsRef.address());
|
||||||
finish = false;
|
finish = false;
|
||||||
finished = false;
|
finished = false;
|
||||||
off = len = 0;
|
off = len = 0;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Closes the compressor and discards any unprocessed input.
|
* Closes the compressor and discards any unprocessed input.
|
||||||
@ -488,13 +513,16 @@ class Deflater {
|
|||||||
* finalize() method. Once this method is called, the behavior
|
* finalize() method. Once this method is called, the behavior
|
||||||
* of the Deflater object is undefined.
|
* of the Deflater object is undefined.
|
||||||
*/
|
*/
|
||||||
public synchronized void end() {
|
public void end() {
|
||||||
if (strm != 0) {
|
synchronized (zsRef) {
|
||||||
end(strm);
|
long addr = zsRef.address();
|
||||||
strm = 0;
|
zsRef.clear();
|
||||||
|
if (addr != 0) {
|
||||||
|
end(addr);
|
||||||
buf = null;
|
buf = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Closes the compressor when garbage is collected.
|
* Closes the compressor when garbage is collected.
|
||||||
@ -504,18 +532,19 @@ class Deflater {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void ensureOpen() {
|
private void ensureOpen() {
|
||||||
if (strm == 0)
|
assert Thread.holdsLock(zsRef);
|
||||||
throw new NullPointerException();
|
if (zsRef.address() == 0)
|
||||||
|
throw new NullPointerException("Deflater has been closed");
|
||||||
}
|
}
|
||||||
|
|
||||||
private static native void initIDs();
|
private static native void initIDs();
|
||||||
private native static long init(int level, int strategy, boolean nowrap);
|
private native static long init(int level, int strategy, boolean nowrap);
|
||||||
private native static void setDictionary(long strm, byte[] b, int off,
|
private native static void setDictionary(long addr, byte[] b, int off, int len);
|
||||||
int len);
|
private native int deflateBytes(long addr, byte[] b, int off, int len,
|
||||||
private native int deflateBytes(byte[] b, int off, int len, int flush);
|
int flush);
|
||||||
private native static int getAdler(long strm);
|
private native static int getAdler(long addr);
|
||||||
private native static long getBytesRead(long strm);
|
private native static long getBytesRead(long addr);
|
||||||
private native static long getBytesWritten(long strm);
|
private native static long getBytesWritten(long addr);
|
||||||
private native static void reset(long strm);
|
private native static void reset(long addr);
|
||||||
private native static void end(long strm);
|
private native static void end(long addr);
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 1996-2008 Sun Microsystems, Inc. All Rights Reserved.
|
* Copyright 1996-2009 Sun Microsystems, Inc. All Rights Reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -72,7 +72,8 @@ package java.util.zip;
|
|||||||
*/
|
*/
|
||||||
public
|
public
|
||||||
class Inflater {
|
class Inflater {
|
||||||
private long strm;
|
|
||||||
|
private final ZStreamRef zsRef;
|
||||||
private byte[] buf = defaultBuf;
|
private byte[] buf = defaultBuf;
|
||||||
private int off, len;
|
private int off, len;
|
||||||
private boolean finished;
|
private boolean finished;
|
||||||
@ -97,7 +98,7 @@ class Inflater {
|
|||||||
* @param nowrap if true then support GZIP compatible compression
|
* @param nowrap if true then support GZIP compatible compression
|
||||||
*/
|
*/
|
||||||
public Inflater(boolean nowrap) {
|
public Inflater(boolean nowrap) {
|
||||||
strm = init(nowrap);
|
zsRef = new ZStreamRef(init(nowrap));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -116,17 +117,19 @@ class Inflater {
|
|||||||
* @param len the length of the input data
|
* @param len the length of the input data
|
||||||
* @see Inflater#needsInput
|
* @see Inflater#needsInput
|
||||||
*/
|
*/
|
||||||
public synchronized void setInput(byte[] b, int off, int len) {
|
public void setInput(byte[] b, int off, int len) {
|
||||||
if (b == null) {
|
if (b == null) {
|
||||||
throw new NullPointerException();
|
throw new NullPointerException();
|
||||||
}
|
}
|
||||||
if (off < 0 || len < 0 || off > b.length - len) {
|
if (off < 0 || len < 0 || off > b.length - len) {
|
||||||
throw new ArrayIndexOutOfBoundsException();
|
throw new ArrayIndexOutOfBoundsException();
|
||||||
}
|
}
|
||||||
|
synchronized (zsRef) {
|
||||||
this.buf = b;
|
this.buf = b;
|
||||||
this.off = off;
|
this.off = off;
|
||||||
this.len = len;
|
this.len = len;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets input data for decompression. Should be called whenever
|
* Sets input data for decompression. Should be called whenever
|
||||||
@ -150,16 +153,19 @@ class Inflater {
|
|||||||
* @see Inflater#needsDictionary
|
* @see Inflater#needsDictionary
|
||||||
* @see Inflater#getAdler
|
* @see Inflater#getAdler
|
||||||
*/
|
*/
|
||||||
public synchronized void setDictionary(byte[] b, int off, int len) {
|
public void setDictionary(byte[] b, int off, int len) {
|
||||||
if (strm == 0 || b == null) {
|
if (b == null) {
|
||||||
throw new NullPointerException();
|
throw new NullPointerException();
|
||||||
}
|
}
|
||||||
if (off < 0 || len < 0 || off > b.length - len) {
|
if (off < 0 || len < 0 || off > b.length - len) {
|
||||||
throw new ArrayIndexOutOfBoundsException();
|
throw new ArrayIndexOutOfBoundsException();
|
||||||
}
|
}
|
||||||
setDictionary(strm, b, off, len);
|
synchronized (zsRef) {
|
||||||
|
ensureOpen();
|
||||||
|
setDictionary(zsRef.address(), b, off, len);
|
||||||
needDict = false;
|
needDict = false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the preset dictionary to the given array of bytes. Should be
|
* Sets the preset dictionary to the given array of bytes. Should be
|
||||||
@ -180,9 +186,11 @@ class Inflater {
|
|||||||
* buffer after decompression has finished.
|
* buffer after decompression has finished.
|
||||||
* @return the total number of bytes remaining in the input buffer
|
* @return the total number of bytes remaining in the input buffer
|
||||||
*/
|
*/
|
||||||
public synchronized int getRemaining() {
|
public int getRemaining() {
|
||||||
|
synchronized (zsRef) {
|
||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns true if no data remains in the input buffer. This can
|
* Returns true if no data remains in the input buffer. This can
|
||||||
@ -190,18 +198,22 @@ class Inflater {
|
|||||||
* to provide more input.
|
* to provide more input.
|
||||||
* @return true if no data remains in the input buffer
|
* @return true if no data remains in the input buffer
|
||||||
*/
|
*/
|
||||||
public synchronized boolean needsInput() {
|
public boolean needsInput() {
|
||||||
|
synchronized (zsRef) {
|
||||||
return len <= 0;
|
return len <= 0;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns true if a preset dictionary is needed for decompression.
|
* Returns true if a preset dictionary is needed for decompression.
|
||||||
* @return true if a preset dictionary is needed for decompression
|
* @return true if a preset dictionary is needed for decompression
|
||||||
* @see Inflater#setDictionary
|
* @see Inflater#setDictionary
|
||||||
*/
|
*/
|
||||||
public synchronized boolean needsDictionary() {
|
public boolean needsDictionary() {
|
||||||
|
synchronized (zsRef) {
|
||||||
return needDict;
|
return needDict;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns true if the end of the compressed data stream has been
|
* Returns true if the end of the compressed data stream has been
|
||||||
@ -209,9 +221,11 @@ class Inflater {
|
|||||||
* @return true if the end of the compressed data stream has been
|
* @return true if the end of the compressed data stream has been
|
||||||
* reached
|
* reached
|
||||||
*/
|
*/
|
||||||
public synchronized boolean finished() {
|
public boolean finished() {
|
||||||
|
synchronized (zsRef) {
|
||||||
return finished;
|
return finished;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Uncompresses bytes into specified buffer. Returns actual number
|
* Uncompresses bytes into specified buffer. Returns actual number
|
||||||
@ -228,7 +242,7 @@ class Inflater {
|
|||||||
* @see Inflater#needsInput
|
* @see Inflater#needsInput
|
||||||
* @see Inflater#needsDictionary
|
* @see Inflater#needsDictionary
|
||||||
*/
|
*/
|
||||||
public synchronized int inflate(byte[] b, int off, int len)
|
public int inflate(byte[] b, int off, int len)
|
||||||
throws DataFormatException
|
throws DataFormatException
|
||||||
{
|
{
|
||||||
if (b == null) {
|
if (b == null) {
|
||||||
@ -237,7 +251,10 @@ class Inflater {
|
|||||||
if (off < 0 || len < 0 || off > b.length - len) {
|
if (off < 0 || len < 0 || off > b.length - len) {
|
||||||
throw new ArrayIndexOutOfBoundsException();
|
throw new ArrayIndexOutOfBoundsException();
|
||||||
}
|
}
|
||||||
return inflateBytes(b, off, len);
|
synchronized (zsRef) {
|
||||||
|
ensureOpen();
|
||||||
|
return inflateBytes(zsRef.address(), b, off, len);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -261,9 +278,11 @@ class Inflater {
|
|||||||
* Returns the ADLER-32 value of the uncompressed data.
|
* Returns the ADLER-32 value of the uncompressed data.
|
||||||
* @return the ADLER-32 value of the uncompressed data
|
* @return the ADLER-32 value of the uncompressed data
|
||||||
*/
|
*/
|
||||||
public synchronized int getAdler() {
|
public int getAdler() {
|
||||||
|
synchronized (zsRef) {
|
||||||
ensureOpen();
|
ensureOpen();
|
||||||
return getAdler(strm);
|
return getAdler(zsRef.address());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -285,9 +304,11 @@ class Inflater {
|
|||||||
* @return the total (non-negative) number of compressed bytes input so far
|
* @return the total (non-negative) number of compressed bytes input so far
|
||||||
* @since 1.5
|
* @since 1.5
|
||||||
*/
|
*/
|
||||||
public synchronized long getBytesRead() {
|
public long getBytesRead() {
|
||||||
|
synchronized (zsRef) {
|
||||||
ensureOpen();
|
ensureOpen();
|
||||||
return getBytesRead(strm);
|
return getBytesRead(zsRef.address());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -309,22 +330,26 @@ class Inflater {
|
|||||||
* @return the total (non-negative) number of uncompressed bytes output so far
|
* @return the total (non-negative) number of uncompressed bytes output so far
|
||||||
* @since 1.5
|
* @since 1.5
|
||||||
*/
|
*/
|
||||||
public synchronized long getBytesWritten() {
|
public long getBytesWritten() {
|
||||||
|
synchronized (zsRef) {
|
||||||
ensureOpen();
|
ensureOpen();
|
||||||
return getBytesWritten(strm);
|
return getBytesWritten(zsRef.address());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Resets inflater so that a new set of input data can be processed.
|
* Resets inflater so that a new set of input data can be processed.
|
||||||
*/
|
*/
|
||||||
public synchronized void reset() {
|
public void reset() {
|
||||||
|
synchronized (zsRef) {
|
||||||
ensureOpen();
|
ensureOpen();
|
||||||
reset(strm);
|
reset(zsRef.address());
|
||||||
buf = defaultBuf;
|
buf = defaultBuf;
|
||||||
finished = false;
|
finished = false;
|
||||||
needDict = false;
|
needDict = false;
|
||||||
off = len = 0;
|
off = len = 0;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Closes the decompressor and discards any unprocessed input.
|
* Closes the decompressor and discards any unprocessed input.
|
||||||
@ -333,13 +358,16 @@ class Inflater {
|
|||||||
* method. Once this method is called, the behavior of the Inflater
|
* method. Once this method is called, the behavior of the Inflater
|
||||||
* object is undefined.
|
* object is undefined.
|
||||||
*/
|
*/
|
||||||
public synchronized void end() {
|
public void end() {
|
||||||
if (strm != 0) {
|
synchronized (zsRef) {
|
||||||
end(strm);
|
long addr = zsRef.address();
|
||||||
strm = 0;
|
zsRef.clear();
|
||||||
|
if (addr != 0) {
|
||||||
|
end(addr);
|
||||||
buf = null;
|
buf = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Closes the decompressor when garbage is collected.
|
* Closes the decompressor when garbage is collected.
|
||||||
@ -349,19 +377,20 @@ class Inflater {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void ensureOpen () {
|
private void ensureOpen () {
|
||||||
if (strm == 0)
|
assert Thread.holdsLock(zsRef);
|
||||||
throw new NullPointerException();
|
if (zsRef.address() == 0)
|
||||||
|
throw new NullPointerException("Inflater has been closed");
|
||||||
}
|
}
|
||||||
|
|
||||||
private native static void initIDs();
|
private native static void initIDs();
|
||||||
private native static long init(boolean nowrap);
|
private native static long init(boolean nowrap);
|
||||||
private native static void setDictionary(long strm, byte[] b, int off,
|
private native static void setDictionary(long addr, byte[] b, int off,
|
||||||
int len);
|
int len);
|
||||||
private native int inflateBytes(byte[] b, int off, int len)
|
private native int inflateBytes(long addr, byte[] b, int off, int len)
|
||||||
throws DataFormatException;
|
throws DataFormatException;
|
||||||
private native static int getAdler(long strm);
|
private native static int getAdler(long addr);
|
||||||
private native static long getBytesRead(long strm);
|
private native static long getBytesRead(long addr);
|
||||||
private native static long getBytesWritten(long strm);
|
private native static long getBytesWritten(long addr);
|
||||||
private native static void reset(long strm);
|
private native static void reset(long addr);
|
||||||
private native static void end(long strm);
|
private native static void end(long addr);
|
||||||
}
|
}
|
||||||
|
46
jdk/src/share/classes/java/util/zip/ZStreamRef.java
Normal file
46
jdk/src/share/classes/java/util/zip/ZStreamRef.java
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2009 Sun Microsystems, Inc. All Rights Reserved.
|
||||||
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
|
*
|
||||||
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License version 2 only, as
|
||||||
|
* published by the Free Software Foundation. Sun designates this
|
||||||
|
* particular file as subject to the "Classpath" exception as provided
|
||||||
|
* by Sun in the LICENSE file that accompanied this code.
|
||||||
|
*
|
||||||
|
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
* version 2 for more details (a copy is included in the LICENSE file that
|
||||||
|
* accompanied this code).
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License version
|
||||||
|
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||||
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*
|
||||||
|
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
||||||
|
* CA 95054 USA or visit www.sun.com if you need additional information or
|
||||||
|
* have any questions.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package java.util.zip;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A reference to the native zlib's z_stream structure.
|
||||||
|
*/
|
||||||
|
|
||||||
|
class ZStreamRef {
|
||||||
|
|
||||||
|
private long address;
|
||||||
|
ZStreamRef (long address) {
|
||||||
|
this.address = address;
|
||||||
|
}
|
||||||
|
|
||||||
|
long address() {
|
||||||
|
return address;
|
||||||
|
}
|
||||||
|
|
||||||
|
void clear() {
|
||||||
|
address = 0;
|
||||||
|
}
|
||||||
|
}
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 1997-2005 Sun Microsystems, Inc. All Rights Reserved.
|
* Copyright 1997-2009 Sun Microsystems, Inc. All Rights Reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -38,7 +38,6 @@
|
|||||||
|
|
||||||
#define DEF_MEM_LEVEL 8
|
#define DEF_MEM_LEVEL 8
|
||||||
|
|
||||||
static jfieldID strmID;
|
|
||||||
static jfieldID levelID;
|
static jfieldID levelID;
|
||||||
static jfieldID strategyID;
|
static jfieldID strategyID;
|
||||||
static jfieldID setParamsID;
|
static jfieldID setParamsID;
|
||||||
@ -49,7 +48,6 @@ static jfieldID bufID, offID, lenID;
|
|||||||
JNIEXPORT void JNICALL
|
JNIEXPORT void JNICALL
|
||||||
Java_java_util_zip_Deflater_initIDs(JNIEnv *env, jclass cls)
|
Java_java_util_zip_Deflater_initIDs(JNIEnv *env, jclass cls)
|
||||||
{
|
{
|
||||||
strmID = (*env)->GetFieldID(env, cls, "strm", "J");
|
|
||||||
levelID = (*env)->GetFieldID(env, cls, "level", "I");
|
levelID = (*env)->GetFieldID(env, cls, "level", "I");
|
||||||
strategyID = (*env)->GetFieldID(env, cls, "strategy", "I");
|
strategyID = (*env)->GetFieldID(env, cls, "strategy", "I");
|
||||||
setParamsID = (*env)->GetFieldID(env, cls, "setParams", "Z");
|
setParamsID = (*env)->GetFieldID(env, cls, "setParams", "Z");
|
||||||
@ -94,7 +92,7 @@ Java_java_util_zip_Deflater_init(JNIEnv *env, jclass cls, jint level,
|
|||||||
}
|
}
|
||||||
|
|
||||||
JNIEXPORT void JNICALL
|
JNIEXPORT void JNICALL
|
||||||
Java_java_util_zip_Deflater_setDictionary(JNIEnv *env, jclass cls, jlong strm,
|
Java_java_util_zip_Deflater_setDictionary(JNIEnv *env, jclass cls, jlong addr,
|
||||||
jarray b, jint off, jint len)
|
jarray b, jint off, jint len)
|
||||||
{
|
{
|
||||||
Bytef *buf = (*env)->GetPrimitiveArrayCritical(env, b, 0);
|
Bytef *buf = (*env)->GetPrimitiveArrayCritical(env, b, 0);
|
||||||
@ -102,7 +100,7 @@ Java_java_util_zip_Deflater_setDictionary(JNIEnv *env, jclass cls, jlong strm,
|
|||||||
if (buf == 0) {/* out of memory */
|
if (buf == 0) {/* out of memory */
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
res = deflateSetDictionary((z_stream *)jlong_to_ptr(strm), buf + off, len);
|
res = deflateSetDictionary((z_stream *)jlong_to_ptr(addr), buf + off, len);
|
||||||
(*env)->ReleasePrimitiveArrayCritical(env, b, buf, 0);
|
(*env)->ReleasePrimitiveArrayCritical(env, b, buf, 0);
|
||||||
switch (res) {
|
switch (res) {
|
||||||
case Z_OK:
|
case Z_OK:
|
||||||
@ -111,21 +109,17 @@ Java_java_util_zip_Deflater_setDictionary(JNIEnv *env, jclass cls, jlong strm,
|
|||||||
JNU_ThrowIllegalArgumentException(env, 0);
|
JNU_ThrowIllegalArgumentException(env, 0);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
JNU_ThrowInternalError(env, ((z_stream *)jlong_to_ptr(strm))->msg);
|
JNU_ThrowInternalError(env, ((z_stream *)jlong_to_ptr(addr))->msg);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
JNIEXPORT jint JNICALL
|
JNIEXPORT jint JNICALL
|
||||||
Java_java_util_zip_Deflater_deflateBytes(JNIEnv *env, jobject this,
|
Java_java_util_zip_Deflater_deflateBytes(JNIEnv *env, jobject this, jlong addr,
|
||||||
jarray b, jint off, jint len, jint flush)
|
jarray b, jint off, jint len, jint flush)
|
||||||
{
|
{
|
||||||
z_stream *strm = jlong_to_ptr((*env)->GetLongField(env, this, strmID));
|
z_stream *strm = jlong_to_ptr(addr);
|
||||||
|
|
||||||
if (strm == 0) {
|
|
||||||
JNU_ThrowNullPointerException(env, 0);
|
|
||||||
return 0;
|
|
||||||
} else {
|
|
||||||
jarray this_buf = (*env)->GetObjectField(env, this, bufID);
|
jarray this_buf = (*env)->GetObjectField(env, this, bufID);
|
||||||
jint this_off = (*env)->GetIntField(env, this, offID);
|
jint this_off = (*env)->GetIntField(env, this, offID);
|
||||||
jint this_len = (*env)->GetIntField(env, this, lenID);
|
jint this_len = (*env)->GetIntField(env, this, lenID);
|
||||||
@ -142,7 +136,6 @@ Java_java_util_zip_Deflater_deflateBytes(JNIEnv *env, jobject this,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
(*env)->GetByteArrayRegion(env, this_buf, this_off, this_len, in_buf);
|
(*env)->GetByteArrayRegion(env, this_buf, this_off, this_len, in_buf);
|
||||||
|
|
||||||
out_buf = (jbyte *) malloc(len);
|
out_buf = (jbyte *) malloc(len);
|
||||||
if (out_buf == 0) {
|
if (out_buf == 0) {
|
||||||
free(in_buf);
|
free(in_buf);
|
||||||
@ -178,7 +171,6 @@ Java_java_util_zip_Deflater_deflateBytes(JNIEnv *env, jobject this,
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
jboolean finish = (*env)->GetBooleanField(env, this, finishID);
|
jboolean finish = (*env)->GetBooleanField(env, this, finishID);
|
||||||
|
|
||||||
in_buf = (jbyte *) malloc(this_len);
|
in_buf = (jbyte *) malloc(this_len);
|
||||||
if (in_buf == 0) {
|
if (in_buf == 0) {
|
||||||
JNU_ThrowOutOfMemoryError(env, 0);
|
JNU_ThrowOutOfMemoryError(env, 0);
|
||||||
@ -221,41 +213,40 @@ Java_java_util_zip_Deflater_deflateBytes(JNIEnv *env, jobject this,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
JNIEXPORT jint JNICALL
|
JNIEXPORT jint JNICALL
|
||||||
Java_java_util_zip_Deflater_getAdler(JNIEnv *env, jclass cls, jlong strm)
|
Java_java_util_zip_Deflater_getAdler(JNIEnv *env, jclass cls, jlong addr)
|
||||||
{
|
{
|
||||||
return ((z_stream *)jlong_to_ptr(strm))->adler;
|
return ((z_stream *)jlong_to_ptr(addr))->adler;
|
||||||
}
|
}
|
||||||
|
|
||||||
JNIEXPORT jlong JNICALL
|
JNIEXPORT jlong JNICALL
|
||||||
Java_java_util_zip_Deflater_getBytesRead(JNIEnv *env, jclass cls, jlong strm)
|
Java_java_util_zip_Deflater_getBytesRead(JNIEnv *env, jclass cls, jlong addr)
|
||||||
{
|
{
|
||||||
return ((z_stream *)jlong_to_ptr(strm))->total_in;
|
return ((z_stream *)jlong_to_ptr(addr))->total_in;
|
||||||
}
|
}
|
||||||
|
|
||||||
JNIEXPORT jlong JNICALL
|
JNIEXPORT jlong JNICALL
|
||||||
Java_java_util_zip_Deflater_getBytesWritten(JNIEnv *env, jclass cls, jlong strm)
|
Java_java_util_zip_Deflater_getBytesWritten(JNIEnv *env, jclass cls, jlong addr)
|
||||||
{
|
{
|
||||||
return ((z_stream *)jlong_to_ptr(strm))->total_out;
|
return ((z_stream *)jlong_to_ptr(addr))->total_out;
|
||||||
}
|
}
|
||||||
|
|
||||||
JNIEXPORT void JNICALL
|
JNIEXPORT void JNICALL
|
||||||
Java_java_util_zip_Deflater_reset(JNIEnv *env, jclass cls, jlong strm)
|
Java_java_util_zip_Deflater_reset(JNIEnv *env, jclass cls, jlong addr)
|
||||||
{
|
{
|
||||||
if (deflateReset((z_stream *)jlong_to_ptr(strm)) != Z_OK) {
|
if (deflateReset((z_stream *)jlong_to_ptr(addr)) != Z_OK) {
|
||||||
JNU_ThrowInternalError(env, 0);
|
JNU_ThrowInternalError(env, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
JNIEXPORT void JNICALL
|
JNIEXPORT void JNICALL
|
||||||
Java_java_util_zip_Deflater_end(JNIEnv *env, jclass cls, jlong strm)
|
Java_java_util_zip_Deflater_end(JNIEnv *env, jclass cls, jlong addr)
|
||||||
{
|
{
|
||||||
if (deflateEnd((z_stream *)jlong_to_ptr(strm)) == Z_STREAM_ERROR) {
|
if (deflateEnd((z_stream *)jlong_to_ptr(addr)) == Z_STREAM_ERROR) {
|
||||||
JNU_ThrowInternalError(env, 0);
|
JNU_ThrowInternalError(env, 0);
|
||||||
} else {
|
} else {
|
||||||
free((z_stream *)jlong_to_ptr(strm));
|
free((z_stream *)jlong_to_ptr(addr));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 1997-2005 Sun Microsystems, Inc. All Rights Reserved.
|
* Copyright 1997-2009 Sun Microsystems, Inc. All Rights Reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -41,7 +41,6 @@
|
|||||||
#define ThrowDataFormatException(env, msg) \
|
#define ThrowDataFormatException(env, msg) \
|
||||||
JNU_ThrowByName(env, "java/util/zip/DataFormatException", msg)
|
JNU_ThrowByName(env, "java/util/zip/DataFormatException", msg)
|
||||||
|
|
||||||
static jfieldID strmID;
|
|
||||||
static jfieldID needDictID;
|
static jfieldID needDictID;
|
||||||
static jfieldID finishedID;
|
static jfieldID finishedID;
|
||||||
static jfieldID bufID, offID, lenID;
|
static jfieldID bufID, offID, lenID;
|
||||||
@ -49,7 +48,6 @@ static jfieldID bufID, offID, lenID;
|
|||||||
JNIEXPORT void JNICALL
|
JNIEXPORT void JNICALL
|
||||||
Java_java_util_zip_Inflater_initIDs(JNIEnv *env, jclass cls)
|
Java_java_util_zip_Inflater_initIDs(JNIEnv *env, jclass cls)
|
||||||
{
|
{
|
||||||
strmID = (*env)->GetFieldID(env, cls, "strm", "J");
|
|
||||||
needDictID = (*env)->GetFieldID(env, cls, "needDict", "Z");
|
needDictID = (*env)->GetFieldID(env, cls, "needDict", "Z");
|
||||||
finishedID = (*env)->GetFieldID(env, cls, "finished", "Z");
|
finishedID = (*env)->GetFieldID(env, cls, "finished", "Z");
|
||||||
bufID = (*env)->GetFieldID(env, cls, "buf", "[B");
|
bufID = (*env)->GetFieldID(env, cls, "buf", "[B");
|
||||||
@ -84,38 +82,34 @@ Java_java_util_zip_Inflater_init(JNIEnv *env, jclass cls, jboolean nowrap)
|
|||||||
}
|
}
|
||||||
|
|
||||||
JNIEXPORT void JNICALL
|
JNIEXPORT void JNICALL
|
||||||
Java_java_util_zip_Inflater_setDictionary(JNIEnv *env, jclass cls, jlong strm,
|
Java_java_util_zip_Inflater_setDictionary(JNIEnv *env, jclass cls, jlong addr,
|
||||||
jarray b, jint off, jint len)
|
jarray b, jint off, jint len)
|
||||||
{
|
{
|
||||||
Bytef *buf = (*env)->GetPrimitiveArrayCritical(env, b, 0);
|
Bytef *buf = (*env)->GetPrimitiveArrayCritical(env, b, 0);
|
||||||
int res;
|
int res;
|
||||||
if (buf == 0) /* out of memory */
|
if (buf == 0) /* out of memory */
|
||||||
return;
|
return;
|
||||||
res = inflateSetDictionary(jlong_to_ptr(strm), buf + off, len);
|
res = inflateSetDictionary(jlong_to_ptr(addr), buf + off, len);
|
||||||
(*env)->ReleasePrimitiveArrayCritical(env, b, buf, 0);
|
(*env)->ReleasePrimitiveArrayCritical(env, b, buf, 0);
|
||||||
switch (res) {
|
switch (res) {
|
||||||
case Z_OK:
|
case Z_OK:
|
||||||
break;
|
break;
|
||||||
case Z_STREAM_ERROR:
|
case Z_STREAM_ERROR:
|
||||||
case Z_DATA_ERROR:
|
case Z_DATA_ERROR:
|
||||||
JNU_ThrowIllegalArgumentException(env, ((z_stream *)jlong_to_ptr(strm))->msg);
|
JNU_ThrowIllegalArgumentException(env, ((z_stream *)jlong_to_ptr(addr))->msg);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
JNU_ThrowInternalError(env, ((z_stream *)jlong_to_ptr(strm))->msg);
|
JNU_ThrowInternalError(env, ((z_stream *)jlong_to_ptr(addr))->msg);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
JNIEXPORT jint JNICALL
|
JNIEXPORT jint JNICALL
|
||||||
Java_java_util_zip_Inflater_inflateBytes(JNIEnv *env, jobject this,
|
Java_java_util_zip_Inflater_inflateBytes(JNIEnv *env, jobject this, jlong addr,
|
||||||
jarray b, jint off, jint len)
|
jarray b, jint off, jint len)
|
||||||
{
|
{
|
||||||
z_stream *strm = jlong_to_ptr((*env)->GetLongField(env, this, strmID));
|
z_stream *strm = jlong_to_ptr(addr);
|
||||||
|
|
||||||
if (strm == 0) {
|
|
||||||
JNU_ThrowNullPointerException(env, 0);
|
|
||||||
return 0;
|
|
||||||
} else {
|
|
||||||
jarray this_buf = (jarray)(*env)->GetObjectField(env, this, bufID);
|
jarray this_buf = (jarray)(*env)->GetObjectField(env, this, bufID);
|
||||||
jint this_off = (*env)->GetIntField(env, this, offID);
|
jint this_off = (*env)->GetIntField(env, this, offID);
|
||||||
jint this_len = (*env)->GetIntField(env, this, lenID);
|
jint this_len = (*env)->GetIntField(env, this, lenID);
|
||||||
@ -177,41 +171,40 @@ Java_java_util_zip_Inflater_inflateBytes(JNIEnv *env, jobject this,
|
|||||||
JNU_ThrowInternalError(env, strm->msg);
|
JNU_ThrowInternalError(env, strm->msg);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
JNIEXPORT jint JNICALL
|
JNIEXPORT jint JNICALL
|
||||||
Java_java_util_zip_Inflater_getAdler(JNIEnv *env, jclass cls, jlong strm)
|
Java_java_util_zip_Inflater_getAdler(JNIEnv *env, jclass cls, jlong addr)
|
||||||
{
|
{
|
||||||
return ((z_stream *)jlong_to_ptr(strm))->adler;
|
return ((z_stream *)jlong_to_ptr(addr))->adler;
|
||||||
}
|
}
|
||||||
|
|
||||||
JNIEXPORT jlong JNICALL
|
JNIEXPORT jlong JNICALL
|
||||||
Java_java_util_zip_Inflater_getBytesRead(JNIEnv *env, jclass cls, jlong strm)
|
Java_java_util_zip_Inflater_getBytesRead(JNIEnv *env, jclass cls, jlong addr)
|
||||||
{
|
{
|
||||||
return ((z_stream *)jlong_to_ptr(strm))->total_in;
|
return ((z_stream *)jlong_to_ptr(addr))->total_in;
|
||||||
}
|
}
|
||||||
|
|
||||||
JNIEXPORT jlong JNICALL
|
JNIEXPORT jlong JNICALL
|
||||||
Java_java_util_zip_Inflater_getBytesWritten(JNIEnv *env, jclass cls, jlong strm)
|
Java_java_util_zip_Inflater_getBytesWritten(JNIEnv *env, jclass cls, jlong addr)
|
||||||
{
|
{
|
||||||
return ((z_stream *)jlong_to_ptr(strm))->total_out;
|
return ((z_stream *)jlong_to_ptr(addr))->total_out;
|
||||||
}
|
}
|
||||||
|
|
||||||
JNIEXPORT void JNICALL
|
JNIEXPORT void JNICALL
|
||||||
Java_java_util_zip_Inflater_reset(JNIEnv *env, jclass cls, jlong strm)
|
Java_java_util_zip_Inflater_reset(JNIEnv *env, jclass cls, jlong addr)
|
||||||
{
|
{
|
||||||
if (inflateReset(jlong_to_ptr(strm)) != Z_OK) {
|
if (inflateReset(jlong_to_ptr(addr)) != Z_OK) {
|
||||||
JNU_ThrowInternalError(env, 0);
|
JNU_ThrowInternalError(env, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
JNIEXPORT void JNICALL
|
JNIEXPORT void JNICALL
|
||||||
Java_java_util_zip_Inflater_end(JNIEnv *env, jclass cls, jlong strm)
|
Java_java_util_zip_Inflater_end(JNIEnv *env, jclass cls, jlong addr)
|
||||||
{
|
{
|
||||||
if (inflateEnd(jlong_to_ptr(strm)) == Z_STREAM_ERROR) {
|
if (inflateEnd(jlong_to_ptr(addr)) == Z_STREAM_ERROR) {
|
||||||
JNU_ThrowInternalError(env, 0);
|
JNU_ThrowInternalError(env, 0);
|
||||||
} else {
|
} else {
|
||||||
free(jlong_to_ptr(strm));
|
free(jlong_to_ptr(addr));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user