# sun.misc.Unsafe memory access (JEP 498) and JNI (JEP 472): what does the JVM say?

$ java UnsafeWarning      (JDK 21)
    java.version = 21.0.12.1
    read back: 42

$ java UnsafeWarning      (JDK 25)
    java.version = 25.0.4.1
    WARNING: A terminally deprecated method in sun.misc.Unsafe has been called
    WARNING: sun.misc.Unsafe::allocateMemory has been called by UnsafeWarning (file:<repo>/build/lanes/us25/)
    WARNING: Please consider reporting this to the maintainers of class UnsafeWarning
    WARNING: sun.misc.Unsafe::allocateMemory will be removed in a future release
    read back: 42

$ java UnsafeWarning      (JDK 24, Corretto image)
    java.version = 24.0.2
    WARNING: A terminally deprecated method in sun.misc.Unsafe has been called
    WARNING: sun.misc.Unsafe::allocateMemory has been called by UnsafeWarning (file:/b/us21/)
    WARNING: Please consider reporting this to the maintainers of class UnsafeWarning
    WARNING: sun.misc.Unsafe::allocateMemory will be removed in a future release
    read back: 42

$ java JniWarning      (JDK 21)
    java.version = 21.0.12.1
    System.loadLibrary("net") returned
$ java --enable-native-access=ALL-UNNAMED JniWarning      (JDK 21)
    java.version = 21.0.12.1
    System.loadLibrary("net") returned

$ java JniWarning      (JDK 25)
    java.version = 25.0.4.1
    WARNING: A restricted method in java.lang.System has been called
    WARNING: java.lang.System::loadLibrary has been called by JniWarning in an unnamed module (file:<repo>/build/lanes/jni25/)
    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
    
    System.loadLibrary("net") returned
$ java --enable-native-access=ALL-UNNAMED JniWarning      (JDK 25)
    java.version = 25.0.4.1
    System.loadLibrary("net") returned

$ java JniWarning      (JDK 24, Corretto image)
    java.version = 24.0.2
    System.loadLibrary("net") returned
    WARNING: A restricted method in java.lang.System has been called
    WARNING: java.lang.System::loadLibrary has been called by JniWarning in an unnamed module (file:/b/jni21/)
    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
    
