[Soot-list] How to read Java 5 annotations?

Bernhard Berger berber at tzi.de
Wed Jun 13 01:32:06 EDT 2012


Hi Marc-André,

all the annotations can be found within Soot. In my opinion, there is an
imperfection regarding class-tags used within annotations but all static
information can be found after loading the classes from bytecode (never
tried to load from Jimple).

The problem I've had in a project with the mentioned class tags
(@Foo(param = Type.class)) is the following: The parameter is converted
to a soot.tagkit.AnnotationClassElem instance and the type is stored as
a string value (of the form "L<fq-name>;"). AFAIR this can lead to the
situation that the type isn't loaded and therefore you cannot get its
type information. No idea if this is intended or an accident and should
be patched. Beyond that, to find the type one has to strip the L and
the ;, replace "/" by "." and  then use the resolver to find the type.
Perhaps this should be done by soot.

Bernhard

On Mi, 2012-06-13 at 07:43 +0800, Eric Bodden wrote:
> Hi again.
> 
> I am not sure what the doc says but annotations do not get lost in the
> conversion to Jimple. They are manifested as AnnotationTag objects on
> SootClass, SootMethod or SootField objects:
> http://www.sable.mcgill.ca/soot/doc/soot/tagkit/AnnotationTag.html
> 
> Cheers,
> Eric
> 
> On 13 June 2012 04:39, Marc-Andre Laverdiere-Papineau
> <marc-andre.laverdiere-papineau at polymtl.ca> wrote:
> > Hello,
> >
> > I am reading this tutorial:
> > http://www.sable.mcgill.ca/soot/tutorial/addattributes/index.html
> >
> > It says near the end that Java attributes get 'lost' along the way. Is
> > there a way to read them anyway in soot?
> >
> > If I were to parse a java file to jimple, would the Java 5 annotations
> > be kept in the Jimple format?
> >
> > Which subclass of Tag would be used to record those? Is there any
> > particular encoding I need to worry about?
> >
> > Regards,
> >
> > --
> > Marc-André Laverdière-Papineau
> > Étudiant au doctorat - PhD Student
> >
> > _______________________________________________
> > Soot-list mailing list
> > Soot-list at sable.mcgill.ca
> > http://mailman.cs.mcgill.ca/mailman/listinfo/soot-list
> 
> 
> 

-- 
Dipl. Inf. Bernhard Berger

TZI – Universität Bremen, AG Softwaretechnik
E-Mail  berber at tzi.de
Telefon +49 421 218-64472



More information about the Soot-list mailing list