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

SA-JDI: allFields() returns inherited fields with wrong declaringType

    XMLWordPrintable

Details

    • beta2
    • generic
    • generic
    • Verified

    Description



      Name: ipR10196 Date: 02/05/2004


      --------------------------------------
      Test : nsk/sajdi/ReferenceType/allFields/allfields001
      VM : ClientVM, ServerVM
      Mode : all
      Platform : generic
      OS : SunOS 5.8
      JDK : 1.5.0 b32-b36
      ----------------------------------------

      This test checks that method ReferenceType.allFields() returns list
      of all declared and inherited fields, including invisible fields
      (hidden or ambigous).
      For each returned field method TypeComponent.declaringType() should
      return ReferenceType of a class or interface in which this field
      was declared.

      The test demonstrates that for inherited fields declaringType()
      always returns reference to the most derived class, regardless of
      the real declaring class of the field.

      This bug is reproduced with any of SA-JDI connectors, but is NOT
      reproduced with legacy JDI connectors.

      In contrast, similar method ReferenceType.visibleFields() returns
      inherited fields with correct declaringType attributes either
      for SA-JDI and legacy JDI connectors.

      This test checks a lot of fields of different classes and thus
      produces too many errors. I simplified this test by removing
      unnecessary fields and checks. The simplified version of the test
      declares one field for tested class, its interface and superclass:

          interface Interface3 {
              Object fieldVisibleInterface3PublicStaticObject;
          }

          class SuperClass {
              int fieldVisibleSuperClassPublicInt;
          }

          class TestedClass extends SuperClass implements Interface3 {
              long fieldVisibleTestedClassPublicLong;
          }

      Field declared directly in TestedClass is reported correctly:

          field #0
            field name: fieldVisibleTestedClassPublicLong
            type name: long
            signature: J
            decl type: class nsk.sajdi.ReferenceType.allFields.allfields001aTestedClass
                          (loaded by instance of sun.misc.Launcher$AppClassLoader(id=0))
            type name: nsk.sajdi.ReferenceType.allFields.allfields001aTestedClass
            toString:
      nsk.sajdi.ReferenceType.allFields.allfields001aTestedClass.fieldVisibleTestedClassPublicLong
            fieldByName:
      nsk.sajdi.ReferenceType.allFields.allfields001aTestedClass.fieldVisibleTestedClassPublicLong
                 equals: true
            ... found in expected list: #2

      Fields inherited from Interface3 and SuperClass are wrongly reported
      as declared in TestedClass, so test cannot recognize them as expected.
      However, fieldByName() returns correct field related to Interface3
      or SuperClass respectively, and it is not equal to original field:

          field #1
            field name: fieldVisibleInterface3PublicStaticObject
            type name: java.lang.Object
            signature: Ljava/lang/Object;
            decl type: class nsk.sajdi.ReferenceType.allFields.allfields001aTestedClass
                          (loaded by instance of sun.misc.Launcher$AppClassLoader(id=0))
            type name: nsk.sajdi.ReferenceType.allFields.allfields001aTestedClass
            toString:
      nsk.sajdi.ReferenceType.allFields.allfields001aTestedClass.fieldVisibleInterface3PublicStaticObject
            fieldByName:
      nsk.sajdi.ReferenceType.allFields.allfields001aInterface3.fieldVisibleInterface3PublicStaticObject
                 equals: false
        # ERROR: ReferenceType.allFields() returned unexpected field:
        # ERROR: field nom: 1
        # ERROR: field name: fieldVisibleInterface3PublicStaticObject
        # ERROR: decl type: nsk.sajdi.ReferenceType.allFields.allfields001aTestedClass
        # ERROR: isSynthetic: false

          field #2
            field name: fieldVisibleSuperClassPublicInt
            type name: int
            signature: I
            decl type: class nsk.sajdi.ReferenceType.allFields.allfields001aTestedClass
                          (loaded by instance of sun.misc.Launcher$AppClassLoader(id=0))
            type name: nsk.sajdi.ReferenceType.allFields.allfields001aTestedClass
            toString:
      nsk.sajdi.ReferenceType.allFields.allfields001aTestedClass.fieldVisibleSuperClassPublicInt
            fieldByName:
      nsk.sajdi.ReferenceType.allFields.allfields001aSuperClass.fieldVisibleSuperClassPublicInt
                 equals: false
        # ERROR: ReferenceType.allFields() returned unexpected field:
        # ERROR: field nom: 2
        # ERROR: field name: fieldVisibleSuperClassPublicInt
        # ERROR: decl type: nsk.sajdi.ReferenceType.allFields.allfields001aTestedClass
        # ERROR: isSynthetic: false

      Finally, the test reports that inherited fields declared in
      Interface3 and SuperClass were not found in the returned fields list:

        Check if all expected fields found
        # ERROR: ReferenceType.allFields() returned no expected field:
        # ERROR: field name: fieldVisibleInterface3PublicStaticObject
        # ERROR: declared in: Interface3
        # ERROR: found count: 0
        # ERROR: ReferenceType.allFields() returned no expected field:
        # ERROR: field name: fieldVisibleSuperClassPublicInt
        # ERROR: declared in: SuperClass
        # ERROR: found count: 0

      To reproduce this failure with simplified testcase:
        cd /net/jano.sfbay/export/disk20/GammaBase/Bugs/<this bug number>
        sh build.sh $JAVA_HOME
        sh run.sh [-pid | -core | -socket] [-g] [-v] $JAVA_HOME [JAVA_OPTS]
      where:
          -pid - run test with SA-JDI pid attaching connector (default)
          -core - run test with SA-JDI core attaching connector
          -socket - run test with JDI socket attaching connector
          -g - run test with java_g binaries
          -v - run test in verbose mode

      The original testcase will be available in the next r27 testbase release.

      Running with SA-JDI connectors on Linux platform this test is crashed
      because of known bug:
      4975660 SA-JDI: SAPIDAttachingConnector.attach() causes debugger VM crash on Linux

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

      Attachments

        Activity

          People

            sundar Sundararajan Athijegannathan
            popovsunw Popov Popov (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: