I don't think so, for several reasons.
1) The class and superclass qualified name references are stored in the InstanceInfo block. Since the ABC spec is built for terseness, there is no way to predetermine the location of any block without reading the whole file up to that block. For example, they have some pretty neat tricks in the ABC spec for making a number only as large as it needs to be. Rather than declaring an int to always be four bytes, they say "check out the first byte, and if the last bit in the byte is 1, use that as a flag to determine that there are more bits in this value. Continue looking for final bit flags until you have read the whole number." This means that in the worst case scenario, a number that could have been represented in four bytes ends up requiring four and a half due to the "flag" bits, but in most cases you will save space. Unfortunately, this also means that you have to read every byte one at a time to parse the ABC file, since you never know how big each value will be, and the spec uses ints as indices in to the constant pool in almost every structure to save space (i.e. they have multiple references to the same values in the pool instead of explicitly repeating the values everywhere). Another example is that optional flags on items (such as traits) are only written to the ABC file if prior values hold certain flags - such as optional method arguments, which are only written to method traits if they exist on the method signature; otherwise they are omitted.
2) Technically, you could read all the way up to the InstanceInfo and flip the indices in to the constant pool to change the class qualified name and superclass qualified name, but you'd end up with an invalid ABC file. This is because in order to make a new class name, you'd have to make an entry in to the multiname pool representing it, and an entry in to the string pool for the string portions of the class name and namespace. Without maintaining the ABC file structure, you'd be unable to do this because...
3) ...of the third reason, which is that there are methods (namely the constructor and script initializer) which require references to the qualified name and multiname pool indices in order to instance a class. You have to push the class and superclass indices on to the stack during class init, so if you change the class name and superclass name you would need to modify the referenced indices in to the multiname pool in the opcode. Again, there's no way I know of to predetermine the location of these values without parsing the entire ABC file structure. I've pasted in the opcodes for the script initializer for one of my template classes in Loom below. For reference, the class hierarchy for this class is Object <= loom.template::BaseClass <= loom.template::DynamicSubClass.
function script0$init():* /* disp_id 0*/
{
// local_count=1 max_scope=3 max_stack=2 code_len=25
0 getlocal0
1 pushscope
2 getscopeobject 0
4 findpropstrict Object
6 getproperty Object
8 pushscope
9 findpropstrict loom.template::BaseClass
11 getproperty loom.template::BaseClass
13 pushscope
14 findpropstrict BaseClass
16 getproperty BaseClass
18 newclass loom.template::DynamicSubClass
20 popscope
21 popscope
22 initproperty loom.template::DynamicSubClass
24 returnvoid
}
Again, this is just based upon what I know of the spec. I encourage you to look at what I have after I release the source to you guys and see if you can find a way to get this done.
Thanks,
- max