RFR: 8298658: Platform-specific type leaks to platform independent code.
Alfonso² Peterssen
duke at openjdk.org
Tue Jan 31 13:53:57 UTC 2023
On Wed, 14 Dec 2022 13:37:32 GMT, Alfonso² Peterssen <duke at openjdk.org> wrote:
> This is not a cosmetic change, it enforces the isolation of platform-specific code from the user-facing API.
>
> `sun.nio.fs.DefaultFileSystemProvider#instance()` has a platform-specific return type. This makes the platform-independent `java.nio.file.FileSystems.DefaultFileSystemHolder#getDefaultProvider()` have a platform-dependent call e.g. INVOKESTATIC with different signatures.
>
> The platform-specific return types were introduced in [JDK-8213406](https://bugs.openjdk.org/browse/JDK-8213406), the common SPI type was used before. There's no reason to leak types to platform-independent code, except for tests, which could just cast.
>
> This change is motivated by [Espresso](https://github.com/oracle/graal/tree/master/espresso), a meta-circular, spec-compliant JVM written in Java. Espresso aims to provide a custom Java IO/NIO implementation on top of any vanilla JDK as a viable alternative to the imminent removal of `SecurityManager`.
"java.nio.file.spi.DefaultFileSystemProvider" is an application level option, we aim to virtualize the IO for the whole VM.
We've already virtualized legacy `java.io` APIs and most of NIO, thanks to the clean separation of platform-dependent code.
"Virtualize" here means re-implementing the Java APIs against Truffle APIs.
Once the SecurityManager is gone, Espresso could be a viable alternative.
-------------
PR: https://git.openjdk.org/jdk/pull/11674
More information about the nio-dev
mailing list