2016/08/14

00:12

Also, class rewriting could be used for optimization. Say for example there is an ArrayList but for one target, that uses a bunch of memory. Instead it can be rewritten to be another class for example. This could be done for anything for the most part.

00:20

One thing to consider for class rewrites is Class.forName() and the Class.name() with toString(). Since technically code could detect or rely on the name of a given class, but that would be a bit ugly anyway. That might not be too much of an issue at all.

09:12

So do I write the constant pool first, or wait until later?

15:24

Write it first, but before that determine strings that are used in all constants so that they are recorded first in a kind of string table.

20:33

I will need an efficient way to write the constant pool without wasting much space. There will need to be 9 bytes at the minimum for each entry due to long or double, however since those take up two spots that could be handled in special cases. So this leaves 3 2-byte fields (for references). 3*2 == 6. Since 6 is rather off and a tag is needed also, make it 4 2-byte fields. However in reality due to the way references refer to name and types, I only need two 2 byte entries, which is enough for int and float. So I suppose keep it at 6 bytes then. Long and double will just consume more space and have an illegal tag identifier.