[foreign-preview] RFR: 8282476: Drop NativeSymbol [v2]

Maurizio Cimadamore mcimadamore at openjdk.java.net
Wed Mar 2 14:22:06 UTC 2022


> This change drops the `NativeSymbol` interface from the API, for the following reasons:
> 
> * A `NativeSymbol` is essentially a `MemorySegment` w/o a length - following JDK-8280460, zero-length memory segment are better supported and can be used instead.
> 
> * Whenever the API takes a `NativeSymbol` (e.g. in linker downcall handles) we can take `Addressable` and have a more flexible API
> 
> * The extra level of safety added by `NativeSymbol` was questionable for such a low level API. The only difference between a `NativeSymbol` and a `MemorySegment` is the fact that the former does not support slicing and dereference. But the same is true for a zero-length segment. Also, while `NativeSymbol` made it harder for developers to pass wrong types to linker method handles (e.g. a `VaList`), it is still possible to unsafely wrap bad data into a `NativeSymbol` (e.g. the API implementation won't really check that the address used to construct a new `NativeSymbol` is really that of a "symbol"). And, `NativeSymbol` also made it harder for developers to pass raw native addresses to the linker (such addresses needed to be wrapped into a symbol instead).
> 
> Ultimately, the concept of "symbol" was a bit too fuzzy: we came to it mostly because it made sense as a return type for lookups - but it doesn't ultimately add anything to the API, other than providing two different ways to do the same thing.

Maurizio Cimadamore has updated the pull request incrementally with one additional commit since the last revision:

  Address review comments
  * remove remaining references to native symbol in CLinker javadoc
  * improve javadoc of ClassLoader::findNative

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

Changes:
  - all: https://git.openjdk.java.net/panama-foreign/pull/658/files
  - new: https://git.openjdk.java.net/panama-foreign/pull/658/files/d849d6ad..10b6fb4c

Webrevs:
 - full: https://webrevs.openjdk.java.net/?repo=panama-foreign&pr=658&range=01
 - incr: https://webrevs.openjdk.java.net/?repo=panama-foreign&pr=658&range=00-01

  Stats: 9 lines in 2 files changed: 2 ins; 0 del; 7 mod
  Patch: https://git.openjdk.java.net/panama-foreign/pull/658.diff
  Fetch: git fetch https://git.openjdk.java.net/panama-foreign pull/658/head:pull/658

PR: https://git.openjdk.java.net/panama-foreign/pull/658


More information about the panama-dev mailing list