|
1 | 1 | /*
|
2 |
| - * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved. |
| 2 | + * Copyright (c) 1998, 2022, Oracle and/or its affiliates. All rights reserved. |
3 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
4 | 4 | *
|
5 | 5 | * This code is free software; you can redistribute it and/or modify it
|
@@ -753,7 +753,9 @@ invoker_completeInvokeRequest(jthread thread)
|
753 | 753 | }
|
754 | 754 | id = request->id;
|
755 | 755 | exc = request->exception;
|
| 756 | + request->exception = NULL; |
756 | 757 | returnValue = request->returnValue;
|
| 758 | + request->returnValue.l = NULL; |
757 | 759 |
|
758 | 760 | /* Release return value and exception references, but delay the release
|
759 | 761 | * until after the return packet was sent. */
|
@@ -796,23 +798,20 @@ invoker_completeInvokeRequest(jthread thread)
|
796 | 798 | (void)outStream_writeObjectTag(env, &out, exc);
|
797 | 799 | (void)outStream_writeObjectRef(env, &out, exc);
|
798 | 800 | outStream_sendReply(&out);
|
| 801 | + /* |
| 802 | + * Delete potentially saved global references for return value |
| 803 | + * and exception. This must be done before sending the reply or |
| 804 | + * these objects will briefly be viewable by the debugger as live |
| 805 | + * when they shouldn't be. |
| 806 | + */ |
| 807 | + if (mustReleaseReturnValue && returnValue.l != NULL) { |
| 808 | + tossGlobalRef(env, &returnValue.l); |
| 809 | + } |
| 810 | + if (exc != NULL) { |
| 811 | + tossGlobalRef(env, &exc); |
| 812 | + } |
799 | 813 | outStream_destroy(&out);
|
800 | 814 | }
|
801 |
| - |
802 |
| - /* |
803 |
| - * Delete potentially saved global references of return value |
804 |
| - * and exception |
805 |
| - */ |
806 |
| - eventHandler_lock(); // for proper lock order |
807 |
| - debugMonitorEnter(invokerLock); |
808 |
| - if (mustReleaseReturnValue && returnValue.l != NULL) { |
809 |
| - tossGlobalRef(env, &returnValue.l); |
810 |
| - } |
811 |
| - if (exc != NULL) { |
812 |
| - tossGlobalRef(env, &exc); |
813 |
| - } |
814 |
| - debugMonitorExit(invokerLock); |
815 |
| - eventHandler_unlock(); |
816 | 815 | }
|
817 | 816 |
|
818 | 817 | jboolean
|
|
0 commit comments