sun.nio.ch.DirectBuffer and jdk9/jigsaw
Alan Bateman
Alan.Bateman at oracle.com
Wed Feb 22 13:57:19 UTC 2017
On 22/02/2017 13:46, Vitaly Davidovich wrote:
> Hi all,
>
> What's the status of this interface with respect to Java 9 (and beyond)? It
> wasn't added to the critical API list of JEP 260, and thus requires an
> addExports flag to grant access. I have a use case where just the
> address() method is used in performance sensitive code. Previously, the
> code had used a JNI call to get the address of a DirectByteBuffer, but
> address() has superior performance particularly because the JIT
> devirtualizes all callsites I have (they only see DBB as receivers of this
> call).
>
> So, has the fate of this interface been decided? Am I stuck with addExports
> for Java 9? Is there a medium/long term replacement? Just to reiterate, I'd
> like access to the address() with as little fuss as possible, and don't
> care about the attachment() and cleaner() methods on it.
>
> Also, let me know if this best addressed to the nio-dev mailing list - it
> *is* an NIO class, but my question is really geared towards working with
> this interface in the modular/jigsaw world.
>
This interface has always been JDK-internal and has never been
documented/supported. If you have something accessing the memory
directly then maybe it would be better if you looked after the
allocation/deallocation yourself and use NewDirectByteBuffer to wrap the
regions that you need for I/O operations.
-Alan
More information about the jigsaw-dev
mailing list