[Soot-list] annotation bug? (was: Java 1.5 annotations)

Eric Bodden eric.bodden at mail.mcgill.ca
Tue Apr 29 22:23:46 EDT 2008


Hi Will.

Torbjorn is busy working on annotation support. Please grant him a few
more days to sort out the last quirks. If you check out today's SVN
version of Soot you should find full support for annotations with
retention type CLASS or RUNTIME, if read from source code. The only
two things that are not (yet) supported are package annotations and
annotations to local variables.

The latter are very tricky because there is no guaranteed 1 to 1
mapping between local variables on the source and on the Jimple level.
Therefore we will probably decide not to retain local variable
annotations until somebody specifically asks for this feature.

So I encourage you (and others) to try out what is currently there and
give us feedback if you find anything missing or anything is not
working for you.

Eric

P.S. Also since today the Soot Java 1.5 frontend seems to be complete
in the sense that we now can compile Soot with itself, which seems
like a good sign. Again, thanks to Torbjorn!

2008/4/29 Will Benton <willb at cs.wisc.edu>:
> On Apr 24, 2008, at 11:23 AM, Will Benton wrote:
>
> > Is there an interface for inspecting and modifying Java 1.5-style
> annotations on class members in Soot?  I saw this thread[1] from earlier,
> but it doesn't seem to have been resolved on-list.  (If not, I'd appreciate
> any advice on how best to proceed.)
> >
>
>
>  Replying to my own message here:
>
>  It looks like Soot represents Java 1.5-style annotations in AnnotationTag
> objects stored within VisibilityAnnotationTag objects; a String
> representation of the type name of the annotation interface is available via
> AnnotationTag.getType().  As far as I can tell, you can add AnnotationTag
> objects to the VisibilityAnnotationTag object and these are reflected in the
> class file.  (I've written up some code to make this a little cleaner; I can
> share it if others are interested.)
>
>  However, it looks like there is a bug in the way Soot handles annotations;
> Soot does not preserve all annotations on members that have both
> runtime-visible and runtime-invisible annotations.
>
>  Consider the attached Annotated class. If I compile this class with the
> Sun/Apple javac and run javap -verbose on it, it shows me that the foo()
> method has two annotations:  the runtime-visible @BlahBlah and the
> runtime-invisible @AnotherAnnotation.  If I run Annotated through soot.Main,
> the resulting class file omits the runtime-visible annotations on foo().
> (The annotations are all visible if I try and access them from, e.g., a
> SceneTransformer, so it looks like the problem comes up when writing out the
> class files; perhaps "extra" VisibilityAnnotationTags get truncated at some
> point?)
>
>  I suspect this is probably an easy fix, but it falls outside of the part of
> soot that I'm familiar with, so I'm mentioning it here before looking
> further.  I'd appreciate any pointers to parts of the code I should look at
> or to potential workarounds.
>
>
>  best,
>  wb
>
>  ---
>  Will Benton <willb at cs.wisc.edu>
>  http://pages.cs.wisc.edu/~willb/
>
>
> _______________________________________________
>  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, Canada


More information about the Soot-list mailing list