@@ -1859,7 +1859,7 @@ Symbol* SystemDictionary::find_resolution_error(const constantPoolHandle& pool,
18591859
18601860void SystemDictionary::add_nest_host_error (const constantPoolHandle& pool,
18611861 int which,
1862- const char * message) {
1862+ const stringStream& message) {
18631863 {
18641864 MutexLocker ml (Thread::current (), SystemDictionary_lock);
18651865 ResolutionErrorEntry* entry = ResolutionErrorTable::find_entry (pool, which);
@@ -1868,14 +1868,19 @@ void SystemDictionary::add_nest_host_error(const constantPoolHandle& pool,
18681868 // constant pool index. In this case resolution succeeded but there's an error in this nest host
18691869 // that we use the table to record.
18701870 assert (pool->resolved_klass_at (which) != nullptr , " klass should be resolved if there is no entry" );
1871- ResolutionErrorTable::add_entry (pool, which, message);
1871+ ResolutionErrorTable::add_entry (pool, which, message. as_string ( true /* on C-heap */ ) );
18721872 } else {
18731873 // An existing entry means we had a true resolution failure (LinkageError) with our nest host, but we
18741874 // still want to add the error message for the higher-level access checks to report. We should
18751875 // only reach here under the same error condition, so we can ignore the potential race with setting
1876- // the message, and set it again.
1877- assert (entry->nest_host_error () == nullptr || strcmp (entry->nest_host_error (), message) == 0 , " should be the same message" );
1878- entry->set_nest_host_error (message);
1876+ // the message.
1877+ const char * nhe = entry->nest_host_error ();
1878+ if (nhe == nullptr ) {
1879+ entry->set_nest_host_error (message.as_string (true /* on C-heap */ ));
1880+ } else {
1881+ DEBUG_ONLY (const char * msg = message.base ();)
1882+ assert (strcmp (nhe, msg) == 0 , " New message %s, differs from original %s" , msg, nhe);
1883+ }
18791884 }
18801885 }
18811886}
0 commit comments