author | mr |
Tue, 29 Oct 2019 13:52:04 -0700 | |
changeset 58850 | f4290bf1cc21 |
parent 47216 | 71c04702a3d5 |
permissions | -rw-r--r-- |
1 | 1 |
/* |
13963
e5b53c306fb5
7197424: update copyright year to match last edit in jdk8 hotspot repository
mikael
parents:
11760
diff
changeset
|
2 |
* Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. |
1 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. |
|
8 |
* |
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
13 |
* accompanied this code). |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License version |
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
18 |
* |
|
5547
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1
diff
changeset
|
21 |
* questions. |
1 | 22 |
* |
23 |
*/ |
|
24 |
||
7397 | 25 |
#include "precompiled.hpp" |
26 |
#include "runtime/handles.inline.hpp" |
|
27 |
#include "utilities/preserveException.hpp" |
|
1 | 28 |
|
29 |
// TODO: These three classes should be refactored |
|
30 |
||
31 |
PreserveExceptionMark::PreserveExceptionMark(Thread*& thread) { |
|
32 |
thread = Thread::current(); |
|
33 |
_thread = thread; |
|
34 |
_preserved_exception_oop = Handle(thread, _thread->pending_exception()); |
|
35 |
_preserved_exception_line = _thread->exception_line(); |
|
36 |
_preserved_exception_file = _thread->exception_file(); |
|
11760
078e0412bcb2
7131006: java/lang/management/ThreadMXBean/ThreadLists.java
minqi
parents:
7397
diff
changeset
|
37 |
_thread->clear_pending_exception(); // Needed to avoid infinite recursion |
1 | 38 |
} |
39 |
||
40 |
||
41 |
PreserveExceptionMark::~PreserveExceptionMark() { |
|
42 |
if (_thread->has_pending_exception()) { |
|
43 |
oop exception = _thread->pending_exception(); |
|
44 |
_thread->clear_pending_exception(); // Needed to avoid infinite recursion |
|
45 |
exception->print(); |
|
46 |
fatal("PreserveExceptionMark destructor expects no pending exceptions"); |
|
47 |
} |
|
48 |
if (_preserved_exception_oop() != NULL) { |
|
49 |
_thread->set_pending_exception(_preserved_exception_oop(), _preserved_exception_file, _preserved_exception_line); |
|
50 |
} |
|
51 |
} |
|
52 |
||
53 |
||
54 |
// This code is cloned from PreserveExceptionMark, except that: |
|
55 |
// returned pending exceptions do not cause a crash. |
|
56 |
// thread is passed in, not set (not a reference parameter) |
|
57 |
// and bug 6431341 has been addressed. |
|
58 |
||
59 |
CautiouslyPreserveExceptionMark::CautiouslyPreserveExceptionMark(Thread* thread) { |
|
60 |
_thread = thread; |
|
61 |
_preserved_exception_oop = Handle(thread, _thread->pending_exception()); |
|
62 |
_preserved_exception_line = _thread->exception_line(); |
|
63 |
_preserved_exception_file = _thread->exception_file(); |
|
64 |
_thread->clear_pending_exception(); // Pending exceptions are checked in the destructor |
|
65 |
} |
|
66 |
||
67 |
||
68 |
CautiouslyPreserveExceptionMark::~CautiouslyPreserveExceptionMark() { |
|
69 |
assert(!_thread->has_pending_exception(), "unexpected exception generated"); |
|
70 |
if (_thread->has_pending_exception()) { |
|
71 |
_thread->clear_pending_exception(); |
|
72 |
} |
|
73 |
if (_preserved_exception_oop() != NULL) { |
|
74 |
_thread->set_pending_exception(_preserved_exception_oop(), _preserved_exception_file, _preserved_exception_line); |
|
75 |
} |
|
76 |
} |
|
77 |
||
78 |
||
79 |
void WeakPreserveExceptionMark::preserve() { |
|
80 |
_preserved_exception_oop = Handle(_thread, _thread->pending_exception()); |
|
81 |
_preserved_exception_line = _thread->exception_line(); |
|
82 |
_preserved_exception_file = _thread->exception_file(); |
|
83 |
_thread->clear_pending_exception(); |
|
84 |
} |
|
85 |
||
86 |
void WeakPreserveExceptionMark::restore() { |
|
87 |
if (!_thread->has_pending_exception()) { |
|
88 |
_thread->set_pending_exception(_preserved_exception_oop(), _preserved_exception_file, _preserved_exception_line); |
|
89 |
} |
|
90 |
} |