Skip to content

Terminally deprecated method warnings appearing in application startup logs #4610

@petergphillips

Description

@petergphillips

Expected behavior

No warnings appearing in logs on application startup

Actual behavior

We receive the following warnings

WARNING: A terminally deprecated method in sun.misc.Unsafe has been called
WARNING: sun.misc.Unsafe::objectFieldOffset has been called by net.bytebuddy.dynamic.loading.ClassInjector$UsingUnsafe$Dispatcher$CreationAction (file:/app/agent.jar)
WARNING: Please consider reporting this to the maintainers of class net.bytebuddy.dynamic.loading.ClassInjector$UsingUnsafe$Dispatcher$CreationAction
WARNING: sun.misc.Unsafe::objectFieldOffset 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:/app/agent.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

To Reproduce

These warnings have only started appearing since we switched from Java 21 to Java 25.
They appear on any Spring Boot application at startup using the java agent (see https://learn.microsoft.com/en-us/azure/azure-monitor/app/java-spring-boot#enabling-with-jvm-argument).

So one of my previous PRs (microsoft/ApplicationInsights-Java-Repros#15) is sufficient to show the issue. Assembling the jar file and then running

java -Dapplicationinsights.connection.string=<connection string> -javaagent:<path to agent>/applicationinsights-agent-3.7.7.jar -jar build/libs/gradle-0.0.1-SNAPSHOT.jar

will do the trick.

System information

Please provide the following information:

  • SDK Version: 25
  • OS type and version: We run eclipse-temurin:25-jre-jammy, but any should replicate. Also replicated on MacOS Tahoe.
  • Application Server type and version (if applicable): Spring Boot 4
  • Using spring-boot? Yes
  • Additional relevant libraries (with version, if applicable):

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions