RFR: 8066859: java/lang/ref/OOMEInReferenceHandler.java failed with java.lang.Exception: Reference Handler thread died [v2]

Doug Lea dl at openjdk.org
Wed Jul 13 11:22:31 UTC 2022


On Mon, 11 Jul 2022 04:18:20 GMT, David Holmes <dholmes at openjdk.org> wrote:

>> src/java.base/share/classes/java/util/concurrent/locks/LockSupport.java line 463:
>> 
>>> 461:      *  Preallocated exceptions thrown if acquiring or releasing locks
>>> 462:      *  when OutOfMemory.
>>> 463:      */
>> 
>> I don't see why this should be necessary. IMSE is thrown before any state changes occur and so it is is fine if the IMSE is replaced by OOME.
>> 
>> Even IE should be safe at the points it is thrown.
>> 
>> Also in both cases you want to see a full and proper stacktrace.
>
> Consider this another way, any place you have a `throw x` it must be safe to propagate that exception. It doesn't matter if that is actually `x` or an OOME caused by creating `x`.

On further consideration, I agree. The very low probability that an IE or IMSE would enable further handling is not worth the extra startup cost of establishing static exceptions. Updated.

-------------

PR: https://git.openjdk.org/jdk/pull/9427


More information about the core-libs-dev mailing list