jamesfredley commented on code in PR #15417:
URL: https://github.com/apache/grails-core/pull/15417#discussion_r2835660466


##########
grails-gradle/plugins/src/main/groovy/org/grails/gradle/plugin/core/GrailsGradlePlugin.groovy:
##########
@@ -597,6 +601,74 @@ class GrailsGradlePlugin extends GroovyPlugin {
         }
     }
 
+    /**
+     * Configures JVM arguments required for compatibility with Java 23+.
+     *
+     * <p>Java 24 introduced restrictions on native access ({@code JEP 472}) 
that cause
+     * warnings from libraries such as hawtjni (used by JLine) and Netty that 
call
+     * {@code System.loadLibrary} or declare native methods. The
+     * {@code --enable-native-access=ALL-UNNAMED} flag suppresses these 
warnings and
+     * will become mandatory in a future JDK release when the default changes 
to deny.</p>
+     *
+     * <p>Java 23 began terminal deprecation of {@code sun.misc.Unsafe} 
memory-access
+     * methods ({@code JEP 471/498}). Netty 4.1.x uses {@code 
Unsafe.allocateMemory}
+     * for off-heap buffers. The {@code --sun-misc-unsafe-memory-access=allow} 
flag
+     * suppresses the resulting warnings until Netty migrates to {@code 
MemorySegment}
+     * APIs (Netty 4.2+).</p>
+     *
+     * <p>Both flags are only added when the target JVM version (from the 
configured
+     * toolchain, or the JVM running Gradle if no toolchain is set) is high 
enough to
+     * recognize them, avoiding {@code Unrecognized option} errors on older 
JDKs.</p>
+     *
+     * @param project the Gradle project
+     * @see <a 
href="https://github.com/apache/grails-core/issues/15216";>#15216 - Java 25 
native access warnings</a>
+     * @see <a 
href="https://github.com/apache/grails-core/issues/15343";>#15343 - 
sun.misc.Unsafe deprecation warnings</a>
+     * @since 7.0.8
+     */
+    protected void configureJavaCompatibilityArgs(Project project) {
+        project.afterEvaluate {

Review Comment:
   plugins.withId('java') fires at plugin application time, before the user's 
build.gradle sets the toolchain, but looking at a solution without 
afterEvaluate 



-- 
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