This patch makes MemorySegment::ofBuffer more general, by allowing clients to 
pass *any* `Buffer` instance, not just `ByteBuffer`.
This allows us to match expressiveness of JNI API, where JNI clients can obtain 
the address of any direct buffer instance, using the `GetDirectBufferAddress` 
function.

We thought about also providing a more general way to view a segment as a 
buffer (e.g. asIntBuffer) but doing that doesn't seem worth it: direct buffers 
can only created form `ByteBuffer`.
So, to create a direct `IntBuffer`, clients have to first create a direct 
`ByteBuffer` then to view that buffer as an `IntBuffer`.

In other words, `IntBuffer` and friends are not first-class citizens in the 
`Buffer` API. As such it would not be possible to map many memory segments into 
an `IntBuffer`; in fact, the only segment we could safely map into an 
`IntBuffer` would be an _heap_ segment backed by an `int[]`. As such it doesn't 
seem worth adding a lot of API surface (in terms of additional overloads) for 
such a corner case.

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

Commit messages:
 - Tweak javadoc
 - Merge branch 'foreign-preview' into generalize_ofbuffer
 - Merge branch 'master' into foreign-preview
 - Merge branch 'master' into foreign-preview
 - Merge branch 'master' into foreign-preview
 - Fix crashes in heap segment benchmarks due to misaligned access
 - Merge branch 'master' into foreign-preview
 - Update src/java.base/share/classes/jdk/internal/reflect/Reflection.java
 - Initial push
 - Add tests for loaderLookup/restricted method corner cases
 - ... and 59 more: https://git.openjdk.java.net/jdk/compare/11fa03f3...02494e2f

Changes: https://git.openjdk.java.net/jdk/pull/8701/files
 Webrev: https://webrevs.openjdk.java.net/?repo=jdk&pr=8701&range=00
  Issue: https://bugs.openjdk.java.net/browse/JDK-8286715
  Stats: 95 lines in 8 files changed: 55 ins; 1 del; 39 mod
  Patch: https://git.openjdk.java.net/jdk/pull/8701.diff
  Fetch: git fetch https://git.openjdk.java.net/jdk pull/8701/head:pull/8701

PR: https://git.openjdk.java.net/jdk/pull/8701

Reply via email to