@@ -1896,14 +1896,19 @@ void SystemDictionary::add_nest_host_error(const constantPoolHandle& pool,
18961896 {
18971897 MutexLocker ml (Thread::current (), SystemDictionary_lock);
18981898 ResolutionErrorEntry* entry = resolution_errors ()->find_entry (index, hash, pool, which);
1899- if (entry != NULL && entry->nest_host_error () == NULL ) {
1899+ if (entry == NULL ) {
1900+ // Only add a new entry to the resolution error table if one hasn't been found for this
1901+ // constant pool index. In this case resolution succeeded but there's an error in this nest host
1902+ // that we use the table to record.
1903+ assert (pool->resolved_klass_at (which) != nullptr , " klass should be resolved if there is no entry" );
1904+ resolution_errors ()->add_entry (index, hash, pool, which, message);
1905+ } else {
19001906 // An existing entry means we had a true resolution failure (LinkageError) with our nest host, but we
19011907 // still want to add the error message for the higher-level access checks to report. We should
19021908 // only reach here under the same error condition, so we can ignore the potential race with setting
1903- // the message. If we see it is already set then we can ignore it.
1909+ // the message, and set it again.
1910+ assert (entry->nest_host_error () == nullptr || strcmp (entry->nest_host_error (), message) == 0 , " should be the same message" );
19041911 entry->set_nest_host_error (message);
1905- } else {
1906- resolution_errors ()->add_entry (index, hash, pool, which, message);
19071912 }
19081913 }
19091914}
0 commit comments