codeconsole opened a new pull request, #15989:
URL: https://github.com/apache/grails-core/pull/15989

   ### Problem
   
   On JDK 24+ every launch of the CLI prints JEP 472 restricted-method warnings:
   
   ```
   WARNING: A restricted method in java.lang.System has been called
   WARNING: java.lang.System::load has been called by 
org.jline.nativ.JLineNativeLoader in an unnamed module 
(file:/.../grails-cli-8.0.0-M3-all.jar)
   WARNING: Use --enable-native-access=ALL-UNNAMED to avoid a warning for 
callers in this module
   WARNING: Restricted methods will be blocked in a future release unless 
native access is enabled
   ```
   
   JLine loads its native terminal library via `System::load`, a restricted 
method under [JEP 472](https://openjdk.org/jeps/472). The generated start 
scripts launch the shadow jar on the classpath with `DEFAULT_JVM_OPTS=""`, so 
nothing grants native access. Today this is just noise, but a future JDK 
release will block the call outright, breaking interactive terminal support.
   
   There is no way to avoid the grant: terminal control fundamentally requires 
native access (JLine's FFM provider hits the same restriction, and the `exec` 
provider degrades to a dumb terminal on Windows). JEP 472's prescribed 
remediation for classpath applications is exactly this flag in the launcher.
   
   Relates to #15216, which reported the same symptom from `grailsw` on Java 25 
(via hawtjni at the time; it is JLine's loader in 8.0.x) and only had a 
user-side workaround.
   
   ### Change
   
   Set `defaultJvmOpts = ['--enable-native-access=ALL-UNNAMED']` on the four 
`CreateStartScripts` tasks:
   
   - `grails`, `grails-shell-cli`, `grails-forge-cli` 
(`grails-forge/grails-cli/build.gradle`)
   - `grailsw` (`grails-wrapper/build.gradle`) — the wrapper loads the 
downloaded CLI jar into its own JVM via `URLClassLoader`, so it needs the same 
grant
   
   This bakes the flag into both the POSIX and Windows scripts shipped in the 
distributions.
   
   ### Verification
   
   - Generated all four start scripts; each now contains 
`DEFAULT_JVM_OPTS='"--enable-native-access=ALL-UNNAMED"'` (and the `.bat` 
equivalent).
   - Assembled a dist layout (`bin/grails` + 
`lib/grails-cli-8.0.0-SNAPSHOT-all.jar`) and ran `grails --version` on JDK 
25.0.3: no warnings.
   - Control run of the same jar without the flag reproduces all four warnings.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to