[Soot-list] Question about inner class and failure to verify using ASM3.3.1
Henddher Pedroza
hpedro2 at uic.edu
Fri Oct 26 12:20:05 EDT 2012
What about this 'default' initialization as empty string ?
(if 'info' is null, EnclosingMethodTag(class_name, "", "") will be
created and added ... is that correct?)
Please help!
// soot.coffi.Util @398
else if (coffiClass.attributes[i] instanceof
EnclosingMethod_attribute){
EnclosingMethod_attribute attr =
(EnclosingMethod_attribute)coffiClass.attributes[i];
String class_name =
((CONSTANT_Utf8_info)coffiClass.constant_pool[((CONSTANT_Class_info)coffiClass.constant_pool[
attr.class_index ]).name_index]).convert();
CONSTANT_NameAndType_info info =
(CONSTANT_NameAndType_info)coffiClass.constant_pool[attr.method_index];
* String method_name = "";**
** String method_sig = "";**
***
if (info != null){
method_name =
((CONSTANT_Utf8_info)coffiClass.constant_pool[info.name_index]).convert();
method_sig =
((CONSTANT_Utf8_info)coffiClass.constant_pool[info.descriptor_index]).convert();
}
* bclass.addTag(new EnclosingMethodTag(class_name,
method_name, method_sig));**
* }
On 10/26/2012 11:05 AM, Henddher Pedroza wrote:
> More info:
>
> Issue$1 generated by soot:
>
> $ javap -c -v -s -sysinfo -constants Issue\$1.class
> Classfile ./innerclass_issue/output/Issue$1.class
> Last modified Oct 25, 2012; size 352 bytes
> MD5 checksum bdbeedc92127b3b4da92668ad64991e4
> Compiled from "Issue.java"
> class Issue$1 implements java.io.Serializable
> SourceFile: "Issue.java"
> * EnclosingMethod: #22.#3 // Issue.**
> * InnerClasses:
> #20; //class Issue$1
> minor version: 0
> major version: 46
> flags: ACC_SUPER
> Constant pool:
> #1 = Utf8 java/lang/Object
> #2 = Utf8 EnclosingMethod
> #3 = NameAndType #25:#25 // "":
> #4 = Utf8 <init>
> #5 = Utf8 (LIssue;)V
> #6 = NameAndType #4:#8 // "<init>":()V
> #7 = Class #1 // java/lang/Object
> #8 = Utf8 ()V
> #9 = Utf8 Code
> #10 = Utf8 InnerClasses
> #11 = Utf8 LIssue;
> #12 = Utf8 Issue.java
> #13 = NameAndType #23:#11 // this$0:LIssue;
> #14 = Utf8 SourceFile
> #15 = Utf8 Issue
> #16 = Methodref #7.#6 // java/lang/Object."<init>":()V
> #17 = Utf8 java/io/Serializable
> #18 = Fieldref #20.#13 // Issue$1.this$0:LIssue;
> #19 = Class #17 // java/io/Serializable
> #20 = Class #21 // Issue$1
> #21 = Utf8 Issue$1
> #22 = Class #15 // Issue
> #23 = Utf8 this$0
> #24 = Utf8 dummy
> #25 = Utf8
> {
> final Issue this$0;
> Signature: LIssue;
> flags: ACC_FINAL
>
>
> Issue$1(Issue);
> Signature: (LIssue;)V
> flags:
> Code:
> stack=2, locals=2, args_size=2
> 0: aload_0
> 1: aload_1
> 2: putfield #18 // Field this$0:LIssue;
> 5: aload_0
> 6: invokespecial #16 // Method
> java/lang/Object."<init>":()V
> 9: return
>
> public void dummy();
> Signature: ()V
> flags: ACC_PUBLIC
> Code:
> stack=0, locals=1, args_size=1
> 0: return
> }
>
> Issue$1 generated by compiler:
>
> Classfile ./innerclass_issue/Issue$1.class
> Last modified Oct 25, 2012; size 389 bytes
> MD5 checksum 2f3a83859d87f9451fc95cbd6a8744c8
> Compiled from "Issue.java"
> class Issue$1 implements java.io.Serializable
> SourceFile: "Issue.java"
> *EnclosingMethod: #17.#0 // Issue**
> *** InnerClasses:
> #3; //class Issue$1
> minor version: 0
> major version: 51
> flags: ACC_SUPER
> Constant pool:
> #1 = Fieldref #3.#18 // Issue$1.this$0:LIssue;
> #2 = Methodref #4.#19 // java/lang/Object."<init>":()V
> #3 = Class #20 // Issue$1
> #4 = Class #23 // java/lang/Object
> #5 = Class #24 // java/io/Serializable
> #6 = Utf8 this$0
> #7 = Utf8 LIssue;
> #8 = Utf8 <init>
> #9 = Utf8 (LIssue;)V
> #10 = Utf8 Code
> #11 = Utf8 LineNumberTable
> #12 = Utf8 dummy
> #13 = Utf8 ()V
> #14 = Utf8 SourceFile
> #15 = Utf8 Issue.java
> #16 = Utf8 EnclosingMethod
> #17 = Class #25 // Issue
> #18 = NameAndType #6:#7 // this$0:LIssue;
> #19 = NameAndType #8:#13 // "<init>":()V
> #20 = Utf8 Issue$1
> #21 = Utf8
> #22 = Utf8 InnerClasses
> #23 = Utf8 java/lang/Object
> #24 = Utf8 java/io/Serializable
> #25 = Utf8 Issue
> {
> final Issue this$0;
> Signature: LIssue;
> flags: ACC_FINAL, ACC_SYNTHETIC
>
>
> Issue$1(Issue);
> Signature: (LIssue;)V
> flags:
> Code:
> stack=2, locals=2, args_size=2
> 0: aload_0
> 1: aload_1
> 2: putfield #1 // Field this$0:LIssue;
> 5: aload_0
> 6: invokespecial #2 // Method
> java/lang/Object."<init>":()V
> 9: return
> LineNumberTable:
> line 3: 0
>
> public void dummy();
> Signature: ()V
> flags: ACC_PUBLIC
> Code:
> stack=0, locals=1, args_size=1
> 0: return
> LineNumberTable:
> line 5: 0
> }
>
> So in Issue$1 from compiler, EnclosingMethod refers to entry #0 but in
> the one from Soot, it refers to #3 (NameAndType).
> Isn't this the issue?
> would this be something different between class version 46 and 51?
>
> - Henddher
>
> On 10/26/2012 09:38 AM, Henddher Pedroza wrote:
>> Hello all again,
>>
>> Posting again with original attachment replaced.
>>
>> Here is more info about the issue:
>>
>> Stepping through the verifier code in ASM 3.3.1 makes me believe that
>> the issue is in the .class file generated by Soot 2.5.0. Soot
>> generates 46 and compiler 1.7 generates 51.
>>
>> When Issue$1 is being verified by ASM, the enclosing name and
>> enclosing desc of the inner class is read in preparation for visiting
>> the outer class. However, ASM 3.3.1 expects enclosing desc to be null
>> because the inner class is not defined within a method. When ASM
>> checks if enclosing desc is null, it finds that it is empty-string
>> instead which is unexpected.
>>
>> The fundamental question is this:
>>
>> When an inner class is defined within the body of another class, the
>> field is tagged as synthetic and the class attribute of the inner
>> class is tagged as "EnclosingMethod" but also the enclosing name and
>> enclosing desc are empty strings both. Is this correct?
>> Where in the specification are these points explained?
>>
>> (the 4 classes are attached: both pairs, Issue.class and
>> Issue$1.class pair, from compiler and from Soot 2.5.0. The source
>> code Issue.java and a README)
>>
>> Thanks in advance. Any help is very appreciated.
>>
>> -Henddher
>>
>> On 10/25/2012 06:21 PM, Henddher Pedroza wrote:
>>>
>>> Hello,
>>>
>>> I am using Soot 2.5.0 and ASM3.3.1 BasicVerifier and Analyzer and came
>>> across an issue:
>>>
>>> BasicVerifier+Analyzer throws IAE "invalid method descr(null or empty)"
>>> when I try to verify a .jar file.
>>>
>>> The source .java is as follows:
>>>
>>> //Issue.java:
>>> import java.io.Serializable;
>>> public class Issue {
>>> Serializable serializable = new Serializable() {
>>> public void dummy() {
>>> }
>>> };
>>> }
>>>
>>> I compile the class with javac 1.7.0_05.
>>> $ javac -d . Issue.java
>>>
>>> Then, I ran the classes through Soot 2.5.0:
>>> $ java soot.Main -app -d output.jar -outjar Issue
>>>
>>> Soot started on Thu Oct 25 17:05:28 CDT 2012
>>> Transforming Issue...
>>> Transforming Issue$1...
>>> Writing to Issue.class
>>> Writing to Issue$1.class
>>> Soot finished on Thu Oct 25 17:05:29 CDT 2012
>>> Soot has run for 0 min. 1 sec.
>>>
>>> Finally, I run the .jar through ASM 3.3.1 Analyzer+BasicVerifier, the
>>> exception happens when checking Issue$1.class, after checking
>>> Issue.class:
>>> $ java -jar asm311verifier.jar output.jar -pd
>>>
>>> java.lang.IllegalArgumentException: Invalid method descriptor (must not
>>> be null or empty)
>>> at
>>> org.objectweb.asm.util.CheckMethodAdapter.checkMethodDesc(CheckMethodAdapter.java:1104)
>>>
>>> at
>>> org.objectweb.asm.util.CheckClassAdapter.visitOuterClass(CheckClassAdapter.java:405)
>>>
>>> at org.objectweb.asm.ClassReader.accept(ClassReader.java:572)
>>> at org.objectweb.asm.ClassReader.accept(ClassReader.java:425)
>>>
>>> I have attached the source, original .class and transformed classes
>>> should anyone wanted to experiment.
>>>
>>> Any advice?
>>>
>>> Thanks in advance.
>>>
>>> - Henddher
>>>
>>>
>>>
>>>
>>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.cs.mcgill.ca/pipermail/soot-list/attachments/20121026/82cd1894/attachment-0001.html
More information about the Soot-list
mailing list