问题描述
运行程序时控制台输出以下警告信息:
WARNING: A restricted method in java.lang.System has been called
WARNING: java.lang.System::load has been called by com.intellij.rt.execution.application.AppMainV2 in an unnamed module
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
解决方案
- 在 IntelliJ IDEA 菜单栏中选择 Run > Edit Configurations...。
- 在左侧配置列表中找到对应的 Application 项。
- 点击右侧的 Modify options,勾选 Add VM options。
- 在 VM options 文本框中输入以下内容:
--enable-native-access=ALL-UNNAMED
--add-opens java.base/java.lang=ALL-UNNAMED
- 点击 Apply 和 OK 保存设置。
- 重新运行程序,警告提示将消失。

