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

Warn about uses of functions replaced for portability


    • Subcomponent:
    • CPU:
    • OS:


      Hotspot provides a portability layer (via the os "namespace"). This provides portable implementations of various functions with common semantics over all supported platforms. This is used to provide functions not present on some platforms, and to hide behavioral variations between platforms where the functions do exist.

      It is possible for direct uses of the native functions to creep into the code, because only developer care and code review presently prevents that from occurring in some places. For example, if a function is natively available everywhere but with different semantics, it is all too easy to call it while failing to have a test that hits those differences.

      For gcc/clang-based platforms we can use __attribute__ declarations to cause warnings to be generated for references to such functions. These attribute declarations can be added to utilities/compilerWarnings.hpp.

      For functions which should never be called, we can use (for example)

      extern "C" char* strerror(int)
      __attribute__((__warning__("use os::strerror")));

      For functions which should never be called outside the implementation of the os replacement, we can use (for example)

      extern "C" int vsnprintf(char*, size_t, const char*, va_list)
      __attribute__((__deprecated__("use os::vsnprintf")));

      and in the definition of os::vsnprintf, locally disable the deprecation warning with the appropriate diagnostic #pragma.


          Issue Links



              • Assignee:
                hseigel Harold Seigel
                kbarrett Kim Barrett
              • Votes:
                0 Vote for this issue
                4 Start watching this issue


                • Created: