[Soot-list] Jasmin annotation bug(fix)
Christophe Foket
christophe.foket at elis.ugent.be
Wed Nov 30 14:36:12 EST 2011
Hello,
I am trying to run Soot on the tradebeans benchmark, which is part of
the latest dacapo release. For this, I am using the methodology
described here: http://www.bodden.de/2010/03/29/soot-tamiflex-dacapo/.
One of the dumped classes is "javax.persistence.OneToMany". This class
is read in correctly by soot, but written out incorrectly even if no
transformations are applied to it.
The problem with this class is that there are two extra bytes inserted
in the annotation of one of its methods. Below is the output of "javap
-verbose javax.persistence.OneToMany" for both the original class and
the (untransformed) class generated by soot.
Original:
=====
public abstract javax.persistence.CascadeType[] cascade();
Signature: ()[Ljavax/persistence/CascadeType;
AnnotationDefault: length = 0x3
5B 00 00
Sootified:
======
public abstract javax.persistence.CascadeType[] cascade();
Signature: ()[Ljavax/persistence/CascadeType;
AnnotationDefault: length = 0x5
00 17 5B 00 00
Note that the 5B 00 00, corresponds to an array (5B is '[') of size
zero, which is what we expect. The "00 17", on the other hand points to
an entry in the constant pool, representing the name of the array
annotation, which is "default". After some debugging, I found out that
the annotation is internally represented by an ArrayElemValPair.
ArrayElemValPair extends ElemValPair, which defines a method setNoName()
that, when called makes sure that the constant pool index of the
ElemValPair's name is not written out. The problem, however, is in
ArrayElemValPair, which overrides setNoName(), without performing a
super call:
public void setNoName(){
if (list == null) return;
Iterator it = list.iterator();
while (it.hasNext()){
((ElemValPair)it.next()).setNoName();
}
}
In this case, the setNoName() method is called on all elements of the
list, but not on the annotation itself. Therefore, whenever the
annotation is written out, it ithe constant pool index of its name is
also written out. Changing the implementation of setNoName() to
public void setNoName(){
*super.setNoName();*
if (list == null) return;
Iterator it = list.iterator();
while (it.hasNext()){
((ElemValPair)it.next()).setNoName();
}
}
causes Soot to generate the class file correctly.
I don't know enough about the internals of jasmin to decide whether or
not this fixes the issue entirely, but it at least seemed to solve my
problem.
Best,
Christophe
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.cs.mcgill.ca/pipermail/soot-list/attachments/20111130/13b55acb/attachment.html
More information about the Soot-list
mailing list