RFR: 8298658: Platform-specific type leaks to platform independent code.

Alfonso² Peterssen duke at openjdk.org
Thu Jan 26 23:58:01 UTC 2023


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`.

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

Commit messages:
 - Avoid leaking implementation types to platform-independent code.

Changes: https://git.openjdk.org/jdk/pull/11674/files
 Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=11674&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8298658
  Stats: 8 lines in 4 files changed: 4 ins; 0 del; 4 mod
  Patch: https://git.openjdk.org/jdk/pull/11674.diff
  Fetch: git fetch https://git.openjdk.org/jdk pull/11674/head:pull/11674

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


More information about the nio-dev mailing list