1
1
/*
2
- * Copyright (c) 1997, 2020 , Oracle and/or its affiliates. All rights reserved.
2
+ * Copyright (c) 1997, 2021 , Oracle and/or its affiliates. All rights reserved.
3
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
4
*
5
5
* This code is free software; you can redistribute it and/or modify it
@@ -141,8 +141,9 @@ PerfCounter* ClassLoader::_unsafe_defineClassCallCounter = NULL;
141
141
GrowableArray<ModuleClassPathList*>* ClassLoader::_patch_mod_entries = NULL ;
142
142
GrowableArray<ModuleClassPathList*>* ClassLoader::_exploded_entries = NULL ;
143
143
ClassPathEntry* ClassLoader::_jrt_entry = NULL ;
144
- ClassPathEntry* ClassLoader::_first_append_entry = NULL ;
145
- ClassPathEntry* ClassLoader::_last_append_entry = NULL ;
144
+
145
+ ClassPathEntry* volatile ClassLoader::_first_append_entry_list = NULL ;
146
+ ClassPathEntry* volatile ClassLoader::_last_append_entry = NULL ;
146
147
#if INCLUDE_CDS
147
148
ClassPathEntry* ClassLoader::_app_classpath_entries = NULL ;
148
149
ClassPathEntry* ClassLoader::_last_app_classpath_entry = NULL ;
@@ -815,7 +816,7 @@ ClassPathZipEntry* ClassLoader::create_class_path_zip_entry(const char *path, bo
815
816
816
817
// returns true if entry already on class path
817
818
bool ClassLoader::contains_append_entry (const char * name) {
818
- ClassPathEntry* e = _first_append_entry ;
819
+ ClassPathEntry* e = first_append_entry () ;
819
820
while (e != NULL ) {
820
821
// assume zip entries have been canonicalized
821
822
if (strcmp (name, e->name ()) == 0 ) {
@@ -826,11 +827,14 @@ bool ClassLoader::contains_append_entry(const char* name) {
826
827
return false ;
827
828
}
828
829
830
+ // The boot append entries are added with a lock, and read lock free.
829
831
void ClassLoader::add_to_boot_append_entries (ClassPathEntry *new_entry) {
830
832
if (new_entry != NULL ) {
833
+ MutexLocker ml (Bootclasspath_lock, Mutex::_no_safepoint_check_flag);
831
834
if (_last_append_entry == NULL ) {
832
- assert (_first_append_entry == NULL , " boot loader's append class path entry list not empty" );
833
- _first_append_entry = _last_append_entry = new_entry;
835
+ _last_append_entry = new_entry;
836
+ assert (first_append_entry () == NULL , " boot loader's append class path entry list not empty" );
837
+ Atomic::release_store (&_first_append_entry_list, new_entry);
834
838
} else {
835
839
_last_append_entry->set_next (new_entry);
836
840
_last_append_entry = new_entry;
@@ -944,7 +948,7 @@ void ClassLoader::print_bootclasspath() {
944
948
}
945
949
946
950
// appended entries
947
- e = _first_append_entry ;
951
+ e = first_append_entry () ;
948
952
while (e != NULL ) {
949
953
tty->print (" %s ;" , e->name ());
950
954
e = e->next ();
@@ -1252,7 +1256,7 @@ InstanceKlass* ClassLoader::load_class(Symbol* name, bool search_append_only, TR
1252
1256
assert (classpath_index == 0 , " The classpath_index has been incremented incorrectly" );
1253
1257
classpath_index = 1 ;
1254
1258
1255
- e = _first_append_entry ;
1259
+ e = first_append_entry () ;
1256
1260
while (e != NULL ) {
1257
1261
stream = e->open_stream (file_name, CHECK_NULL);
1258
1262
if (NULL != stream) {
@@ -1427,7 +1431,7 @@ void ClassLoader::record_result(InstanceKlass* ik, const ClassFileStream* stream
1427
1431
// Initialize the class loader's access to methods in libzip. Parse and
1428
1432
// process the boot classpath into a list ClassPathEntry objects. Once
1429
1433
// this list has been created, it must not change order (see class PackageInfo)
1430
- // it can be appended to and is by jvmti and the kernel vm .
1434
+ // it can be appended to and is by jvmti.
1431
1435
1432
1436
void ClassLoader::initialize () {
1433
1437
EXCEPTION_MARK;
0 commit comments