Merge pull request #183760 from asbachb/openjdk17-remove-lib-folders

openjdk17: Remove default java.library.path

authored by

Robert Hensing and committed by
GitHub
d6417bd3 ac27a3cd

+61
+1
pkgs/development/compilers/openjdk/17.nix
··· 41 41 ./currency-date-range-jdk10.patch 42 42 ./increase-javadoc-heap-jdk13.patch 43 43 ./ignore-LegalNoticeFilePlugin.patch 44 + ./fix-library-path-jdk17.patch 44 45 45 46 # -Wformat etc. are stricter in newer gccs, per 46 47 # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79677
+60
pkgs/development/compilers/openjdk/fix-library-path-jdk17.patch
··· 1 + --- a/src/hotspot/os/linux/os_linux.cpp 2 + +++ b/src/hotspot/os/linux/os_linux.cpp 3 + @@ -412,18 +412,8 @@ void os::init_system_properties_values() { 4 + // 1: ... 5 + // ... 6 + // 7: The default directories, normally /lib and /usr/lib. 7 + -#ifndef OVERRIDE_LIBPATH 8 + - #if defined(_LP64) 9 + - #define DEFAULT_LIBPATH "/usr/lib64:/lib64:/lib:/usr/lib" 10 + - #else 11 + - #define DEFAULT_LIBPATH "/lib:/usr/lib" 12 + - #endif 13 + -#else 14 + - #define DEFAULT_LIBPATH OVERRIDE_LIBPATH 15 + -#endif 16 + 17 + // Base path of extensions installed on the system. 18 + -#define SYS_EXT_DIR "/usr/java/packages" 19 + #define EXTENSIONS_DIR "/lib/ext" 20 + 21 + // Buffer that fits several sprintfs. 22 + @@ -431,7 +421,7 @@ void os::init_system_properties_values() { 23 + // by the nulls included by the sizeof operator. 24 + const size_t bufsize = 25 + MAX2((size_t)MAXPATHLEN, // For dll_dir & friends. 26 + - (size_t)MAXPATHLEN + sizeof(EXTENSIONS_DIR) + sizeof(SYS_EXT_DIR) + sizeof(EXTENSIONS_DIR)); // extensions dir 27 + + (size_t)MAXPATHLEN + sizeof(EXTENSIONS_DIR) + sizeof(EXTENSIONS_DIR)); // extensions dir 28 + char *buf = NEW_C_HEAP_ARRAY(char, bufsize, mtInternal); 29 + 30 + // sysclasspath, java_home, dll_dir 31 + @@ -478,26 +468,22 @@ void os::init_system_properties_values() { 32 + // should always exist (until the legacy problem cited above is 33 + // addressed). 34 + const char *v = ::getenv("LD_LIBRARY_PATH"); 35 + - const char *v_colon = ":"; 36 + - if (v == NULL) { v = ""; v_colon = ""; } 37 + + if (v == NULL) { v = ""; } 38 + // That's +1 for the colon and +1 for the trailing '\0'. 39 + char *ld_library_path = NEW_C_HEAP_ARRAY(char, 40 + - strlen(v) + 1 + 41 + - sizeof(SYS_EXT_DIR) + sizeof("/lib/") + sizeof(DEFAULT_LIBPATH) + 1, 42 + + strlen(v) + 1, 43 + mtInternal); 44 + - sprintf(ld_library_path, "%s%s" SYS_EXT_DIR "/lib:" DEFAULT_LIBPATH, v, v_colon); 45 + + sprintf(ld_library_path, "%s", v); 46 + Arguments::set_library_path(ld_library_path); 47 + FREE_C_HEAP_ARRAY(char, ld_library_path); 48 + } 49 + 50 + // Extensions directories. 51 + - sprintf(buf, "%s" EXTENSIONS_DIR ":" SYS_EXT_DIR EXTENSIONS_DIR, Arguments::get_java_home()); 52 + + sprintf(buf, "%s" EXTENSIONS_DIR, Arguments::get_java_home()); 53 + Arguments::set_ext_dirs(buf); 54 + 55 + FREE_C_HEAP_ARRAY(char, buf); 56 + 57 + -#undef DEFAULT_LIBPATH 58 + -#undef SYS_EXT_DIR 59 + #undef EXTENSIONS_DIR 60 + }