--- old/src/hotspot/share/classfile/systemDictionaryShared.cpp 2020-06-24 22:02:40.163365179 +0000 +++ new/src/hotspot/share/classfile/systemDictionaryShared.cpp 2020-06-24 22:02:39.248342859 +0000 @@ -871,7 +871,17 @@ // the corresponding SystemDictionaryShared::get_shared_xxx() function. Handle manifest = get_shared_jar_manifest(index, CHECK_(pd)); Handle url = get_shared_jar_url(index, CHECK_(pd)); - define_shared_package(class_name, class_loader, manifest, url, CHECK_(pd)); + int index_offset = index - ClassLoaderExt::app_class_paths_start_index(); + if (index_offset < MAX_BITMAP_BITS) { + if (pkg_entry == NULL || !pkg_entry->is_defined_by_cds_in_class_path(index_offset)) { + define_shared_package(class_name, class_loader, manifest, url, CHECK_(pd)); + if (pkg_entry != NULL) { + pkg_entry->set_defined_in_class_path(index_offset); + } + } + } else { + define_shared_package(class_name, class_loader, manifest, url, CHECK_(pd)); + } pd = get_shared_protection_domain(class_loader, index, url, CHECK_(pd)); } }