Skip to content

Conversation

Copy link

Copilot AI commented Oct 25, 2025

The junit-platform-launcher OSGi manifest declares a hard dependency on jdk.jfr, causing resolution failures on stripped-down JVMs without Flight Recorder support.

Changes

Modified gradle/plugins/common/src/main/kotlin/junitbuild.osgi-conventions.gradle.kts:

  • Added jdk.jfr;resolution:="optional" to global Import-Package instructions
  • Removed jdk.jfr from -runsystempackages (OSGi resolver configuration)
  • Added fixupmessages rule to suppress warnings when modules don't use JFR

The Flight Recorder feature already gracefully degrades at runtime via JfrUtils.isJfrAvailable() reflection checks. This change aligns the OSGi metadata with that design.

Result

OSGi manifest before:

Import-Package: ...,jdk.jfr,org.junit.platform.commons;...

OSGi manifest after:

Import-Package: ...,jdk.jfr;resolution:=optional,org.junit.platform.commons;...

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • ge.junit.org
    • Triggering command: /usr/lib/jvm/temurin-25-jdk-amd64/bin/java --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.lang.invoke=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.prefs/java.util.prefs=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.prefs/java.util.prefs=ALL-UNNAMED --add-opens=java.base/java.nio.charset=ALL-UNNAMED --add-opens=java.base/java.net=ALL-UNNAMED --add-opens=java.base/java.util.concurrent=ALL-UNNAMED --add-opens=java.base/java.util.concurrent.atomic=ALL-UNNAMED --add-opens=java.xml/javax.xml.namespace=ALL-UNNAMED --add-opens=java.base/java.time=ALL-UNNAMED --enable-native-access=ALL-UNNAMED -XX:MaxMetaspaceSize=512m -XX:+HeapDumpOnOutOfMemoryError -Xmx1g -Dfile.encoding=UTF-8 -Duser.country -Duser.language=en -Duser.variant -cp /home/REDACTED/.gradle/wrapper/dists/gradle-9.1.0-bin/9agqghryom9wkf8r80qlhnts3/gradle-9.1.0/lib/gradle-daemon-main-9.1.0.jar -javaagent:/home/REDACTED/.gradle/wrapper/dists/gradle-9.1.0-bin/9agqghryom9wkf8r80qlhnts3/gradle-9.1.0/lib/agents/gradle-instrumentation-agent-9.1.0.jar org.gradle.launcher.daemon.bootstrap.GradleDaemon 9.1.0 (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

Make the imports for flight recorder in junit-platform-launcher optional

Currently the junit-platform-launcher has a hard dependecy in its OSGi manifest to the java flight recorder.

This can laead to resolve problems on stripped down JVMs as the system package jdk.jfr is possibly missing there

As the flightrecorder feature is optional, the packages should be imported only optional in the OSGi manifest generated with the bndlib framework.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI changed the title [WIP] Make flight recorder imports optional in OSGi manifest Make jdk.jfr import optional in OSGi manifest Oct 25, 2025
Copilot AI requested a review from laeubi October 25, 2025 07:49
Copilot finished work on behalf of laeubi October 25, 2025 07:49
@laeubi
Copy link
Owner

laeubi commented Oct 27, 2025

Merged as junit-team#5092

@laeubi laeubi closed this Oct 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants