[Soot-list] Soot and Java Annotations

Florian Strauß f_straus at cs.uni-kl.de
Wed Feb 1 09:03:05 EST 2012


Hello Eric,

I found the tag name, it's "VisibilityAnnotationTag". Thank you very much :)

You are right. I do not know why, but there are no annotations at local
variables in the Java bytecode. But I have the Java sourcecode. Is it
possible to write an additional (user-defined) soot phase, which retains the
information about these annotations? I guess, the new step must be in the
very beginning, before the source code is transformed in one of the
intermediate languages.
It is hard to add user-defined attributes (about Java annotations) to
locals, because the type "Local" does not implement the interface "Host",
isn't it? But maybe we can introduce a new tag and add these information to
the method, where the local variable is declared. 
Example:
sootMethod.getTag("NewTag").localVarHasAnnotations(localVar);
and / or
sootMethod.getTag("NewTag").getAnnotation(localVar);

What do you think? Is it possible to make these changes without destroying
everything and in an acceptable time? What would be a good starting point?

Best regards,
Florian




-----Ursprüngliche Nachricht-----
Von: eric.bodden at gmail.com [mailto:eric.bodden at gmail.com] Im Auftrag von
Eric Bodden
Gesendet: Mittwoch, 1. Februar 2012 10:38
An: Florian Strauß
Cc: soot-list at sable.mcgill.ca
Betreff: Re: [Soot-list] Soot and Java Annotations

Hello Florian.

Yes, indeed you can retrieve annotations through tags.

You cannot directly use test1Go.getJavaAnnotation(“MyAnnotation”) but
instead you need to use test1Go.getTag(ID) with a special ID that I
have forgotten. But you can instead just use getTags() to retrieve all
tags to find out...

Soot does not currently support annotations on local variables because
such annotations cannot be persisted in Java bytecode; they are
source-code only.

Eric

On 31 January 2012 17:52, Florian Strauß <f_straus at cs.uni-kl.de> wrote:
> Hi all,
>
>
>
> thanks for working on soot. It’s a very helpful framework.
>
> I am wondering if it is possible to get the Java Annotations, which are
used
> in the analyzed (source) code.
>
>
>
> For example
>
> Input:
>
> public class Test1 {
>
>
>
>       @MyAnnotation
>
>       public void go() {
>
>
>
>             @TestAnnotation
>
>             Container c1 = new Container();
>
> [..]
>
>       }
>
> }
>
>
>
>
>
> Output:
>
> SootMethod test1Go = 
.
>
> test1Go.getJavaAnnotation(“MyAnnotation”) ?
>
> Local c1 = 

>
> c1.getJavaAnnotation(“TestAnnotation”) ?
>
>
>
> I know soot provides a type “Tag” and each subtype of “Host” has a method
> “getTag”. Is it possible to use this method to get information about the
> Java Annotations? Unfortunately Local (or JimpleLocal) does not implement
> “Host”. Any ideas?
>
>
>
> Best regards,
>
> Florian
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> _______________________________________________
> Soot-list mailing list
> Soot-list at sable.mcgill.ca
> http://mailman.cs.mcgill.ca/mailman/listinfo/soot-list
>



-- 
Eric Bodden, Ph.D., http://bodden.de/
Head of Secure Software Engineering Group at EC SPRIDE
Principal Investigator in Secure Services at CASED
Tel: +49 6151 16-75422    Fax: +49 6151 16-72051
Room 3.2.14, Mornewegstr. 30, 64293 Darmstadt




More information about the Soot-list mailing list