[Soot-list] A question about using a subset of optimizaitons directly on bytecode

Eric Bodden eric.bodden at mail.mcgill.ca
Sat Aug 2 19:06:41 EDT 2008


> But I would only want (in the ideal case) to give it the bytecode for
> a single method, not the whole class. Does this sound plausible?
>
> I am using ASM to get the class bytecode and reconstruct the class at
> the end, so things like local stack size should be recalculated
> accordingly.
>
> Or, does Coffi/Jasmin need to see the whole class (It's not clear if a
> JimpleBody relates to a whole class or a single method) ?

I don't think that this is possible. I see two problems with this: (1)
Soot needs to resolve the type hierarchy of all classes that are
referenced in your method in order to perform the typing of local
variables etc. (2) Important information about constants referenced in
your method is contained in the constant pool of the class, which is
not part of the "code" byte array of your method. Hence it would be
missing if you only passed the latter to Soot.

>> Both Coffi and Jasmin operate on streams (Coffi on an InputStream and
>> Jasmin on an OutputStream). Therefore it should be easy to just use
>> ByteArrayInput/OutputStreams instead to get what you want.
>
> Sounds ideal!

Yes but for this to work you would have it to provide it at least the
byte array for the definition of a complete class, and probably also
at least some information about the hierarchy of all referenced
classes.

Eric

-- 
Eric Bodden
Sable Research Group
McGill University, Montréal, Canada


More information about the Soot-list mailing list