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

Macros should be defined in the global namespace in src/hotspot/share/memory/metaspace

XMLWordPrintable

      Sonarcloud issues the following warning about various macros in src/hotspot/share/memory/metaspace.

      “Move this #define/#undef to the global namespace.
      Macros should not be #define'd or #undef'd within a block”

      For example, in src/hotspot/share/memory/metaspace/blockTree.cpp

      namespace metaspace {
      // Needed to prevent linker errors on MacOS and AIX
      const size_t BlockTree::MinWordSize;
      #define NODE_FORMAT \
      Move this #define/#undef to the global namespace.
        "@" PTR_FORMAT \
        ": canary " INTPTR_FORMAT \
        ", parent " PTR_FORMAT \
        ", left " PTR_FORMAT \
        ", right " PTR_FORMAT \
        ", next " PTR_FORMAT \
        ", size " SIZE_FORMAT
      #define NODE_FORMAT_ARGS(n) \
        p2i(n), \
        (n)->_canary, \
        p2i((n)->_parent), \
        p2i((n)->_left), \
        p2i((n)->_right), \
        p2i((n)->_next), \
        (n)->_word_size


      }

      Macros should be defined outside of the metaspace namespace, since their scope is not actually restricted.

            Unassigned Unassigned
            szaldana Sonia Zaldana Calles
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: