RFR: 8253590: java/foreign tests are still failing on x86_32 after foreign-memaccess integration
Maurizio Cimadamore
mcimadamore at openjdk.java.net
Mon Sep 28 20:21:38 UTC 2020
This patch addresses a problem in a couple of tests for the foreign memory access API; we have two methods in the API,
namely `MemorySegment::asByteBuffer` and `MemorySegment::toByteArray` which should throw an exception if invoked on a
segment whose size is bigger than Integer.MAX_VALUE. The problem is that on 32-bits platform is not really possible to
allocate a segment bigger than that; for that reason, at some point during 14 we "fixed" this by tweaking the test to
allocate so much memory that the allocation itself would fail.
When we integrated the latest API changes, this dubious fix was reverted, and now the tests have started misbehaving
again. A much better solution is not to rely on allocation; the two tests should just create a synthetic segment using
`MemorySegment::ofNativeRestricted`; this way we can test that the API throws when it should, w/o being impacted by
what Unsafe does, or does not support on 32-bits platforms.
-------------
Commit messages:
- Improve robustness of memory access tests by not relying on platform allocation size limits
Changes: https://git.openjdk.java.net/jdk/pull/386/files
Webrev: https://webrevs.openjdk.java.net/?repo=jdk&pr=386&range=00
Issue: https://bugs.openjdk.java.net/browse/JDK-8253590
Stats: 8 lines in 2 files changed: 2 ins; 1 del; 5 mod
Patch: https://git.openjdk.java.net/jdk/pull/386.diff
Fetch: git fetch https://git.openjdk.java.net/jdk pull/386/head:pull/386
PR: https://git.openjdk.java.net/jdk/pull/386
More information about the core-libs-dev
mailing list