mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-16 17:14:41 +02:00
8237750: Load libzip.so only if necessary
Libzip.so is unconditionally loaded even without usage. Fix by on demand loading. Reviewed-by: dlong, iklam, ccheung
This commit is contained in:
parent
bc8065facd
commit
0c0d485c37
6 changed files with 28 additions and 4 deletions
|
@ -95,6 +95,7 @@ static FindEntry_t FindEntry = NULL;
|
|||
static ReadEntry_t ReadEntry = NULL;
|
||||
static GetNextEntry_t GetNextEntry = NULL;
|
||||
static Crc32_t Crc32 = NULL;
|
||||
int ClassLoader::_libzip_loaded = 0;
|
||||
|
||||
// Entry points for jimage.dll for loading jimage file entries
|
||||
|
||||
|
@ -747,6 +748,7 @@ ClassPathEntry* ClassLoader::create_class_path_entry(const char *path, const str
|
|||
// enable call to C land
|
||||
ThreadToNativeFromVM ttn(thread);
|
||||
HandleMark hm(thread);
|
||||
load_zip_library_if_needed();
|
||||
zip = (*ZipOpen)(canonical_path, &error_msg);
|
||||
}
|
||||
if (zip != NULL && error_msg == NULL) {
|
||||
|
@ -796,6 +798,7 @@ ClassPathZipEntry* ClassLoader::create_class_path_zip_entry(const char *path, bo
|
|||
JavaThread* thread = JavaThread::current();
|
||||
ThreadToNativeFromVM ttn(thread);
|
||||
HandleMark hm(thread);
|
||||
load_zip_library_if_needed();
|
||||
zip = (*ZipOpen)(canonical_path, &error_msg);
|
||||
}
|
||||
if (zip != NULL && error_msg == NULL) {
|
||||
|
@ -967,6 +970,14 @@ void ClassLoader::load_java_library() {
|
|||
CanonicalizeEntry = CAST_TO_FN_PTR(canonicalize_fn_t, dll_lookup(javalib_handle, "JDK_Canonicalize", NULL));
|
||||
}
|
||||
|
||||
void ClassLoader::release_load_zip_library() {
|
||||
MutexLocker locker(Zip_lock, Monitor::_no_safepoint_check_flag);
|
||||
if (_libzip_loaded == 0) {
|
||||
load_zip_library();
|
||||
Atomic::release_store(&_libzip_loaded, 1);
|
||||
}
|
||||
}
|
||||
|
||||
void ClassLoader::load_zip_library() {
|
||||
assert(ZipOpen == NULL, "should not load zip library twice");
|
||||
char path[JVM_MAXPATHLEN];
|
||||
|
@ -1008,6 +1019,7 @@ void ClassLoader::load_jimage_library() {
|
|||
}
|
||||
|
||||
int ClassLoader::crc32(int crc, const char* buf, int len) {
|
||||
load_zip_library_if_needed();
|
||||
return (*Crc32)(crc, (const jbyte*)buf, len);
|
||||
}
|
||||
|
||||
|
@ -1466,8 +1478,6 @@ void ClassLoader::initialize() {
|
|||
|
||||
// lookup java library entry points
|
||||
load_java_library();
|
||||
// lookup zip library entry points
|
||||
load_zip_library();
|
||||
// jimage library entry points are loaded below, in lookup_vm_options
|
||||
setup_bootstrap_search_path();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue