--- old/src/hotspot/os/bsd/os_bsd.inline.hpp 2018-10-04 11:57:56.000000000 -0500 +++ new/src/hotspot/os/bsd/os_bsd.inline.hpp 2018-10-04 11:57:56.000000000 -0500 @@ -34,11 +34,50 @@ #include #include -// File names are case-insensitive on windows only +#ifdef __APPLE__ + +#include +#include + +// File names could be case-insensitive on Mac OS X, +// depending on the filesystem's capabilities. +static bool is_filesystem_case_insensitive(const char* path) { + char resolved[PATH_MAX] = {'\0'}; + if (path[0] != '/') { + // The path is relative, so find the current working directory + os::get_current_directory(resolved, PATH_MAX); + // Start resolving full path + int remaining = PATH_MAX - strlen(resolved) - 1; + if (remaining > 0) { + strncat(resolved, "/", (size_t)remaining); + } + } + // Resolve full path + int remaining = PATH_MAX - strlen(resolved) - 1; + if (remaining > 0) { + strncat(resolved, path, (size_t)remaining); + } + return (pathconf(resolved, _PC_CASE_SENSITIVE) == 0); +} + +inline int os::file_name_strncmp(const char* s1, const char* s2, size_t num) { + int result = strncmp(s1, s2, num); + if ((result != 0) && (strlen(s1) == strlen(s2))) { + if (is_filesystem_case_insensitive(s1)) { + result = strncasecmp(s1, s2, num); + } + } + return result; +} + +#else + inline int os::file_name_strncmp(const char* s1, const char* s2, size_t num) { return strncmp(s1, s2, num); } +#endif // __APPLE__ + inline bool os::obsolete_option(const JavaVMOption *option) { return false; }