RFR: In rare cases, the unlock() on join() might fail, causing an IllegalMonitorStateException

Alan Bateman Alan.Bateman at oracle.com
Thu Feb 25 20:02:31 UTC 2021


On 25/02/2021 15:36, Dr Heinz M. Kabutz wrote:
> :
>
> I did some sleuthing.
>
> Starting at
> src/jdk.jshell/share/classes/jdk/jshell/execution/RemoteExecutionControl.java
>
> we see the StopExecutionException extending ThreadDeath
>
> This is stored as a private field
>
> private final StopExecutionException stopException =new StopExecutionException();
>
> They read this via reflection inside:
>
> src/jdk.jshell/share/classes/jdk/jshell/execution/JdiDefaultExecutionControl.java
>
> This then calls ThreadReference#stop(throwable), which sends the JWDP command to the
> JVM, which relays the command to ThreadReferenceImpl.c and then that calls threadControl.c's
> method
> threadControl_stop(jthread thread, jobject throwable)
Yes, jshell wants to "kill" the main agent thread in response to ctrl-C 
but there isn't really a safe or reliable way to do that. I was chatting 
with Jan Lahoda today about this and whether it could try 
ThreadReference::interrupt first. Doing that would require work on JVMTI 
InterruptThread to have it do more than just set the interrupt status 
(long standing issue here). So I think we need to think more about this 
before putting in fixes for a fundamentally broken feature.

-Alan



More information about the loom-dev mailing list