[Soot-list] Custom method annotations are lost in the SootMethod?

Eric Bodden eric.bodden at mail.mcgill.ca
Fri Dec 14 23:01:26 EST 2007


Mario, it's not enough to just define a class FooTag. You have to
instantiate those tags somewhere and add them to the statements in
question. Soot does that for the Deprecated tag (apparently). If you
want to have it for other tags, you have to do it yourself AFAIK.

Jennifer wrote a note once, about how Soot ought to address this:
http://www.sable.mcgill.ca/publications/technotes/#note4

However, I am not sure if that ever got implemented or how to use it.
Does anybody else know?

Eric

On 14/12/2007, Mario Mendez <mario at cs.unm.edu> wrote:
> Hi,
>
> If I add the following annotations to a method:
>
>      @Foo
>      @Deprecated
>      String send(String data) throws IOException {
>
> , and then I retrieve the Tags from the method:
>      List<Tag> tags = originalMethod.getTags();
>      for (Tag tag : tags) {
>        System.out.println(">>>> FOUND TAG!!!!!!!!" + tag.getName());
>      }
>
> The loop finds the (Java libraries) @Deprecated tag, but not the
> (defined by myself) @Foo tag. The @Foo Tag is defined identically to
> Deprecated. FooTag is identical to DeprecatedTag. The code of both is
> shown below.
> -What am I missing, that the Foo annotation is lost?
> -Independently of that, do I need to create a xTag class for every @x
> annotation? I did the usual homework: tutorial, Google ;-) but couldn't
> find anything about this.
>
> As always, thank you!!!!!
>
>
> ---
>
> @java.lang.annotation.Documented
> @java.lang.annotation.Retention(value =
> java.lang.annotation.RetentionPolicy.RUNTIME)
> public @interface Foo {
> }
>
> ---
>
> public class FooTag implements Tag {
>
>    public FooTag() {
>    }
>
>    public String toString() {
>      return "Foo";
>    }
>
>    /**
>     * Returns the tag name.
>     */
>    public String getName() {
>      return "FooTag";
>    }
>
>    public String getInfo() {
>      return "Foo";
>    }
>
>    /**
>     * Returns the tag raw data.
>     */
>    public byte[] getValue() {
>      throw new RuntimeException("DeprecatedTag has no value for bytecode");
>    }
> }
>
>
> _______________________________________________
> 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