This article, JDK 9: Proposal to allow illegal reflective access by default, claims that the –permit-illegal-access option will be replaced by a more general option, –illegal-access.

–illegal-access=permit

–illegal-access=warn

–illegal-access=debug

–illegal-access=deny

➥ Did that happen? Is there a –illegal-access setting?

➥ How are these set? Arguments to launching the JVM?

➥ How does one get the current value during runtime?

解决方案

Did that happen? Is there a –illegal-access setting?

Yes, it appears that did happen—at least for OpenJDK/OracleJDK. The option is listed in the documentation for the java "tool".

It is also listed when executing java --help-extra.

Note: The JDK-11 documentation mentions this option will be removed in a future release.

How are these set? Arguments to launching the JVM?

Yes, it is a command-line option. Example:

java --illegal-access=deny --module-path --module / [args...]

How does one get the current value during runtime?

Unfortunately, I'm not aware of any way to query the value at runtime. It doesn't appear to be part of the system or environment properties. I tried finding where the value was used internally but was unable to (but to be honest I didn't spend too much time looking).

For convenience, here's the documentation of --illegal-access for JDK-11:

--illegal-access=parameter

When present at run time, --illegal-access= takes a keyword parameter to specify a mode of operation:

Note:

This option will be removed in a future release.

permit: This mode opens each package in each module in the run-time image to code in all unnamed modules ( such as code on the class path), if that package existed in JDK 8. This enables both static access, (for example, by compiled bytecode, and deep reflective access) through the platform's various reflection APIs. The first reflective-access operation to any such package causes a warning to be issued. However, no warnings are issued after the first occurrence. This single warning describes how to enable further warnings. This mode is the default for the current JDK but will change in a future release.

warn: This mode is identical to permit except that a warning message is issued for each illegal reflective-access operation.

debug: This mode is identical to warn except that both a warning message and a stack trace are issued for each illegal reflective-access operation.

deny: This mode disables all illegal-access operations except for those enabled by other command-line options, such as --add-opens. This mode will become the default in a future release.

The default mode, --illegal-access=permit, is intended to make you aware of code on the class path that reflectively accesses any JDK-internal APIs at least once. To learn about all such accesses, you can use the warn or the debug modes. For each library or framework on the class path that requires illegal access, you have two options:

If the component's maintainers have already released a fixed version that no longer uses JDK-internal APIs then you can consider upgrading to that version.

If the component still needs to be fixed, then you can contact its maintainers and ask them to replace their use of JDK-internal APIs with the proper exported APIs.

If you must continue to use a component that requires illegal access, then you can eliminate the warning messages by using one or more --add-opens options to open only those internal packages to which access is required.

To verify that your application is ready for a future version of the JDK, run it with --illegal-access=deny along with any necessary --add-opens options. Any remaining illegal-access errors will most likely be due to static references from compiled code to JDK-internal APIs. You can identify those by running the jdeps tool with the --jdk-internals option. For performance reasons, the current JDK does not issue warnings for illegal static-access operations.

java 判断值是否设置,获取Java中“-非法访问”设置的当前值相关推荐

  1. 练习2-6 编写一个函数setbits(x, p ,n, y),该函数返回对x执行下列操作后的结果值: 将x中从第p位开始的n个(二进制)位设置为y中最右边n位的值,x的其余各位保持不变。

    练习2-6 编写一个函数setbits(x, p ,n, y),该函数返回对x执行下列操作后的结果值: 将x中从第p位开始的n个(二进制)位设置为y中最右边n位的值,x的其余各位保持不变. 参考代码如 ...

  2. python字典修改键所对应值_python - 将键值替换为相同字典中与不同键对应的值

    我对Python脚本没有经验,但作为项目中的一项要求,我不得不构建代码,这是我遇到的问题 -python - 将键值替换为相同字典中与不同键对应的值 我有以下值的字典它来自一个UNIX脚本设置我已经在 ...

  3. 编写函数 int fac(int x)计算 x!的值。在主函数中输入 n 和 m 的值,通过调用函数 fac 计算m Cn 的值(要求分别用递归和非递归的方法编写函数 fac)

    编写函数 int fac(int x)计算 x!的值.在主函数中输入 n 和 m 的值,通过调用函数 fac 计算m Cn 的值(要求分别用递归和非递归的方法编写函数 fac) 递归: #includ ...

  4. ajax获取java session的值_jquery 怎么获取 ajax中的session值

    jquery 怎么获取 ajax中的session值 15 例如HttpContext.Current.Session["LogUserAccount"] = LogUserAcc ...

  5. java判断字符个数_使用Java判断字符串中的中文字符数量

    Java判断一个字符串str中中文的个数,经过总结,有以下几种方法(全部经过验证),可根据其原理判断在何种情况下使用哪个方法: 1. 1 char[] c =str.toCharArray();2 f ...

  6. java 判断非ascii字符_文件名中的JavaMail和非ASCII字符

    我可以在 JavaMail中发送具有非ascii文件名的附件,但我无法下载它们.我特意为那些文件名包含非ascii字符的附件获取java.io.FileNotFoundException. 仅供参考: ...

  7. java 字体名字_JAVA:获取系统中可用的字体的名字

    import java.awt.*; public class GetLocalFontFamily { public static void main(String[] agrs) { //获取系统 ...

  8. 【Java】使用lambda表达式获取list中所有对象的某个属性以及获取特定属性的某一个对象

    使用lambda表达式获取list中所有对象的某个属性以及获取特定属性的某一个对象 获取List中所有对象的某个属性 获取List中某个特定属性的对象 获取List中所有对象的某个属性 案例如下:获取 ...

  9. java判断jsonobject是否为空_javascript中如何判断json是否为空呢?

    摘要: 下文讲述javascript中判断Json为空的方法分享,如下所示: json在web开发中必不可少,常常用于web的数据交换,那么在json中如何判断json对象是否为空呢? 1.jquer ...

最新文章

  1. SPOJ ATOMS - Atoms in the Lab
  2. 太棒啦!PyCharm与Jupyter完美融合,Jupytext来啦!
  3. java tomcat监控_java-jvisualvm远程监控tomcat
  4. 车辆动力学及控制_道路自适应车辆动力学控制研究(127页)【附下载】
  5. 那传说中的P、NP以及NPC问题
  6. 选项卡TabPanel控件
  7. python 进程和线程
  8. word论文排版插件_教你如何用word快速搞定论文排版
  9. wireshark: there are no interfaces on which a capture can be done
  10. X86汇编语言从实模式到保护模式09:32位x86处理器编程架构
  11. 深度优先搜索(DFS)
  12. csgo躲猫猫模式显示服务器已满,csgo躲猫猫攻略大全
  13. Android 中文 API——android.widget合集(上)(20篇)
  14. TIF图片转bitmap的两种方式(C#)
  15. 考完试写一套新闻系统
  16. 关于数据库主键和外键(终于弄懂啦)
  17. 本地计算机的硬件基本配置信息,Windows7系统如何查看硬件的基本配置
  18. 我在汇才的亲身经历与感受
  19. 如何查询电脑本机出厂序列号
  20. 计算机系统要素 - 布尔逻辑/布尔运算构建ALU

热门文章

  1. 【codevs3304】水果姐逛水果店Ⅰ,线段树练习
  2. 英语中正式和休闲的打招呼_6
  3. python tornado websocket_Python Tornado实现WEB服务器Socket服务器共存并实现交互的方法...
  4. 合肥python招聘_2020年合肥京东方招聘官网招聘-合肥京东方招聘官网招聘求职信息-拉勾招聘...
  5. uniapp图片自适应_uni-app下input组件基于内容自适应宽度的实现
  6. python telnetlib详解 执行循环命令_Python3+telnetlib实现telnet客户端
  7. 高阶系统怎么用matlab降阶,高阶系统模型一种降阶方法.pdf
  8. ctf 改变图片高度_通过CRC32爆破修改图片的宽高 ctf-misc图片隐写
  9. 4 weekend110的hive入门
  10. HomeHack:黑客如何控制 LG 的 IoT 家用设备