Alex headshot

AlBlue’s Blog

Macs, Modularity and More

A little bit closer

2007, java, pack200

I've just managed to successfully decode a no-op Java class (i.e. one with a default constructor) and then have a sample code instantiate the class. This pretty much knits together everything that's there to demonstrate that it works, but currently the argument for the constructor invocation (java.lang.Object#init) is hard-coded. The Pack format is a little bit weird; because it segregates out all of the constant references, and method calls are indexed by those constant references, you have to do re-writing on pretty much every opcode argument that goes through. So zero-arg opcodes (aload_0, return) are a doddle; it's the ones that take arguments (e.g. invokespecial that you have to do the processing work on.

Anyway, the code that figures out the arguments is horribly broken at the moment, but this is enough of a demonstration to take a quick checkpoint and verify that things are moving in the right direction. I expect that the next bit of progress will be quite slow as I figure out the best way to resolve the opcodes' arguments, but at least we're on the right track.