JDK-8298476 : Unseal FinalReference
  • Type: Enhancement
  • Component: core-libs
  • Sub-Component: java.lang
  • Priority: P4
  • Status: Closed
  • Resolution: Won't Fix
  • Submitted: 2022-12-09
  • Updated: 2022-12-14
  • Resolved: 2022-12-14
Related Reports
Relates :  
Description
The change in JDK-8283415 made use of the now available sealed keyword for FinalReference<T>.
Unfortunately this introduced a problem for the Espresso VM (Java on Truffle): Since Espresso is written in Java it uses the functionality of the "Host VM" to implement finalization. We do that however by introducing a new subclass of FinalReference<T> [1] which does not work anymore with the changes made in JDK-8283415. We cannot use Finalizer itself because we want to inject an additional "Guest object".
Making FinalReference<T> non-sealed would simplify things for Espresso.
[1] https://github.com/oracle/graal/blob/f195395329fba573afc6f81c5e70a18ac334dd10/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/ref/ClassAssembler.java#L85-L113
Comments
Yes indeed, this only worked by injecting a public subclass of FinalRefernce in java.lang.ref (see [2]). I understand that FinalReference is an internal class, and I acknowledge that it's a somewhat odd request. [2] https://github.com/oracle/graal/blob/f195395329fba573afc6f81c5e70a18ac334dd10/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/ref/ClassAssembler.java#L50-L62
09-12-2022

FinalReference is JDK internal class and not a supported interface. I assume Espresso must be injecting a class j.l.ref for this to have every worked.
09-12-2022

A pull request was submitted for review. URL: https://git.openjdk.org/jdk/pull/11610 Date: 2022-12-09 14:17:24 +0000
09-12-2022