RFR: JDK-8298476: Unseal FinalReference<T>

Bernhard Urban-Forster burban at openjdk.org
Fri Dec 9 14:25:38 UTC 2022


The change in [JDK-8283415](https://bugs.openjdk.org/browse/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. It does that however by [introducing a new subclass of `FinalReference<T>`](https://github.com/oracle/graal/blob/f195395329fba573afc6f81c5e70a18ac334dd10/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/ref/ClassAssembler.java#L85-L113) 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. Before pursuing other more involved solutions I thought I would ask how strongly the maintainers of core-libs feel about such a change. Would that be okay? Are there any implications for the GC for such a change?

-------------

Commit messages:
 - JDK-8298476: Unseal FinalReference<T>

Changes: https://git.openjdk.org/jdk/pull/11610/files
 Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=11610&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8298476
  Stats: 1 line in 1 file changed: 0 ins; 0 del; 1 mod
  Patch: https://git.openjdk.org/jdk/pull/11610.diff
  Fetch: git fetch https://git.openjdk.org/jdk pull/11610/head:pull/11610

PR: https://git.openjdk.org/jdk/pull/11610


More information about the core-libs-dev mailing list