我刚刚试着用 Java9运行我的服务器,然后得到了下一个警告:
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by io.netty.util.internal.ReflectionUtil (file:/home/azureuser/server-0.28.0-SNAPSHOT.jar) to constructor java.nio.DirectByteBuffer(long,int)
WARNING: Please consider reporting this to the maintainers of io.netty.util.internal.ReflectionUtil
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
我想在启动时隐藏这个警告而不将 --illegal-access=deny
添加到 JVM 选项中,比如:
System.setProperty("illegal-access", "deny");
有什么办法吗?
所有相关的答案都建议使用 JVM 选项,我想从代码中关闭这个选项。这可能吗?
澄清一下,我的问题是关于从代码中转换这个警告,而不是通过类似问题中提到的 JVM 参数/标志。