[foreign-memaccess] RFR 8224993: Add Unsafe support for MemoryAddress (again)
Maurizio Cimadamore
maurizio.cimadamore at oracle.com
Thu May 30 20:08:54 UTC 2019
The way I see this, is that we need some place where to put potentially
unsafe API points.
jdk.internal is not an acceptable answer, as that's clearly a
non-exported module.
sun.misc.Unsafe is not great either, as that's something that we want to
discourage - but it's the only vehicle we've got right now, so I'm not
too worried about having it there, since this is still a prototype.
Moving forward I have some ideas on how to do this more cleanly (clearly
this is a problem that will show up again, and magnified, once we start
talking SystemABI). The basic idea is to put the unsafe parts of the API
in a separate module (e.g. jdk.foreign.unsafe) and mark that module as
'non resolvable by default', which means that developers can only 'see'
that module if they pass an explicit flag to javac/jvm (--add-modules).
This seems like a robust way to add unsafe functionalities, as there
will be a clear opt-in from the user. Whether this is a viable
alternative, time will tell - we're in the process of discussing these
points internally.
Maurizio
On 30/05/2019 19:10, Jorn Vernee wrote:
> Thanks, I understood it so far. But, I was wondering if new APIs
> should be added to sun.misc.Unsafe as well. sun.misc.Unsafe didn't for
> instance get the rename from get/setObjectXXX to get/setReferenceXXX
> either.
>
> From what I understood, sun.misc.Unsafe is only there to allow code
> that relied on it previously to keep working under Java 9+, since
> there is currently no public alternative for some of the
> functionality. But, in general we'd want to discourage use of
> sun.misc.Unsafe since it's an internal API.
>
> Jorn
>
> Maurizio Cimadamore schreef op 2019-05-30 19:12:
>> My understanding is that sun.misc.Unsafe is available via the
>> jdk.unsupported module - which people can rely upon when writing
>> modular code. The jdk.internal Unsafe is just not exported, so you
>> will have to burst through module boundary checks in order to access
>> it from outside the JDK.
>>
>> Maurizio
>>
>> On 30/05/2019 17:09, Jorn Vernee wrote:
>>> I wanted to ask about the addition of the APIs to sun.misc.Unsafe
>>> last time, but got side-tracked by the test build error and then
>>> forgot :/. I had assumed sun.misc.Unsafe would not be updated going
>>> forward? What's the policy on this?
More information about the panama-dev
mailing list