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

class _ValueObj should not be subclassed

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P4
    • Resolution: Not an Issue
    • Affects Version/s: 9, 10, 11
    • Fix Version/s: 12
    • Component/s: hotspot
    • Labels:
      None
    • Subcomponent:
    • CPU:
      generic
    • OS:
      generic

      Description

      Value object guidance is here:

      src/hotspot/share/memory/allocation.hpp:

      // Base class for objects used as value objects.
      // Calling new or delete will result in fatal error.
      //
      // Portability note: Certain compilers (e.g. gcc) will
      // always make classes bigger if it has a superclass, even
      // if the superclass does not have any virtual methods or
      // instance fields. The HotSpot implementation relies on this
      // not to happen. So never make a ValueObj class a direct subclass
      // of this object, but use the VALUE_OBJ_CLASS_SPEC class instead, e.g.,
      // like this:
      //
      // class A VALUE_OBJ_CLASS_SPEC {
      // ...
      // }
      //
      // With gcc and possible other compilers the VALUE_OBJ_CLASS_SPEC can
      // be defined as a an empty string "".
      //

      In particular this, this bit of guidance:

        So never make a ValueObj class a direct subclass of this object,
        but use the VALUE_OBJ_CLASS_SPEC class instead

      However, there is one direct subclass of _ValueObj:

      src/hotspot/share/runtime/vframeArray.hpp:

      // A vframeArrayElement is an element of a vframeArray. Each element
      // represent an interpreter frame which will eventually be created.

      class vframeArrayElement : public _ValueObj {

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                coleenp Coleen Phillimore
                Reporter:
                dcubed Daniel Daugherty
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: