8273905: Foreign API refresh #576
Disclaimer: the proposed changes touch several areas of the APIs (in deep ways) which makes it hard (if not impossible) to break the changes apart into multiple PRs. Below is an attempt to describe the main areas affected by this PR.
The main change in this area is to attach carriers to
The new dereference methods are statically safe: it is not possible for clients to pass values to setters of the wrong type. We have used the same trick in different parts of the API, to make it more uniform and safer (see changes in
First, we have moved most of the
Some things have been removed as well; most notably, the platform-dependent layout constants, such as
Another thing we removed was the
The main change to memory layouts is the removal of the layout attribute mechanism. This mechanism was powerful, but also very prone to misuse; it was unfortunate that the whole linker classification story depended on it as well, as that meant that linker-related attributes were mixed in with user-defined ones. If needed, we might well re-introduce some form of user-defined attribute in the future (e.g. a
A minor change/simplification to the layout API is that obtaining a memory access var handle from a layout no longer requires a
You will notice that the
We decided to drop the concept of implicit scopes. After all, we already had the notion of confined/shared explicit scopes which were also backed by a cleaner. This is sufficient to cover the implicit cases too.
Another simplification we have done is in the acquire/release mechanism; you will notice that there's only one method now, called
Finally, we have tweaked the
I've ran the typos and grammar analyses already (so what you see should be already relatively polished). I will run some more to catch code issues.
* Fix spurious javadoc references to `MemoryLayouts` * Drop one more unused import * Add checks to `MemorySegment::copy`: array component should match layout carrier * Tweak exception thrown by `MemorySegment::copy` when an unsupported array is passed * Add simple negative tests to `TestArrayCopy`
* Fix javadoc of `UpcallStub` so that summary does not contain link. * Add `@throws IllegalArgumentException` on `ResourceScope::keepAlive` * Add `@throws IllegalStateException` on `ResourceScope::keepAlive` * Add resource scope test to check that keeping alive self is not allowed
Many thanks for testing this and confirming that there are no regressions!
On 18/09/2021 22:11, Uwe Schindler wrote:
@mcimadamore This change now passes all automated pre-integration checks.
After integration, the commit message for the final commit will be:
At the time when this comment was updated there had been 88 new commits pushed to the
As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details.
Going to push as commit 831e75b.
Your commit was automatically rebased without conflicts.