I get the following errors when upgrading to Java 24, with my Spring Boot Webflux application
Is this normal, or a development point?
WARNING: A terminally deprecated method in sun.misc.Unsafe has been called
WARNING: sun.misc.Unsafe::allocateMemory has been called by io.netty.util.internal.PlatformDependent0$2 (file:/Users/sachin/.gradle/caches/modules-2/files-2.1/io.netty/netty-common/4.1.119.Final/2f7c360b03c0aceab7efc1f7c2b75274f0f35909/netty-common-4.1.119.Final.jar)
WARNING: Please consider reporting this to the maintainers of class io.netty.util.internal.PlatformDependent0$2
WARNING: sun.misc.Unsafe::allocateMemory will be removed in a future release
WARNING: A restricted method in java.lang.System has been called
WARNING: java.lang.System::loadLibrary has been called by io.netty.util.internal.NativeLibraryUtil in an unnamed module (file:/Users/sachin/.gradle/caches/modules-2/files-2.1/io.netty/netty-common/4.1.119.Final/2f7c360b03c0aceab7efc1f7c2b75274f0f35909/netty-common-4.1.119.Final.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
plugins {
id("org.springframework.boot") version "3.4.5"
id("io.spring.dependency-management") version "1.1.7"
kotlin("jvm") version "2.2.0-RC"
kotlin("plugin.spring") version "2.2.0-RC"
// id("org.graalvm.buildtools.native") version "0.10.2"
}
group = "com.myapp"
version = "0.0.1-SNAPSHOT"
java {
sourceCompatibility = JavaVersion.VERSION_24
}
kotlin {
compilerOptions {
freeCompilerArgs.addAll("-Xjsr305=strict")
jvmTarget = JvmTarget.JVM_24
}
}
// Configuration for the 'bootRun' task
tasks.withType<BootRun> {
// Set JVM arguments for running the application via 'gradle bootRun'
jvmArgs = listOf(
"--enable-native-access=ALL-UNNAMED",
// --- Garbage Collector Selection ---
// Choose ONE of the following GC options. G1 is often the default.
// Shenandoah GC (Low Pause Time) - Requires JDK 11+
"-XX:+UseShenandoahGC",
// G1 GC (Default in many recent JDKs, good balance)
// "-XX:+UseG1GC",
// ZGC (Low Pause Time, Scalable) - Requires JDK 11+
// "-XX:+UseZGC",
// --- Memory Settings (Example) ---
// Set initial and maximum heap size. Adjust values as needed.
"-Xms512m", // Initial heap size
"-Xmx2048m", // Maximum heap size
// --- Other Potential Flags (Use with caution and testing) ---
// Example: Enable String Deduplication (for G1 GC, reduces heap usage for duplicate Strings)
// "-XX:+UseStringDeduplication",
// Example: Aggressive Optimizations (can sometimes be unstable)
// "-XX:+AggressiveOpts",
// Example: GC Logging (useful for tuning/debugging)
// Modern format (JDK 9+)
"-Xlog:gc*:file=build/gc-bootrun.log:time,level,tags:filecount=5,filesize=10m"
// Older format
// "-XX:+PrintGCDetails",
// "-XX:+PrintGCDateStamps",
// "-Xloggc:build/gc-bootrun.log",
// "-XX:+UseGCLogFileRotation",
// "-XX:NumberOfGCLogFiles=5",
// "-XX:GCLogFileSize=10M",
)
// Ensure you are running with a Java 24+ JDK for bootRun
javaLauncher = javaToolchains.launcherFor {
languageVersion = JavaLanguageVersion.of(24)
}
}
Comment From: wilkinsona
This has nothing to do with Spring Boot. It's a general warning produced by Java 24 when code uses sun.misc.Unsafe
or java.lang.System
. Before opening an issue, please take the time to read the warning message which says "please consider reporting this to the maintainers of class io.netty.util.internal.PlatformDependent0$2".