[Soot-list] EnclosingMethod attribute

Devin Mahoney devin.mahoney at kyrus-tech.com
Fri Sep 21 08:30:17 EDT 2012


I believe I have found an edge condition error in how Soot uses Jasmin
to output assembled class files. The custom version of Jasmin
distributed with Soot doesn't ever allow the EnclosingMethod attribute
of an inner class to be zero.

According to the Java class file spec [1], the EnclosingMethod
attribute specifies "If the current class is not immediately enclosed
by a method or constructor, then the value of the method_index item
must be zero."

While Soot correctly passes EnclosingMethod tags with an empty method
(e.g. ".enclosing_method_attr " "myClass" "" ""\n" ), the custom
Jasmin creates an empty string in the class' constant pool and makes a
reference to that. [2]

This bug was fixed at least as early as Jasmin version 2.0 [3].

I have put in a proposed fix for this bug as a github pull request for
the Sable/Jasmin project. This fix allows class files created by Soot
to be processed by Android's dex library, which will otherwise reject
anonymous inner classes that don't set the EnclosingMethod
method_index to 0.

Devin

[1] http://docs.oracle.com/javase/specs/jvms/se7/html/jvms-4.html#jvms-4.7.7
[2] https://github.com/Sable/jasmin/blob/master/lib/jas/src/jas/EnclMethAttr.java
[3] http://sourceforge.net/projects/jasmin/files/jasmin/2.0/

-- 
Devin Mahoney


More information about the Soot-list mailing list