mill icon indicating copy to clipboard operation
mill copied to clipboard

JDK 25 warning "A restricted method"

Open jackkoenig opened this issue 3 months ago • 3 comments

Using Mill 1.0.5 with the JVM client prints the following warning:

WARNING: A restricted method in java.lang.System has been called
WARNING: java.lang.System::load has been called by mill.launcher.JLineNativeLoader in an unnamed module (file:/path/to/mill/download/1.0.5)
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

jackkoenig avatar Sep 24 '25 02:09 jackkoenig

I got a similar but different warning

WARNING: java.lang.System::loadLibrary has been called by com.swoval.runtime.NativeLoader in an unnamed module (file:/Users/user/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/com/swoval/file-tree-views/2.1.12/file-tree-views-2.1.12.jar).

re-thc avatar Sep 26 '25 17:09 re-thc

Currently, we can ignore these warnings by adding following config in your mill module config

//| mill-jvm-opts: ["--enable-native-access=ALL-UNNAMED"]

// if your application has this warning, try to override forkArgs function
  def forkArgs = Seq(
    "--sun-misc-unsafe-memory-access=allow",
    "--enable-native-access=ALL-UNNAMED"
  )

dragove avatar Oct 20 '25 01:10 dragove

It you see these warning only sometimes, chances are, these come from a freshly starting Mill daemon process, which is stopping itself after some idle-time. To customize the flags of the JVM running the Mill deamon, you can use the mill-jvm-opts settings.

For the normal run tasks, you can run mill with the --debug option to see more logs. If that doesn't reveal the full command, you should be able to inspect the task in the IDE via normal code browsing features, starting in your local module definition.

lefou avatar Oct 20 '25 07:10 lefou