mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-16 00:54:38 +02:00
8304292: Memory leak related to ClassLoader::update_class_path_entry_list
Reviewed-by: dholmes, iklam
This commit is contained in:
parent
6f5c903d10
commit
88b4e3b853
5 changed files with 70 additions and 12 deletions
|
@ -523,7 +523,8 @@ void ClassLoader::setup_app_search_path(JavaThread* current, const char *class_p
|
|||
|
||||
while (cp_stream.has_next()) {
|
||||
const char* path = cp_stream.get_next();
|
||||
update_class_path_entry_list(current, path, false, false, false);
|
||||
update_class_path_entry_list(current, path, /* check_for_duplicates */ true,
|
||||
/* is_boot_append */ false, /* from_class_path_attr */ false);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -668,7 +669,8 @@ void ClassLoader::setup_bootstrap_search_path_impl(JavaThread* current, const ch
|
|||
} else {
|
||||
// Every entry on the boot class path after the initial base piece,
|
||||
// which is set by os::set_boot_path(), is considered an appended entry.
|
||||
update_class_path_entry_list(current, path, false, true, false);
|
||||
update_class_path_entry_list(current, path, /* check_for_duplicates */ false,
|
||||
/* is_boot_append */ true, /* from_class_path_attr */ false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -803,7 +805,7 @@ void ClassLoader::add_to_boot_append_entries(ClassPathEntry *new_entry) {
|
|||
// Note that at dump time, ClassLoader::_app_classpath_entries are NOT used for
|
||||
// loading app classes. Instead, the app class are loaded by the
|
||||
// jdk/internal/loader/ClassLoaders$AppClassLoader instance.
|
||||
void ClassLoader::add_to_app_classpath_entries(JavaThread* current,
|
||||
bool ClassLoader::add_to_app_classpath_entries(JavaThread* current,
|
||||
ClassPathEntry* entry,
|
||||
bool check_for_duplicates) {
|
||||
#if INCLUDE_CDS
|
||||
|
@ -813,7 +815,7 @@ void ClassLoader::add_to_app_classpath_entries(JavaThread* current,
|
|||
while (e != nullptr) {
|
||||
if (strcmp(e->name(), entry->name()) == 0) {
|
||||
// entry already exists
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
e = e->next();
|
||||
}
|
||||
|
@ -832,6 +834,7 @@ void ClassLoader::add_to_app_classpath_entries(JavaThread* current,
|
|||
ClassLoaderExt::process_jar_manifest(current, entry);
|
||||
}
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
// Returns true IFF the file/dir exists and the entry was successfully created.
|
||||
|
@ -854,7 +857,10 @@ bool ClassLoader::update_class_path_entry_list(JavaThread* current,
|
|||
if (is_boot_append) {
|
||||
add_to_boot_append_entries(new_entry);
|
||||
} else {
|
||||
add_to_app_classpath_entries(current, new_entry, check_for_duplicates);
|
||||
if (!add_to_app_classpath_entries(current, new_entry, check_for_duplicates)) {
|
||||
// new_entry is not saved, free it now
|
||||
delete new_entry;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue