Skip to content

Fix illegal reflective access warning on JDK 11 (fixes #12167)#12339

Merged
gnodet merged 2 commits into
maven-3.10.xfrom
fix/12167-jline-illegal-reflective-access
Jun 22, 2026
Merged

Fix illegal reflective access warning on JDK 11 (fixes #12167)#12339
gnodet merged 2 commits into
maven-3.10.xfrom
fix/12167-jline-illegal-reflective-access

Conversation

@gnodet

@gnodet gnodet commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Set org.jline.terminal.exec.redirectPipeCreationMode=native in both mvn and mvn.cmd launcher scripts to prevent JLine's ExecTerminalProvider from using reflection to access ProcessBuilder$RedirectPipeImpl
  • This avoids the "WARNING: Illegal reflective access" messages on JDK 9-15 when stdout is redirected (e.g. mvn -v | cat or mvn -v > file.txt)

The property is a JLine 3.x configuration knob (see jline/jline3#951) that switches pipe creation from reflection-based to native (JNI), which is already available since Maven ships jline-terminal-jni and sets -Dlibrary.jline.path.

Fixes #12167

Test plan

  • On JDK 11, verify mvn -v | cat no longer prints the "Illegal reflective access" warning
  • On JDK 8, verify mvn -v still works (property is harmless — exec provider falls back)
  • On JDK 17+, verify no regressions

🤖 Generated with Claude Code

Claude Code on behalf of Guillaume Nodet

gnodet and others added 2 commits June 22, 2026 17:50
Set org.jline.terminal.exec.redirectPipeCreationMode=native in
launcher scripts to prevent JLine's ExecTerminalProvider from
using reflection to access ProcessBuilder$RedirectPipeImpl.

This avoids the "WARNING: Illegal reflective access" messages
that appear on JDK 9-15 when stdout is redirected (e.g. piped
or written to a file).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Keep reflection as a fallback for platforms where the native
JNI implementation may not be available.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@gnodet gnodet requested a review from slawekjaranowski June 22, 2026 15:53
@gnodet gnodet added the mvn3 label Jun 22, 2026
@slawekjaranowski

Copy link
Copy Markdown
Member

confirm, my test:

MAVEN_OPTS='-Dorg.jline.terminal.exec.redirectPipeCreationMode=native,reflection' mvn -v | cat -
Apache Maven 3.10.0-SNAPSHOT (c64fbe4aa7e348a30bfecf8c5118d6d399627301)
Maven home: /Users/slawomir.jaranowski/.sdkman/candidates/maven/current
Java version: 11.0.31, vendor: Eclipse Adoptium, runtime: /Users/slawomir.jaranowski/.sdkman/candidates/java/11.0.31-tem
Default locale: en_PL, platform encoding: UTF-8, time zone: Europe/Warsaw
OS name: "mac os x", version: "26.5.1", arch: "aarch64", family: "mac"

@gnodet gnodet added the bug Something isn't working label Jun 22, 2026
@gnodet gnodet changed the title [ISSUE-12167] Fix illegal reflective access warning on JDK 11 Fix illegal reflective access warning on JDK 11 (fixes #12167) Jun 22, 2026
@gnodet gnodet merged commit 2970755 into maven-3.10.x Jun 22, 2026
21 checks passed
@gnodet gnodet deleted the fix/12167-jline-illegal-reflective-access branch June 22, 2026 18:13
@github-actions github-actions Bot added this to the 3.10.0 milestone Jun 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working mvn3

Projects

None yet

Development

Successfully merging this pull request may close these issues.

WARNING: Illegal reflective access by org.jline.terminal.impl.exec.ExecTerminalProvider JDK11

3 participants