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

Mario Mendez mario at cs.unm.edu
Fri Dec 14 20:16:44 EST 2007


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");
   }
}




More information about the Soot-list mailing list