Alex headshot

AlBlue’s Blog

Macs, Modularity and More

Pack200 managed to dump out a field

2006, eclipse, java, pack200

The Pack200 unpacking work is starting to come along nicely. And, as is par for the course, when you get on the final strait1 towards a solution, you suddenly realise that when you started off you were heading in totally the wrong direction and need to change tack ... still, that's what a good refactoring editor is for, huh?

I've now got to the stage where I can decrypt a trivial field and associated constant in an interface, and be able to successfully reconstitute the Jar file. (It's not fully pack200 compliant yet, as I need to sort the constant pool, but it is a valid class file none the less). Of course, if you have interfaces with more than just Ints in them (well, byte/short will probably work OK, and maybe even char) then it's not going to be of much use at the moment. But it does mean that decoding method signatures is likely to be a short hop from here (although decoding bytecodes is another step up in the path).

For those of you who are interested/bored, here's what the reassembled interface looked like:

apple[tmp] javap -c -v test.Test
Compiled from ""
public interface test.Test extends,java.lang.Cloneable
  SourceFile: ""
  minor version: 0
  major version: 49
  Constant pool:
const #1 = Asciz        SourceFile;
const #2 = Asciz;
const #3 = class        #4;     //  test/Test
const #4 = Asciz        test/Test;
const #5 = class        #6;     //  java/lang/Object
const #6 = Asciz        java/lang/Object;
const #7 = class        #8;     //  java/io/Serializable
const #8 = Asciz        java/io/Serializable;
const #9 = class        #10;    //  java/lang/Cloneable
const #10 = Asciz       java/lang/Cloneable;
const #11 = Asciz       WOMBAT;
const #12 = Asciz       I;
const #13 = Asciz       ConstantValue;
const #14 = int 1;

public static final int WOMBAT;
  Constant value: int 1


And with that, I'm checking out for now. The patch is awaiting attention in Harmony's JIRA bug tracking system, after which it should make its way into the SVN repository. Incidentally, the work is being done under ASL, but I'm hoping that it will be re-distributable in an Eclipse install in the future (I've filed bug 161865 to keep track of getting this into Eclipse).