Skip to content
Permalink
Browse files
Add temporary method to test if target VM supports virtual threads
  • Loading branch information
AlanBateman committed Mar 25, 2021
1 parent a660918 commit cbb80455d7df0a379f827aed1b2aac118114f3a5
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 4 deletions.
@@ -426,8 +426,8 @@ JDWP "Java(tm) Debug Wire Protocol"
"Can the VM return the constant pool information?")
(boolean canForceEarlyReturn
"Can the VM force early return from a method?")
(boolean reserved22
"Reserved for future capability")
(boolean supportsVirtualThreads
"Does the VM support virtual threads, temporary capability")
(boolean reserved23
"Reserved for future capability")
(boolean reserved24
@@ -786,6 +786,23 @@ default boolean canGetModuleInfo() {
return false;
}

/**
* Determine if the target VM support virtual threads.
*
* @return {@code true} if the feature is supported, {@code false} otherwise
*
* @apiNote
* This is a temporary method to test the capability of the target VM.
*
* @implSpec
* The default implementation returns {@code false}.
*
* @since 99
*/
default boolean supportsVirtualThreads() {
return false;
}

/**
* Set this VM's default stratum (see {@link Location} for a
* discussion of strata). Overrides the per-class default set
@@ -835,7 +835,8 @@ public boolean canGetModuleInfo() {

public boolean supportsVirtualThreads() {
validateVM();
return versionInfo().jdwpMajor >= 17; // version is TBD
return hasNewCapabilities() &&
capabilitiesNew().supportsVirtualThreads;
}

public void setDebugTraceMode(int traceFlags) {
@@ -798,8 +798,9 @@ capabilitiesNew(PacketInputStream *in, PacketOutputStream *out)
(void)outStream_writeBoolean(out, (jboolean)caps.can_get_constant_pool);
/* 21 Can force early return */
(void)outStream_writeBoolean(out, (jboolean)caps.can_force_early_return);
/* 22 Supports virtual threads, temporary capability */
(void)outStream_writeBoolean(out, (jboolean)JNI_TRUE);

(void)outStream_writeBoolean(out, (jboolean)JNI_FALSE); /* 22 */
(void)outStream_writeBoolean(out, (jboolean)JNI_FALSE); /* 23 */
(void)outStream_writeBoolean(out, (jboolean)JNI_FALSE); /* 24 */
(void)outStream_writeBoolean(out, (jboolean)JNI_FALSE); /* 25 */

0 comments on commit cbb8045

Please sign in to comment.