You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by "jianwang (JIRA)" <ji...@apache.org> on 2008/01/30 02:27:34 UTC

[jira] Commented: (HARMONY-4359) [buildtest][vts] VM does not reject class file with contains incorrect InnerClasses attribute with duplicate entries in classes array

    [ https://issues.apache.org/jira/browse/HARMONY-4359?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12563786#action_12563786 ] 

jianwang commented on HARMONY-4359:
-----------------------------------

I encounter a similar exception when using BEA JRE: java.lang.ClassFormatError: TestClass : duplicate InnerClass entry: 1
Could you please share your icA.java file? I could not understand icA.ccode well. I want to know what kind of class will cause this kind of error on BEA.

Thanks.

> [buildtest][vts] VM does not reject class file with contains incorrect InnerClasses attribute with duplicate entries in classes array
> -------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: HARMONY-4359
>                 URL: https://issues.apache.org/jira/browse/HARMONY-4359
>             Project: Harmony
>          Issue Type: Bug
>          Components: DRLVM
>            Reporter: Vera Petrashkova
>            Assignee: Gregory Shimansky
>            Priority: Minor
>         Attachments: H4359.patch, InnerClassAtr.zip
>
>
> According to the J2SE VM specifications of InnerClasses attribute:
> The InnerClasses attribute has the following format: 
>    InnerClasses_attribute {
>       u2 attribute_name_index;
>       u4 attribute_length;
>       u2 number_of_classes;
>       {  
>          u2 inner_class_info_index;	     
>          u2 outer_class_info_index;	     
>          u2 inner_name_index;	     
>          u2 inner_class_access_flags;	     
>       } classes[number_of_classes];
>     }
> and 
>     classes []
>           Every CONSTANT_Class_info entry in the constant pool table which represents a class or interface  
>           that is not a package member must have exactly one corresponding entry in the "classes" array. 
> But VM does not reject class  if its  InnerClasses attribute contains 2 entries in "classes" array
> and they correspond the same CONSTANT_Class_info element in constant pool table.
> To reproduce this issue run the following test:
> ---------icA.ccode-----------
> magic = xCAFEBABE
> minor_version = 3
> major_version = 45
> constant_pool_count = 19
> constant_pool {
>   /* #1 */ Method = #12 #7
>   /* #2 */ Class = #11
>   /* #3 */ UTF8 = "java/lang/Object"
>   /* #4 */ UTF8 = "SourceFile"
>   /* #5 */ UTF8 = "<init>"
>   /* #6 */ UTF8 = "icA.ccode"
>   /* #7 */ NameAndType = #5 #10
>   /* #8 */ UTF8 = "Code"
>   /* #9 */ UTF8 = "test"
>   /* #10 */ UTF8 = "()V"
>   /* #11 */ UTF8 = "icA"
>   /* #12 */ Class = #3
>   /* #13 */ UTF8 = "InnerClasses"
>   /* #14 */ Class = #16
>   /* #15 */ Class = #17
>   /* #16 */ UTF8 = "pack/inner$nestedClass"
>   /* #17 */ UTF8 = "inner"
>   /* #18 */ UTF8 = "nestedClass"
> }
> access_flags = PUBLIC SUPER  // x21
> this_class = #2
> super_class = #12  // "java/lang/Object"
> interfaces_count = 0
> fields_count = 0
> methods_count = 2
> methods {
>   method {
>     access_flag = PUBLIC  // x01
>     name_index = #5  // "<init>"
>     descriptor_index = #10  // "()V"
>     attributes_count = 1
>       attributes {
>         attribute Code {
>           attribute_name_index = #8  // "Code"
>           attribute_length = 17
>           max_stack = 1
>           max_locals = 1
>           code_length = 5
>           code asm {
>           0:    aload_0
>           1:    invokespecial #1
>           4:    return
>           }
>           exception_table_length = 0
>           attributes_count = 0
>         }
>       }
>   }
> // Test method
>   method {
>     access_flag = PUBLIC  // x01
>     name_index = #9  // "test"
>     descriptor_index = #10  // "()V"
>     attributes_count = 1
>       attributes {
>         attribute Code {
>           attribute_name_index = #8  // "Code"
>           attribute_length = 13
>           max_stack = 1
>           max_locals = 1
>           code_length = 1
>           code asm {
>           0:    return
>           }
>           exception_table_length = 0
>           attributes_count = 0
>         }
>       }
>   }
> }
> attributes_count = 1
> attributes {
>   attribute InnerClasses {
>     attribute_name_index = #13
>     attribute_length = 18 
>     number_of_classes = 2
>     InnerClass { // Tested classes array with two same entries for the class #14
>         inner_class_info_index = #14 // "pack/inner$nestedClass"
>         outer_class_info_index = #15 // "inner"
>         inner_name_index = #17  
>         inner_class_access_flags = Public 
>     }
>     InnerClass { // Tested classes array with two same entries for the class #14
>         inner_class_info_index = #14 // "pack/inner$nestedClass"
>         outer_class_info_index = #15 // "inner"
>         inner_name_index = #17  
>         inner_class_access_flags = Public 
>     }
>  }
> }
> -----------------------test.java------------------
> public class test {
>     public static void main(String[] args) {        
>         try {
>             Class.forName("icA");
>             System.out.println("Test failed. ClassFormatError was not thrown");
>         } catch (ClassFormatError e) {
>             System.out.println("Test passed: " + e);
>         } catch (Throwable e){
>             System.out.println("Test failed. Unexpected error was thrown");
>             e.printStackTrace();
>         }
>     }
> }
> ---------------------
> Use icA class file from attachment.
> Output is:
> Apache Harmony Launcher : (c) Copyright 1991, 2006 The Apache Software Foundation or its licensors, as applicable.
> java version "1.5.0"
> pre-alpha : not complete or compatible
> svn = r551077, (Jun 27 2007), Windows/ia32/msvc 1310, release build
> http://harmony.apache.org
> Test failed. ClassFormatError was not thrown
> This test also fails on RI but is passes on BEA JRockit 
> =============================
> Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_06-b05)
> Java HotSpot(TM) Client VM (build 1.5.0_06-b05, mixed mode)
> Test failed. ClassFormatError was not thrown
> Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-b64)
> BEA WebLogic JRockit(R) (build dra-38972-20041208-2001-win-ia32, R25.0.0-75, GC: System op
> timized over throughput (initial strategy singleparpar))
> Test passed: java.lang.ClassFormatError: icA : duplicate InnerClass entry: 1
> This bug causes the failure of VTS test
> vm/jvms/classFile/attributes/innerClasses/innerClasses12/innerClasses12.xml

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.