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

Add documentation to clarify the MetaspaceObj::metaspace_pointers_do API



      (Per John Rose)

      To support MetspaceClosure, all subtypes of of the C++ class MetaspaceObj must define size(), type() and metaspace_pointers_do(). For subtypes under MetaData, these are dispatched via a vtable. However, for other subtypes that have no vtables (such as ConstMethod), these are dispatched via the templates in MetspaceClosure.

      This API contract is currently not documented by MetaspaceObj. This is a documentation bug. If we had "concepts" in C++, MetaspaceObj should have an associated concept which various templates would refer to, as providing constraints on their arguments. (Kind of likes a generic bound in Java.)

      Something like:

      class MetaspaceObj {
        // This class has no virtual functions (although Metadata does,
        // below it). Nevertheless, there are some protocols that all
        // subtypes of MetaspaceObj are expected to implement, so that
        // templates which are defined for this class hierarchy can
        // work uniformly. They are as follows:
        // void metaspace_pointers_do(MetaspaceClosure* it) { <walk my refs> }
        // int size() const { return align_up(sizeof(<This>), wordSize) / wordSize; }
        // MetaspaceObj::Type type() const { return <This>Type; }
        // DEBUG_ONLY(bool on_stack() { return false; })
        // Within the sub-hierarchy of Metadata, these are virtuals.
        // Elsewhere in the hierarchy of MetaspaceObj, type and/or size can be static if constant.




            • Assignee:
              iklam Ioi Lam
              iklam Ioi Lam
            • Votes:
              0 Vote for this issue
              4 Start watching this issue


              • Created: