JDK-8277244 : Release Note: JEP 416: Reimplement Core Reflection With Method Handles
  • Type: Sub-task
  • Component: core-libs
  • Sub-Component: java.lang:reflect
  • Affected Version: 18
  • Priority: P4
  • Status: Closed
  • Resolution: Delivered
  • Submitted: 2021-11-16
  • Updated: 2022-02-10
  • Resolved: 2022-02-10
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 18
18Resolved
Description
[JEP 416](https://openjdk.java.net/jeps/416) reimplements core reflection with method handles.   Code that depends upon highly implementation-specific and undocumented aspects of the existing implementation might be impacted. Issues that might arise include:
   - Code that inspects the internal generated reflection classes (such as, subclasses of `MagicAccessorImpl`) no longer works and must be updated.
   - Code that attempts to break the encapsulation and change the value of the private final `modifiers` field of `Method`, `Field` and `Constructor` class to be different from the underlying member might cause a runtime error. Such code must be updated.

To mitigate this compatibility risk, you can enable the old implementation as a workaround by using  `-Djdk.reflect.useDirectMethodHandle=false`.   We will remove the old core reflection implementation in a future release. The `-Djdk.reflect.useDirectMethodHandle=false` workaround will stop working at that point.