Since I upgraded to JDK 25 I receive warnings from netty. Can't really find a way to suppress them.
this is my build.gradle:
plugins {
id 'java'
id 'war'
id 'org.springframework.boot' version '3.5.6'
id 'io.spring.dependency-management' version '1.1.7'
id "io.sentry.jvm.gradle" version "5.9.0"
}
group = 'XXX'
version = '0.0.1-SNAPSHOT'
java {
toolchain {
languageVersion = JavaLanguageVersion.of(25)
}
}
configurations {
compileOnly {
extendsFrom annotationProcessor
}
}
repositories {
mavenCentral()
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter-webflux' // WebClient support
implementation 'org.springframework.boot:spring-boot-starter-actuator'
implementation 'org.springframework.boot:spring-boot-starter-aop'
// Resilience4j dependencies
implementation 'io.github.resilience4j:resilience4j-spring-boot3:2.3.0'
implementation 'io.github.resilience4j:resilience4j-micrometer:2.3.0'
implementation 'io.micrometer:micrometer-registry-prometheus'
compileOnly 'org.projectlombok:lombok'
annotationProcessor 'org.projectlombok:lombok'
providedRuntime 'org.springframework.boot:spring-boot-starter-tomcat'
}
This is the warning:
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/admin/.gradle/caches/modules-2/files-2.1/io.netty/netty-common/4.1.127.Final/ada4ab671678f956e1cd5067ba94bc340af1d8bf/netty-common-4.1.127.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
Comment From: vulinh64
I think this will boil down to how Netty team will fix their usages of Unsafe's memory access methods (deprecated since JDK 23, expected to be removed in future JDK release) and replace them with VarHandles:
https://openjdk.org/jeps/471
https://openjdk.org/jeps/498
Comment From: wilkinsona
I'm not sure why you've reported this here. As described in the error message:
Please consider reporting this to the maintainers of class io.netty.util.internal.PlatformDependent0$2
this should be reported to the Netty team. Before doing so, please check their issue tracker for existing reports.
Comment From: krezovic
https://netty.io/wiki/java-24-and-sun.misc.unsafe.html#netty-41-and-unsafe
@wilkinsona is it worth pointing to the guide above and mentioning --sun-misc-unsafe-memory-access=allow
in Spring Boot 3 documentation?
Comment From: philwebb
@krezovic I don't think it belongs in our 4.x migration guide since we've not raised the JDK baseline. You'll get the same warning using Boot 3.x with Java 25.