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

Format checker rejects synthetic interface fields/methods in v49

XMLWordPrintable

    • b39
    • generic, x86
    • generic, windows_xp
    • Verified

      Name: vrR10176 Date: 02/06/2004



      The section "4.6 Fields" of latest draft of new JVM specification says:
      "All fields of interfaces must have their ACC_PUBLIC, ACC_STATIC, and ACC_FINAL flags set;
      they may have their ACC_SYNTHETIC flag set and must not have any of the other flags in Table
      4.4 set (?2.13.3.1)."

      ACC_PUBLIC 0x0001
      ACC_STATIC 0x0008
      ACC_FINAL 0x0010
      ACC_SYNTHETIC 0x1000

      However, class format checker (jdk1.5.0-b37, jdk1.5.0-b32d) rejects valid interfaces
      which contain fields with all specified flags set.

      To reproduce the issue execute following test (for class files see attachments):
      ----------- test.java ------------
      class test {
      public class test {
          public static void main(String args[]) {
              try {
                  Class.forName("test_i");
              } catch (Throwable e) {
                  System.out.println("Failed with loading exception: " + e);
              }
          }

      }
      ----------- test_i.jcod-----------
      class test_i {
        0xCAFEBABE;
        0; // minor version
        49; // version
        [] { // Constant Pool
          ; // first element is empty
          class #7; // #1
          class #8; // #2
          Utf8 "i"; // #3
          Utf8 "I"; // #4
          Utf8 "ConstantValue"; // #5
          int 0x00000001; // #6
          Utf8 "test_i"; // #7
          Utf8 "java/lang/Object"; // #8
        } // Constant Pool

        0x0600; // access
        #1;// this_cpx
        #2;// super_cpx

        [] { // Interfaces
        } // Interfaces

        [] { // fields
          { // Member
            0x1019; // access flags: public static final synthetic

            #3; // name_cpx
            #4; // sig_cpx
            [] { // Attributes
              Attr(#5) { // ConstantValue
                #6;
              } // end ConstantValue
            } // Attributes
          } // Member
        } // fields

        [] { // methods
        } // methods

        [] {
        } // Attributes
      } // end class Test
      ----------------------------------
      ---------- Execution -------------
      % javac -d . test_i.jcod
      % jcod test_i.jcod

      % java -version
      java version "1.5.0-beta"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-beta-b32d)
      Java HotSpot(TM) Client VM (build 1.5.0-beta-b32d, mixed mode)

      $ java -version
      java version "1.5.0-beta2"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-beta2-b37)
      Java HotSpot(TM) Client VM (build 1.5.0-beta2-b37, mixed mode)

      % java -Xfuture test
      Failed with loading exception: java.lang.ClassFormatError: Illegal field modifiers: 0x1019

      ---------------------------------

      JCK1.5-beta1 test vm/classfmt/fld/fldacc001/fldacc00110m1/fldacc00110m1.html
      failed due to this bug.

      ======================================================================

            wtaosunw Wei Tao (Inactive)
            rslasunw Rsla Rsla (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: