JZlib - zlib in pure Java
JZlib is a re-implementation of
in pure Java.
The first and final aim for hacking this stuff is to add the packet compression support to pure Java SSH systems.
The zlib is designed to be a free, general-purpose, legally unencumbered -- that is, not covered by any patents -- lossless data-compression library for use on virtually any computer hardware and operating system. The zlib was written by Jean-loup Gailly (compression) and Mark Adler (decompression).
- Needless to say, JZlib can inflate data, which is deflated by zlib and JZlib can generate deflated data, which is acceptable and is inflated by zlib.
- JZlib supports all compression level and all flushing mode in zlib.
- JZlib does not support gzip file handling supports.
- The performance has not been estimated yet, but it will not be so bad in deflating/inflating data stream on the low bandwidth network.
- JZlib is licensed under BSD style license
- Any invention has not been done in developing JZlib. So, if zlib is patent free, JZlib is also not covered by any patents.
Java Platform API provides packages 'java.util.zip.*' for accessing to zlib, but that support is very limited if you need to use the essence of zlib. For example, we needed to full access to zlib to add the packet compression support to pure Java SSH system, but they are useless for our requirements. The Internet draft SSH Transport Layer Protocol says in the section '4.2 Compression' as follows,
The following compression methods are currently defined:
none REQUIRED no compression
zlib OPTIONAL GNU ZLIB (LZ77) compression
The "zlib" compression is described in [RFC-1950] and in [RFC-1951]. The compression context is initialized after each key exchange, and is passed from one packet to the next with only a partial flush being performed at the end of each packet. A partial flush means that all data will be output, but the next packet will continue using compression tables from the end of the previous packet.
To implement this functionality,
the Z_PARTIAL_FLUSH mode of zlib must be used,
however JDK does not permit us to do so.
It seems that this problem has been well known and
some people have already
reported to JavaSoft's BugParade(for example,
but any positive response has not been returned from JavaSoft,
so this problem will not be solved forever.
This is our motivation to hack JZlib.
Of course, this stuff must be useful for any other pure java programs, which need communications with compressed data stream. Feel free to use this stuff in your hack and we are very happy if we get some feedbacks.
Applications Using JZlib
- JSch uses JZlib for the packet compression.
- Apache MINA
- Nokia Data Gathering
- Oracle Database Lite
Bibles for hacking JZlib
We have referred to following works in hacking JZlib.
- [RFC-1950] Deutch, P. and Gailly, J-L: "ZLIB Compressed Data Format Specification version 3.3", May 1996.
- [RFC-1951] Deutch, P: "DEFLATE Compressed Data Format Specification version 1.3", May 1996.
JZlib 1.1.1 is provided in the zip format,
- jzlib-1.1.1.zip (105,716 bytes)
and also its latest source code is available at
JZlib has been developed by ymnk, but he has just re-implemented zlib in pure Java(this stuff was just required to improve the service on WiredX.net). So, all credit should go to authors Jean-loup Gailly and Mark Adler and contributors of zlib.
Comments/suggestions are accepted at email@example.com.
``SSH is a registered trademark and Secure Shell is a trademark of SSH Communications Security Corp (www.ssh.com)''.