[foreign-memaccess] [Rev 01] RFR: JDK-8243284: Remove Foreign class

Maurizio Cimadamore maurizio.cimadamore at oracle.com
Wed Apr 22 15:06:32 UTC 2020


>
> That's fine. I wasn't suggesting the large static method be removed 
> but rather add overrides to the big one:
>
>
> static MemorySegment ofNativeUnsafe(MemoryAddress addr, long 
> bytesSize, AutoCloseable cleanup)
>
> {
>
>     return ofNativeUnsafe(addr, byteSize, null, cleanup, null);
>
> }
>
>
> No *real* functionality here is being duplicated nor is anything being 
> lost. The JDK already provides overrides like this throughout its many 
> APIs. List has about a dozen.


Message understood. But please understand that List is not an unsafe API.

What we're trying to do here is fundamentally new for the JDK. The JDK 
had, in the past, ways to create e.g. custom byte buffer from random 
addresses (from JNI code). Panama is all about writing what you would 
otherwise do in native code in Java, so it makes sense to provide an 
equivalent capability as a Java API.

The problem is that, by necessity, this API is not safe. Same holds for 
SystemABI.

This means that not all methods in the foreign API are created equal. 
I'd first like to focus on a _single_ method, as we move through 
integrating the second round of API into upstream, and see what are the 
review comments and the CSR comments. It might be that we will have to 
tweak or adjust some aspects re. how these methods are made available.

Until these more important issues are fleshed out in full, I think it's 
premature to talk about convenience overloads.

Maurizio




More information about the panama-dev mailing list