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

Will Benton willb at cs.wisc.edu
Tue Apr 29 22:09:35 EDT 2008


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/

-------------- next part --------------
A non-text attachment was scrubbed...
Name: Annotated.java
Type: application/octet-stream
Size: 456 bytes
Desc: not available
Url : http://mailman.CS.McGill.CA/pipermail/soot-list/attachments/20080429/b301cb34/Annotated.obj


More information about the Soot-list mailing list