Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8130183

InnerClasses: VM permits wrong inner_class_info_index value of zero

XMLWordPrintable

    • b75

        According to http://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.7.6-300-D.1-A:
        The value of the inner_class_info_index item must be a valid index into the constant_pool table. The constant_pool entry at that index must be a CONSTANT_Class_info structure representing C. The remaining items in the classes array entry give information about C.

        Note, that assertion have been changed since the JVMS2 publishing (JVMS2 permitted zero indices for this field): see http://docs.oracle.com/javase/specs/jvms/se6/html/ClassFile.doc.html#80019

        Now for both versions, 49 and 52 (was found using jdk9b70), wrong indices (e.g. 8000) are rejected, but zero indices are permitted. Examples (two classes which differs in first InnerClasses record) are attached.
        Tests are under development.

        I suppose, it would be better either throw CFE for zero index, or accept zero and invalid indices both.


        Please, check additional case: anonymous/local classes with zero inner_class_info_index. Anonymous/local classes with inner_class_info_index = 0 are rejected with CFE, but CFE contains inappropriate, but valid message "java.lang.ClassFormatError: Class is both outer and inner class in class file". Additional cases are attached.

              hseigel Harold Seigel (Inactive)
              asolodkaya Anastasiya Solodkaya (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Created:
                Updated:
                Resolved: