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.
- blocks
-
JDK-8249001 Add Copy::disjoint_bytes
- Closed
- relates to
-
JDK-8214944 replace strerror by os::strerror
- Resolved
-
JDK-8288101 False build warning-as-error with GCC 9 after JDK-8214976
- Resolved
-
JDK-8288082 Build failure due to __clang_major__ is not defined after JDK-8214976
- Resolved
-
JDK-8289633 Forbid raw C-heap allocation functions in hotspot and fix findings
- Resolved
-
JDK-8290900 Build failure with Clang 14+ due to function warning attribute
- Resolved
-
JDK-8148425 strerror() function is not thread-safe
- Closed
-
JDK-8280178 Remove os:: API's that just call system API's
- Resolved
-
JDK-8286349 Simplify use of Windows deprecated POSIX names
- Closed
-
JDK-8224033 os::snprintf should be used in virtualizationSupport.cpp
- Resolved
-
JDK-8232187 Add os::strncpy_s
- Open
-
JDK-8279936 Change shared code to use os:: system API's
- Resolved
-
JDK-8286262 Windows: Cleanup deprecation warning suppression
- Resolved
- links to
-
Commit openjdk/jdk/04f02ac6
-
Review openjdk/jdk/6961
-
Review openjdk/jdk/7248
-
Review openjdk/jdk/8982