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

VM format checking requires Code attribute from abstract/native non-initializer <clinit>

      According to https://bugs.openjdk.java.net/browse/JDK-8130682 and http://docs.oracle.com/javase/specs/jvms/se8/html/jvms-2.html#jvms-2.9-200, <clinit> with signatures (I)I, ()I, (I)V are not initialiizers and should be checked for format like any other regular method. According to http://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.7.3-110 ACC_ABSTRACT and ACC_NATIVE methods shouldn't have Code attribute.
      Actually for <clinit> methods with signatures like ()I, (I)V, (I)I + ACC_ABSTRACT/ACC_NATIVE flags are set, VM requires Code attribute. It ACC_ABSTRACT/ACC_NATIVE happens in methods for class versions 45.3 - 50.0 and ACC_ABSTRACT/ACC_NATIVE + ACC_STATIC for class versions 51.0 - 52.0.
      CFE: Absent Code attribute in method that is not native or abstract .
      Moreother, VM accepts <clinit> ()I, (I)V, (I)I + ACC_ABSTRACT/ACC_NATIVE flags are set + Code attribute without CFE. Expected behaviour: reject ACC_ABSTRACT + ACC_STATIC methods due to http://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.6-200-A.4; reject ACC_NATIVE and 'ACC_ABSTRACT without ACC_STATIC' with Code attribute.

      Note that ACC_STATIC + ACC_ABSTRACT <clinit> ()I, (I)V, (I)I should fail with CFE in both cases (with Code and without Code).

      Was found on jdk9b78, jdk9b81. Tests development are in progress, tck_red will be added after tests completion.
      Examples are attached

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

              Created:
              Updated:
              Resolved: