@@ -1889,7 +1889,7 @@ Symbol* SystemDictionary::find_resolution_error(const constantPoolHandle& pool,
18891889// be updated with the nest host error message.
18901890void SystemDictionary::add_nest_host_error (const constantPoolHandle& pool,
18911891 int which,
1892- const char * message) {
1892+ const stringStream& message) {
18931893 unsigned int hash = resolution_errors ()->compute_hash (pool, which);
18941894 int index = resolution_errors ()->hash_to_index (hash);
18951895 {
@@ -1900,14 +1900,19 @@ void SystemDictionary::add_nest_host_error(const constantPoolHandle& pool,
19001900 // constant pool index. In this case resolution succeeded but there's an error in this nest host
19011901 // that we use the table to record.
19021902 assert (pool->resolved_klass_at (which) != nullptr , " klass should be resolved if there is no entry" );
1903- resolution_errors ()->add_entry (index, hash, pool, which, message);
1903+ resolution_errors ()->add_entry (index, hash, pool, which, message. as_string ( true /* on C-heap */ ) );
19041904 } else {
19051905 // An existing entry means we had a true resolution failure (LinkageError) with our nest host, but we
19061906 // still want to add the error message for the higher-level access checks to report. We should
19071907 // only reach here under the same error condition, so we can ignore the potential race with setting
1908- // the message, and set it again.
1909- assert (entry->nest_host_error () == nullptr || strcmp (entry->nest_host_error (), message) == 0 , " should be the same message" );
1910- entry->set_nest_host_error (message);
1908+ // the message.
1909+ const char * nhe = entry->nest_host_error ();
1910+ if (nhe == nullptr ) {
1911+ entry->set_nest_host_error (message.as_string (true /* on C-heap */ ));
1912+ } else {
1913+ DEBUG_ONLY (const char * msg = message.base ();)
1914+ assert (strcmp (nhe, msg) == 0 , " New message %s, differs from original %s" , msg, nhe);
1915+ }
19111916 }
19121917 }
19131918}
0 commit comments