[Soot-list] Pretty print

Eric Bodden eric.bodden at mail.mcgill.ca
Wed Jun 17 22:04:48 EDT 2009


That should be quite straightforward. Simply add the following line to
your extension's ExtensionInfo class (within the "passes" method):

l.add(new PrettyPrintPass(INSPECT_AST,job,new
CodeWriter(System.out,70),new PrettyPrinter()));

You can see abc.aspectj.ExtensionInfo for an example.

Eric


2009/6/17 Cristiane Queiroz <criscq at gmail.com>:
> Yes, I want to print Java/AspectJ before the weaving.
> What's the easiest way for me to do that?
>
>
> 2009/6/15 Eric Bodden <eric.bodden at mail.mcgill.ca>
>>
>> Hi Christiane.
>>
>> Depending on what you are trying to do, this may be hard to
>> impossible. abc works by (1) transforming Java classes into Jimple and
>> AspectJ aspects into something called an AspectInfo. Then, abc (2)
>> weaves the Jimple code according to the AspectInfo and (3) produces
>> bytecode from the woven Jimple.
>>
>> Therefore you can only print out Java or AspectJ code before step (2),
>> i.e. before the weaving because no Java/AspectJ representation of the
>> woven program exists. If you want to print the un-woven Java/AspecTJ
>> code, I can tell you how to do that, but I fear that you are trying to
>> accomplish something else.
>>
>> If you want to convert the woven Jimple code back to Java you can try
>> to do so using the command line options "+soot -f dava -soot" to abc.
>> This is known to be buggy, though, and it will only produce plain Java
>> code. In other words, the generated code contains no pieces of advice
>> or pointcuts etc. but only appropriate advice methods.
>>
>> Eric
>>
>> 2009/6/15 Cristiane Queiroz <criscq at gmail.com>:
>> > Hi,
>> >
>> > I'm developing a tool to extract Java exception handling to AspectJ
>> > aspects,
>> > and I decided to implement this tool as an abc extension. I have studied
>> > a
>> > little bit about the inner workings of abc and its main components (Soot
>> > and
>> > Polyglot), and noticed that it is easy to change the internal structure
>> > of a
>> > class through Jimple. However, my tool needs to output Java and AspectJ
>> > code
>> > and I couldn't find any example of how to do that. All the examples
>> > focus on
>> > producing Java bytecode.
>> >
>> >  I would like to know if there is any way to pretty print the Jimple
>> > code in
>> > Java and/or AspectJ. Thanks in advance.
>> >
>> >
>> >
>> > Kind regards,
>> >
>> > Cristiane
>> >
>> > _______________________________________________
>> > Soot-list mailing list
>> > Soot-list at sable.mcgill.ca
>> > http://mailman.cs.mcgill.ca/mailman/listinfo/soot-list
>> >
>> >
>>
>>
>>
>> --
>> Eric Bodden
>> Sable Research Group, McGill University
>> Montréal, Québec, Canada
>
>



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


More information about the Soot-list mailing list