Skip to content

io microsphere process ModernProcessIdResolver

github-actions[bot] edited this page Mar 21, 2026 · 1 revision

ModernProcessIdResolver

Type: Class | Module: microsphere-java-core | Package: io.microsphere.process | Since: 1.0.0

Source: microsphere-java-core/src/main/java/io/microsphere/process/ModernProcessIdResolver.java

Overview

A ProcessIdResolver implementation for modern JDKs (Java 9+).

This class uses the java.lang.ProcessHandle API introduced in Java 9 to retrieve the current process ID. It dynamically checks for the presence of the required classes and methods at runtime, ensuring compatibility with different JDK versions.

Example Usage

`ProcessIdResolver resolver = new ModernProcessIdResolver();
if (resolver.supports()) {
    Long pid = resolver.current();
    System.out.println("Current Process ID: " + pid);
` else {
    System.out.println("Process ID resolution not supported on this JVM version.");
}
}

Declaration

public class ModernProcessIdResolver implements ProcessIdResolver

Author: Mercy

Version Information

  • Introduced in: 1.0.0
  • Current Project Version: 0.1.10-SNAPSHOT

Version Compatibility

This component is tested and compatible with the following Java versions:

Java Version Status
Java 8 ✅ Compatible
Java 11 ✅ Compatible
Java 17 ✅ Compatible
Java 21 ✅ Compatible
Java 25 ✅ Compatible

Examples

ProcessIdResolver resolver = new ModernProcessIdResolver();
if (resolver.supports()) {
    Long pid = resolver.current();
    System.out.println("Current Process ID: " + pid);
} else {
    System.out.println("Process ID resolution not supported on this JVM version.");
}

Usage

Maven Dependency

Add the following dependency to your pom.xml:

<dependency>
    <groupId>io.github.microsphere-projects</groupId>
    <artifactId>microsphere-java-core</artifactId>
    <version>${microsphere-java.version}</version>
</dependency>

Tip: Use the BOM (microsphere-java-dependencies) for consistent version management. See the Getting Started guide.

Import

import io.microsphere.process.ModernProcessIdResolver;

API Reference

Public Methods

Method Description
supports
current
getPriority

See Also

  • ProcessIdResolver
  • java.lang.ProcessHandle

This documentation was auto-generated from the source code of microsphere-java.

Home

java-annotations

java-core

jdk-tools

lang-model

annotation-processor

java-test

Clone this wiki locally