11/*
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.
33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44 *
55 * This code is free software; you can redistribute it and/or modify it
@@ -1997,7 +1997,7 @@ oop java_lang_Throwable::message(oop throwable) {
19971997
19981998// Return Symbol for detailed_message or NULL
19991999Symbol* java_lang_Throwable::detail_message (oop throwable) {
2000- PRESERVE_EXCEPTION_MARK; // Keep original exception
2000+ PreserveExceptionMark pm ( Thread::current ());
20012001 oop detailed_message = java_lang_Throwable::message (throwable);
20022002 if (detailed_message != NULL ) {
20032003 return java_lang_String::as_symbol (detailed_message);
@@ -2187,7 +2187,7 @@ class BacktraceBuilder: public StackObj {
21872187 _index++;
21882188 }
21892189
2190- void set_has_hidden_top_frame (TRAPS ) {
2190+ void set_has_hidden_top_frame () {
21912191 if (!_has_hidden_top_frame) {
21922192 // It would be nice to add java/lang/Boolean::TRUE here
21932193 // to indicate that this backtrace has a hidden top frame.
@@ -2525,7 +2525,7 @@ void java_lang_Throwable::fill_in_stack_trace(Handle throwable, const methodHand
25252525 if (skip_hidden) {
25262526 if (total_count == 0 ) {
25272527 // The top frame will be hidden from the stack trace.
2528- bt.set_has_hidden_top_frame (CHECK );
2528+ bt.set_has_hidden_top_frame ();
25292529 }
25302530 continue ;
25312531 }
@@ -2552,11 +2552,12 @@ void java_lang_Throwable::fill_in_stack_trace(Handle throwable, const methodHand
25522552 return ;
25532553 }
25542554
2555- PRESERVE_EXCEPTION_MARK;
2555+ JavaThread* THREAD = JavaThread::current ();
2556+ PreserveExceptionMark pm (THREAD);
25562557
2557- JavaThread* thread = JavaThread::active ( );
2558- fill_in_stack_trace (throwable, method, thread);
2559- // ignore exceptions thrown during stack trace filling
2558+ fill_in_stack_trace (throwable, method, THREAD );
2559+ // Ignore exceptions thrown during stack trace filling (OOM) and reinstall the
2560+ // original exception via the PreserveExceptionMark destructor.
25602561 CLEAR_PENDING_EXCEPTION;
25612562}
25622563
0 commit comments