JEP draft: Prepare to Restrict The Use of JNI

Alex Buckley alex.buckley at oracle.com
Thu Aug 24 14:39:15 UTC 2023


On 8/24/2023 5:05 AM, Volker Simonis wrote:
> I think it is a little unfortunate that the specification of
> "Restricted Methods" is buried in the documentation of the
> java.lang.foreign package [1] which is "only" a preview feature. Apart
> from there it is mentioned neither in the Java Language Specification
> nor in the JVM specification (as far as I can see).
...
> [1] https://docs.oracle.com/en/java/javase/20/docs/api/java.base/java/lang/foreign/package-summary.html#restricted

That's not where "Restricted Methods" are specified. "Restricted 
Methods" are specified in the Java SE Platform Spec, and have been since 
Java SE 19. The mail of Maurizio's, to which you were replying, pointed 
to their specification in the latest Platform Spec:

https://cr.openjdk.org/~iris/se/21/spec/pr/java-se-21-pr-spec/index.html#Restricted-methods

The package specification of java.lang.foreign has a "Restricted 
methods" section designed to give users of the FFM API an understanding 
of what's restricted in the FFM API, and why, using FFM-specific terms, 
so they don't have to read the Platform Spec.

As to the question of whether restricted methods (or preview APIs) 
should have their declarations flagged in such a way that tools can 
discover them -- I can see how this would make tools more agile and lead 
to a better user experience in those tools, but we can't do everything 
at once, and our focus now is on the use of JNI.

Alex


More information about the jdk-dev mailing list