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

compute_offset() is confusing for static fields

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Fixed
    • Icon: P4 P4
    • 11
    • 9
    • hotspot
    • None
    • b01
    • generic
    • generic

      The function compute_offset() [in vm/classfile/javaClasses.cpp] can be used to
      obtain the offset for both ordinary fields and static fields. The caller must
      know which kind of field is being looked for, and must treat the result
      differently according to that knowledge. And there's no way to verify that
      the field found by compute_offset() was actually of the expected kind.

      When a static field is looked for, the resulting offset is from the base of
      the class mirror object, which makes it unsuitable for use with the
      static_field_addr() function that one would expect to be used to convert a
      static field offset to the address of the value; the computed offset instead
      needs to be decremented by the mirror's offset_of_static_fields() value.

      This is a potential source of hard to debug errors.

      It would be better if there were separate functions for getting the offset of
      ordinary fields and static fields (though they might share a common
      implementation).

            coleenp Coleen Phillimore
            kbarrett Kim Barrett
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: