[jdk16] RFR: 8259028: ClassCastException when using custom filesystem with wrapper FileChannel impl

Maurizio Cimadamore mcimadamore at openjdk.java.net
Wed Jan 6 16:16:07 UTC 2021


This patch tweaks `MemorySegment::mapFile` so that it will throw `IllegalArgumentException` whenever the path to be mapped is associated with a custom file system provider.

The check in the implementation is heavily borrowed by what `UnixDomainSocketAddress::of(Path)` does (thanks Alan for the tip!). Not only we have to check if file system is the default one, but also if the default FS belongs to java.base (since that can be overridden).

The test simply check that paths coming from the (internal) JRT file system are not supported by the factory.

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

Commit messages:
 - Tweak javadoc
 - Clarify javadoc of MemorySegment::mapFile w.r.t. custom file systems

Changes: https://git.openjdk.java.net/jdk16/pull/90/files
 Webrev: https://webrevs.openjdk.java.net/?repo=jdk16&pr=90&range=00
  Issue: https://bugs.openjdk.java.net/browse/JDK-8259028
  Stats: 22 lines in 3 files changed: 16 ins; 1 del; 5 mod
  Patch: https://git.openjdk.java.net/jdk16/pull/90.diff
  Fetch: git fetch https://git.openjdk.java.net/jdk16 pull/90/head:pull/90

PR: https://git.openjdk.java.net/jdk16/pull/90


More information about the core-libs-dev mailing list