Preview APIs in the Java Platform

Maurizio Cimadamore maurizio.cimadamore at oracle.com
Thu Mar 5 18:47:41 UTC 2020


On 03/03/2020 21:15, Alex Buckley wrote:
> I intend to update JEP 12 to incorporate preview APIs in the near 
> future, hopefully in time for 15 so that projects such as Panama can 
> benefit from them. 

Thanks for looking at this Alex.

During the development of JEP 370 (memory access API [1]) we ran into 
some issues when trying to make the API fit in the (rather strict) 
incubating module rules. While using the memory access API is relatively 
easy (an --add-modules "jdk.incubator.foreign" will do the trick) the 
number of hacks we had to put in place in order to make the whole thing 
work was, I think, rather unfortunate. The main issue we faced is that, 
at its core, the memory access API adds a new kind of VarHandle - and 
all the logic for dealing with VarHandles is in java.base - but since 
incubating APIs had to live in their own separate module, we had to find 
ways to "split" the API and to create proxy interfaces [2] which 
java.base could then use in order to workaround the fact that the memory 
access API is defined in a module which is not available (for obvious 
reasons) from java.base.

Now, sometimes these hacks just result in a less-than-ideal 
implementation  - e.g. where the code is more cluttered than we'd like; 
but in the case of Panama we ran into actual performance bottlenecks [3] 
whose root cause was, precisely, the fact that we had to split the API 
into two pieces.

So I welcome any change which (a) brings Java SE API at the same level 
as the language and VM features (by allowing such APIs to also be 
'preview') and (b) allows development of future APIs not go through the 
twist and turns we had to go through when developing the memory access API.

Cheers
Maurizio

[1] - https://openjdk.java.net/jeps/370
[2] - 
http://hg.openjdk.java.net/jdk/jdk/file/fbbcf9125cef/src/java.base/share/classes/jdk/internal/access/foreign
[3] - https://bugs.openjdk.java.net/browse/JDK-8237349



More information about the jdk-dev mailing list