JDK 17, released on September 14, 2021, stops the --illegal-access option from reopening access to the Java runtime's internal classes, methods and fields. Adding --illegal-access=permit to a launch command now produces a warning, not the old compatibility behavior. For enterprise application owners, the immediate migration job is to identify which code needs that access—including libraries supplied by someone else—rather than carry the same launch flag into the new runtime. [S1][S6]

JDK 16 had already made strong encapsulation the default while allowing an opt-out for older internal elements. JDK 17 makes that blanket opt-out ineffective. Encapsulation limits access across Java modules, including reflection, where running code reaches into another class's members. Successful compilation does not establish that those operations will work. OpenJDK's JEP 403 warns that the failure can come from a library or framework, even when the application itself uses no internal APIs. [S6]

OpenJDK recommends using jdeps to find dependencies on JDK internals and a separate runtime check on an existing release such as JDK 11. There, --illegal-access=warn reports illegal reflective accesses, --illegal-access=debug adds stack traces to locate the code, and --illegal-access=deny lets a maintainer test with that access blocked except where other options explicitly allow it. Those diagnostic modes need the older runtime: on JDK 17, warn, debug and deny are ineffective too. A migration test should exercise the application paths that invoke its libraries, rather than stop at a clean build. [S6]

The --add-opens launcher option, or an Add-Opens attribute in a JAR-file manifest, can still open specific packages. Where a team needs that temporary relief, a useful maintenance record would name the package, the dependency requiring it and the replacement to test. The opening permits access; it does not remove the code's reliance on internal implementation details. [S6]

For some failures, JEP 403 points to a replacement API. Frameworks that reach into the protected defineClass methods of java.lang.ClassLoader to create classes in existing class loaders should use java.lang.invoke.MethodHandles.Lookup::defineClass instead. That API has been available since JDK 9. An application maintainer using such a framework should first look for an updated component; OpenJDK recommends upgrading dependencies that still rely on internal elements. [S6]

Critical internal APIs such as sun.misc.Unsafe remain available under JEP 403. The sun.misc and sun.reflect packages stay exported and open through the jdk.unsupported module. That is a specific exception, not permission to reach into unrelated packages or an assurance that every individual Unsafe method is unchanged. [S6]

Source documents

  1. OpenJDK: JDK 17 release and schedulehttps://openjdk.org/projects/jdk/17/
  2. JEP 403: complete July 27, 2021 description from official change historyhttps://bugs.openjdk.org/browse/JDK-8263547