SpringBoot Add info contributor support for JDK 24's VirtualThreadSchedulerMXBean

Maybe we can fit these information into the existing ProcessInfo.

Comment From: panic08

I am very interested in this issue and would like to ask a couple questions.

  1. Do I understand correctly that we want to put such fields into ProcessInfo in this form?
private final Long mountedVirtualThreadCount;

private final Long queuedVirtualThreadCount;

private final Integer parallelism;

private final Integer poolSize;
  1. Am I right that we should use reflection to work safely with VirtualThreadSchedulerMXBean since it is jdk 24? Use something like
@SuppressWarnings(“unchecked”)
Class<? extends PlatformManagedObject> clazz = (Class<? extends PlatformManagedObject>)
    Class.forName(“jdk.management.VirtualThreadSchedulerMXBean”);

Object mxBean = ManagementFactory.getPlatformMXBean(clazz);

and then also call methods to get the fields we need

Comment From: mhalbritter

Hello,

I'd add a new field to ProcessInfo: private final VirtualThreads virtualThreads;. This field could be null if running on Java < 24.

public static class VirtualThreads {

    private final long mounted;

    private final long queued;

    private final int parallelism;

    private final int poolSize;

}
  1. Am I right that we should use reflection to work safely with VirtualThreadSchedulerMXBean since it is jdk 24?

Yes. Another option would be a multi-release JAR, but I don't think we have the infrastructure for that in place. I'd go for reflection here.

Should I assign you to the issue?

Comment From: panic08

Should I assign you to the issue?

Yeah, that'd be cool

Comment From: philwebb

Closing in favor of PR #43594. Thanks @panic08!