JEP 442: Foreign Function & Memory API => why is it again preview API?

Uwe Schindler uschindler at apache.org
Wed May 17 07:13:35 UTC 2023


Hi Remi,

thanks for the reponse!

>> yesterday Apache Lucene got the information that JDK 21 got the project
>> panama JEP 442 update and I implemented it already in our source tree.
>>
>> Unfortunately the API is again marked "preview", but JDK 21 is "LTS
>> release". Many of our users (Elasticserach, Solr) will be switching to
>> this version. We were really hoping that the java.lang.foreign API is
>> finished at that time. I checked the changes in our code: just a rename
>> of a method and FileChannel#map now takes Arena instead of Scope.
> I see that Alan and Maurizio have already answer to your other points.
>
> Having preview features and being a LTS are to separate concerns.
> Being a LTS is about support, having preview features is about having feedback before finalizing an API.
>
> Java 17 was released with preview features, Java 21 will be.

Yes that's the case. But Java 17 did not have any "runtime visible" 
preview features, only compiler had preview features. For public 
libraries out there (open source on Maven central like Lucene), people 
don't care how they are produced by a compiler. So enhanced switch 
statements or similar stuff is a bit different than the current problem 
where the preview features are visible at runtime.

Some related note: I don't understand why classes compiled with preview 
SYNTAX features of the Java compiler need to be marked with the preview 
bit; IMHO compiler outputs should only be marked as preview if they use 
preview APIs. There should be no risk in running the compiler output of 
preview switch or instanceof statements without preview features enabled.

Uwe

-- 
Uwe Schindler
uschindler at apache.org
ASF Member, Member of PMC and Committer of Apache Lucene and Apache Solr
Bremen, Germany
https://lucene.apache.org/
https://solr.apache.org/



More information about the core-libs-dev mailing list