java.util.zip/jar integration

Project:JNode Core
Component:Code
Category:task
Priority:normal
Assigned:cluster
Status:won't fix
Description

Jar/Zip openjdk integration is almost complete. Having some trouble making Deflater work. If someone wishes to take a look i'll outline how to setup the project and a brief on the issue.

http://www.mypipedreams.net/openjdk_native_sandbox.zip

That is the project root, unzip into a workspace and import into eclipse.

In order to make any tests work, a seperate rt.jar needs to be created overwriting the normal java.util.zip/jar code with the class files from that project. To do this, a new System JRE library needs to be created with the new rt.jar.

From Eclipse 3.3
Window > Preferences
Java > Installed JREs

Select the default JRE and click Copy.
Make a copy of the rt.jar listed in the default jre, i named it jnode-rt.jar
Remove the rt.jar from the list and click Add External JARs
Add jnode-rt.jar to the list

You should now have a new System JRE that is using the alternate rt.jar.

Using a GUI/CLI app, you need to modify jnode-rt.jar
Remove all the class files under java/util/zip and java/util/jar
Insert the class files from the project unzipped earlier into jnode-rt.jar

You'll know have a system JRE that uses the custom zip/jar class files and supporting code. Anytime you build the project above you will have to re-inject the modified class files into the jar to see the changes.

In order to use these changes, be sure to change the System JRE from the build path to use the new one, and not the default. If the following test class is in a different project, be sure to set them both to use the new System JRE.

To test, i use a hacked together test class that basically attempts to zip the contents of a directory, and then unzip it. Has options to turn on/off writing and verbosity. The contents of the method that deflate/inflate are roughly taken from a sun tutorial on how to use ZipInputStream/ZipOutputStream and is known to work fine with sun jdk.

http://www.mypipedreams.net/JarTest.java

Modify the static vars at the top to set the directory to zip, and the output zip file.

========================================================================================

Now, the issue with Deflater, it seems to be outputting too much information. For the directory i was zipping, sun jdk zipped it to ~5.1k and i was getting ~5.3k. Errors from Inflater were problems reading the CEN (Central Directory).

Im thinking that the problem exists with DeflaterEngine not being called as would be expected from the classpath code. Further investigation could be done to compare classpath Deflater against the Deflater in this class, and see if there are major differences in how state is changing.

Ideally, if the source of the extra bytes could be eliminated no modification would have to be done to any of the supporting classpath classes.

I would like to be able to do this profiling myself, but im not having much spare time as of late. Hopefully if i can get some time i will figure it out, but if someone beats me to it, all the better. If a fix is found, then the zip/jar integration is complete, this is the last major issue. I can then finish the complete integration into JNode.

#1

Status:active» patch (code needs review)

Booted JNode with this patch of java.util.zip and java.util.jar. Had no problem extracting and listing contents. Could not test creation of a jar in JNode as i got FileNotFoundException when attempting to create one. May be some bug in JarCommand itself, as none of the deflate operations deal with files themselves. Patch excludes java.util.jar.Pack200 as requested.

#2

#3

Last patch had a couple of bugs. Fixed those. Still having some issues with jar creation. Tested the code on my linux environment. I can create jars and using the jar command can list/extract them, but my own extraction code will not. Tested the extraction code on a jar created with the jar command, and they extracted fine. Its kind of a weird problem, will debug more later. For now this new patch will boot JNode, just dont try to create any jars with it yet Eye-wink

#1

Status:patch (code needs review)» won't fix

Due to the nature of the implementation between zip and the jni access layer to zlib, it was decided that it was simply easier to maintain the classpath version, rather than try to maintain a openjdk version.