Java 9中的JavaLangAccess和SharedSecrets [英] JavaLangAccess and SharedSecrets in Java 9

查看:66
本文介绍了Java 9中的JavaLangAccess和SharedSecrets的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

似乎从Java 9中删除了sun.misc包中的SharedSecretsJavaLangAccess类.

It seems like the SharedSecrets and JavaLangAccess classes from the sun.misc package were removed in Java 9.

Java 9中是否有这些类提供的功能的替代品?

Are there any replacements in Java 9 for the functionality provided by these classes?

推荐答案

以上两个类均打包在jdk.internal.misc包中.

Both the above classes are packaged in jdk.internal.misc package.

尝试访问它们的一种方法是使用选项

One way you can try and access them is by using the option

--add-exports <source-module>/<package>=<target-module>(,<target-module>)*

用于您的用例:

--add-exports java.base/jdk.internal.misc=your.module

注意 :-来自的免责声明 JEP-261:模块系统 -

必须很好地使用--add-exports--add-opens选项 关心.您可以使用它们来访问库的内部API 模块,甚至JDK本身,但您需要自担风险:如果 内部API被更改或删除,然后您的库或 应用程序将失败.

The --add-exports and --add-opens options must be used with great care. You can use them to gain access to an internal API of a library module, or even of the JDK itself, but you do so at your own risk: If that internal API is changed or removed then your library or application will fail.

这篇关于Java 9中的JavaLangAccess和SharedSecrets的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆