Migrating Java 1.8 version to Java 17

Viewed 104

While building the code getting package sun.security.action is not visible

Package sun.security.action is declared on module java.base, which does not export it to the unnamed module.

What should I do. Kindly advice, Thanks in advance

1 Answers

Java 8 had no module system - everything is visible or just needs to get imported by archives in jdk (f.e. tools.jar).

Java 9 brought JMS and encapsulated some jdk classes.
In your case, see <JAVA_HOME>/lib/src.zip!/java.base/module-info.class:

exports sun.security.action to
   java.desktop,
   java.security.jgss,
   jdk.crypto.ec,
   jdk.incubator.foreign;

Your package isn't public but restricted to some other internal packages/modules.
There was a workaround by adding compiler option --add-exports=java.base/sun.security.action=ALL-UNNAMED at compile time to fix this limitation until version 16.

With version 17 and JEP 403 forget all hope:

It is not a goal to define new standard APIs to replace internal elements for which standard replacements do not yet exist, though such APIs could be suggested in response to this JEP.

Backwards compatibility and important frameworks have lower priority than jdk security - JCP makes strange decisions and works against the community sometimes -.-

Related