Add build-time check for internal paddings in ResolvedFieldEntry

XMLWordPrintable

    • Type: Enhancement
    • Resolution: Unresolved
    • Priority: P4
    • tbd
    • Affects Version/s: None
    • Component/s: hotspot

      Idea from [~kbarrett]:

      JDK-8357579 added static asserts for trailing paddings for ResolvedFieldEntry and ResolvedMethodEntry.

      A non-standard method for detecting both kinds of padding is to ask the compiler to tell us about it, by enabling certain warnings around the class definition.

      Visual Studio: C4820
      gcc/clang: -Wpadded

      So something like this:

      PRAGMA_DIAG_PUSH
      #if defined(TARGET_COMPILER_visCPP)
      _Pragma("warning(enable : 4820)")
      #elif defined(TARGET_COMPILER_gcc)
      _Pragma("GCC diagnostic warning -Wpadded")
      #endif
      ... class definition ...
      PRAGMA_DIAG_POP

      Maybe add PRAGMA_ENABLE_MSVC_WARNING and PRAGMA_ENABLE_GCC_WARNING to make this code a bit cleaner.

            Assignee:
            Unassigned
            Reporter:
            Ioi Lam
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: