Java 4k Resources Thread

What’s the (highest) difference in byte count between the best kzip and the best [DeflOpt + BJWFlate] ?

According to the docs I’ve read DeflOpt is already included in BJWflate, so there’s no extra benefit. Are you finding that to be incorrect?

I may have to install wine and play with BJWflate.

BJWFlate.zip is no longer available on walbeehm.com. I managed to find it elsewhere, but I’d prefer to be cautious. Can anyone confirm the md5sum and cksum outputs?

md5sum: 95d7b11a281293045ae9c110881f8bf1 BJWFlate.exe
cksum: 492803991 39936 BJWFlate.exe

I was less cautious, so I’m already running it within Wine, with exactly the same md5sum.

N.B.: Also found it elsewhere, so that doesn’t help you much

Added support for BJWFlate:

A.normal.7z.pack.gz => 3201 bytes A.progrd.7z.pack.gz => 3030 bytes A.normal.kz.pack.gz => 3078 bytes A.progrd.kz.pack.gz => 2930 bytes A.normal.bj.pack.gz => 3107 bytes A.progrd.bj.pack.gz => 2923 bytes

I added DeflOpt, and as pjt33 suspected, it didn’t have any impact on filesize, so it’s disabled for now.

I guess i mistakenly “saw” a benefit with deflopt and bjwflate… but most likely i was mistaken :stuck_out_tongue:


a.java => 11103 bytes
a.class => 3940 bytes
a.normal.jar => 2332 bytes
a.progrd.jar => 1585 bytes
a.normal.pack => 2558 bytes
a.progrd.pack => 1636 bytes
a.normal.7z.pack.gz => 1728 bytes
a.progrd.7z.pack.gz => 1245 bytes
a.normal.kz.pack.gz => 1665 bytes
a.progrd.kz.pack.gz => 1226 bytes
a.normal.bj.pack.gz => 1609 bytes
a.progrd.bj.pack.gz => 1198 bytes

I just re-ran your updated online shrinking tool and it now compresses a further 28 bytes, very nice! now all that is left to be the ultimate tool for my purposes (he he) is for it to accept a JAR as input. I will be reading in a data file at run time so needs to be in the Jar. :slight_smile:

excellent work!

I do have another idea on a completely different track of thought about how to shrink the size of the jar/pack.gz. It is a bit more complex and probably error prone but will be a nice challenge. Perhaps i should actually finish my java4k entry first :stuck_out_tongue:

Done!

fantastic! thanks

This is sooo obvious I can’t believe it hasn’t been brought up before:

Old:

public class M extends Applet implements Runnable {
	private int[] M = new int[32767]; // Shared state

	public void start() {
		new Thread(this).start();
	}

	public void run() {
             // Minecraft 4k game here
        }
}

2018 bytes.

But that adds M to the constant pool when run already is in there!
So what if we name the class and the member “run”?

New code:


public class run extends Applet implements Runnable {
	private int[] run = new int[32767]; // Shared state

	public void start() {
		new Thread(this).start();
	}

	public void run() {
             // Minecraft 4k game here
        }
}

2010 bytes.

haha, n1

Though what does proguard do regarding the member?
Does it realize it’s a shared name, or does it obfuscate it to a single letter?
Might have to run it with special parameters to prevent it obfuscating the member name?

Good question, I’m not using proguard yet in my build chain.
You can make proguard keep the game of the member, though, so it shouldn’t be a problem.

It doesn’t rename the class.

Ah. This wouldn’t have worked before because of the jar file containing a longer name, but with pack200 and gzip the name of the class is stored only in the pack200’s structures, so that’s why this is suddenly better.

Are you sure? “jar.class” is only two letters longer than “M.jar”, and the savings are more than 2 bytes.

I was talking about the member, i.e.

private int[] run = new int[32767]; // Shared state

I believe proguard will (unless you tell it not to) obfuscate this down to ‘a’, and in so doing reverse Markus’s optimisation.

http://www.indiespot.net/app/java-four-kay

I added the option to keep all class members.

Maybe you should give it a try, my tiny examples turn out bigger, to I’m interested in the real deal.

normal Proguard config:

-libraryjars /root/jdk1.6.0_15/jre/lib/rt.jar
-keep public class *
-keep class *
-allowaccessmodification
-overloadaggressively
-optimizationpasses 99
-defaultpackage ''

“keep members” Proguard config:

-libraryjars /root/jdk1.6.0_15/jre/lib/rt.jar
-keep public class *
-keep class *
-allowaccessmodification
-overloadaggressively
-optimizationpasses 99
-defaultpackage ''

-keepclassmembernames class * {
  private *;
  protected *;
  public *;
  * ;
}

Oh. I use

-obfuscationdictionary proguard.dict

where proguard.dict contains

Code
dispose
isActive
start
sleep
run
a

a is there because it’s the name of the class, but if you’re changing that you’d want to drop it. That should be enough names for most Java4k projects, I think. If you need more just run javap over your class file to work out what methods you’re using and update as appropriate.

How are you guys using Riven’s tool in terms of adding images and other resources into the jar?

The diehards rolls their own.

My graphics are animations of 8 frames each which consists of a global palette of 6 colours which of which sequential frames are simply XORed with the previous frame. Very cheap to decode and give sufficient compression (when gzipped) due to the similarities between frames.

I have all my resources in a single separate file which is added to a jar with my class file and then i let Riven’s tool at it :slight_smile: