8301639: JDI and JDWP specs should clarify potential deadlock issues with method invocation

Reviewed-by: dholmes, alanb
This commit is contained in:
Chris Plummer 2023-09-22 20:29:00 +00:00
parent 6b8261b8d6
commit 9aaac2eee3
4 changed files with 50 additions and 14 deletions
src
java.se/share/data/jdwp
jdk.jdi/share/classes/com/sun/jdi

@ -1145,9 +1145,9 @@ JDWP "Java(tm) Debug Wire Protocol"
"<p>"
"By default, all threads in the target VM are resumed while "
"the method is being invoked if they were previously "
"suspended by an event or by command. "
"suspended by an event or by a command. "
"This is done to prevent the deadlocks "
"that will occur if any of the threads own monitors "
"that will occur if any of the threads own resources, such as monitors, "
"that will be needed by the invoked method. It is possible that "
"breakpoints or other events might occur during the invocation. "
"Note, however, that this implicit resume acts exactly like "
@ -1221,9 +1221,9 @@ JDWP "Java(tm) Debug Wire Protocol"
"<p>"
"By default, all threads in the target VM are resumed while "
"the method is being invoked if they were previously "
"suspended by an event or by command. "
"suspended by an event or by a command. "
"This is done to prevent the deadlocks "
"that will occur if any of the threads own monitors "
"that will occur if any of the threads own resources, such as monitors, "
"that will be needed by the invoked method. It is possible that "
"breakpoints or other events might occur during the invocation. "
"Note, however, that this implicit resume acts exactly like "
@ -1321,7 +1321,7 @@ JDWP "Java(tm) Debug Wire Protocol"
"the method is being invoked if they were previously "
"suspended by an event or by a command. "
"This is done to prevent the deadlocks "
"that will occur if any of the threads own monitors "
"that will occur if any of the threads own resources, such as monitors, "
"that will be needed by the invoked method. It is possible that "
"breakpoints or other events might occur during the invocation. "
"Note, however, that this implicit resume acts exactly like "
@ -1662,7 +1662,7 @@ JDWP "Java(tm) Debug Wire Protocol"
"the method is being invoked if they were previously "
"suspended by an event or by a command. "
"This is done to prevent the deadlocks "
"that will occur if any of the threads own monitors "
"that will occur if any of the threads own resources, such as monitors, "
"that will be needed by the invoked method. It is possible that "
"breakpoints or other events might occur during the invocation. "
"Note, however, that this implicit resume acts exactly like "

@ -1,5 +1,5 @@
/*
* Copyright (c) 1998, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -173,7 +173,7 @@ public interface ClassType extends ReferenceType {
* the method is being invoked if they were previously
* suspended by an event or by {@link VirtualMachine#suspend} or
* {@link ThreadReference#suspend}. This is done to prevent the deadlocks
* that will occur if any of the threads own monitors
* that will occur if any of the threads own resources, such as monitors,
* that will be needed by the invoked method.
* Note, however, that this implicit resume acts exactly like
* {@link ThreadReference#resume}, so if the thread's suspend
@ -207,6 +207,15 @@ public interface ClassType extends ReferenceType {
* If the target VM is disconnected during the invoke (for example, through
* {@link VirtualMachine#dispose}) the method invocation continues.
*
* @apiNote
* <a href="{@docRoot}/java.base/java/lang/Thread.html#virtual-threads">Virtual threads</a>
* are typically user-mode threads scheduled by the Java runtime rather than
* the operating system. As such, there may be more cases with virtual threads
* where the {@link #INVOKE_SINGLE_THREADED} option may cause a deadlock.
* For example, suspending all threads in the target VM may suspend threads that
* support the timer mechanism for virtual threads, and thus methods such as
* {@link Thread#sleep} may deadlock.
*
* @param thread the thread in which to invoke.
* @param method the {@link Method} to invoke.
* @param arguments the list of {@link Value} arguments bound to the
@ -284,7 +293,7 @@ public interface ClassType extends ReferenceType {
* the method is being invoked if they were previously
* suspended by an event or by {@link VirtualMachine#suspend} or
* {@link ThreadReference#suspend}. This is done to prevent the deadlocks
* that will occur if any of the threads own monitors
* that will occur if any of the threads own resources, such as monitors,
* that will be needed by the invoked method. It is possible that
* breakpoints or other events might occur during the invocation.
* Note, however, that this implicit resume acts exactly like
@ -308,6 +317,15 @@ public interface ClassType extends ReferenceType {
* If the target VM is disconnected during the invoke (for example, through
* {@link VirtualMachine#dispose}) the method invocation continues.
*
* @apiNote
* <a href="{@docRoot}/java.base/java/lang/Thread.html#virtual-threads">Virtual threads</a>
* are typically user-mode threads scheduled by the Java runtime rather than
* the operating system. As such, there may be more cases with virtual threads
* where the {@link #INVOKE_SINGLE_THREADED} option may cause a deadlock.
* For example, suspending all threads in the target VM may suspend threads that
* support the timer mechanism for virtual threads, and thus methods such as
* {@link Thread#sleep} may deadlock.
*
* @param thread the thread in which to invoke.
* @param method the constructor {@link Method} to invoke.
* @param arguments the list of {@link Value} arguments bound to the

@ -1,5 +1,5 @@
/*
* Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -104,7 +104,7 @@ public interface InterfaceType extends ReferenceType {
* <p>
* Object arguments must be assignment compatible with the argument type
* (This implies that the argument type must be loaded through the
* enclosing class' class loader). Primitive arguments must be
* enclosing class's class loader). Primitive arguments must be
* either assignment compatible with the argument type or must be
* convertible to the argument type without loss of information.
* If the method being called accepts a variable number of arguments,
@ -124,7 +124,7 @@ public interface InterfaceType extends ReferenceType {
* the method is being invoked if they were previously
* suspended by an event or by {@link VirtualMachine#suspend} or
* {@link ThreadReference#suspend}. This is done to prevent the deadlocks
* that will occur if any of the threads own monitors
* that will occur if any of the threads own resources, such as monitors,
* that will be needed by the invoked method.
* Note, however, that this implicit resume acts exactly like
* {@link ThreadReference#resume}, so if the thread's suspend
@ -158,6 +158,15 @@ public interface InterfaceType extends ReferenceType {
* If the target VM is disconnected during the invoke (for example, through
* {@link VirtualMachine#dispose}) the method invocation continues.
*
* @apiNote
* <a href="{@docRoot}/java.base/java/lang/Thread.html#virtual-threads">Virtual threads</a>
* are typically user-mode threads scheduled by the Java runtime rather than
* the operating system. As such, there may be more cases with virtual threads
* where the {@link ClassType#INVOKE_SINGLE_THREADED} option may cause a deadlock.
* For example, suspending all threads in the target VM may suspend threads that
* support the timer mechanism for virtual threads, and thus methods such as
* {@link Thread#sleep} may deadlock.
*
* @param thread the thread in which to invoke.
* @param method the {@link Method} to invoke.
* @param arguments the list of {@link Value} arguments bound to the

@ -1,5 +1,5 @@
/*
* Copyright (c) 1998, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -205,7 +205,7 @@ public interface ObjectReference extends Value {
* the method is being invoked if they were previously
* suspended by an event or by {@link VirtualMachine#suspend} or
* {@link ThreadReference#suspend}. This is done to prevent the deadlocks
* that will occur if any of the threads own monitors
* that will occur if any of the threads own resources, such as monitors,
* that will be needed by the invoked method.
* Note, however, that this implicit resume acts exactly like
* {@link ThreadReference#resume}, so if the thread's suspend
@ -239,6 +239,15 @@ public interface ObjectReference extends Value {
* If the target VM is disconnected during the invoke (for example, through
* {@link VirtualMachine#dispose}) the method invocation continues.
*
* @apiNote
* <a href="{@docRoot}/java.base/java/lang/Thread.html#virtual-threads">Virtual threads</a>
* are typically user-mode threads scheduled by the Java runtime rather than
* the operating system. As such, there may be more cases with virtual threads
* where the {@link #INVOKE_SINGLE_THREADED} option may cause a deadlock.
* For example, suspending all threads in the target VM may suspend threads that
* support the timer mechanism for virtual threads, and thus methods such as
* {@link Thread#sleep} may deadlock.
*
* @param thread the thread in which to invoke.
* @param method the {@link Method} to invoke.
* @param arguments the list of {@link Value} arguments bound to the