JEP draft: Prepare to Restrict The Use of JNI

Volker Simonis volker.simonis at gmail.com
Thu Aug 24 14:04:34 UTC 2023


On Thu, Aug 24, 2023 at 6:45 AM Maurizio Cimadamore
<maurizio.cimadamore at oracle.com> wrote:
>
> Using a public, but not exported annotation is what I'm suggesting.

You mean like "jdk.internal.javac.PreviewFeature" which is exported as follows:

    exports jdk.internal.javac to
        java.compiler,
        jdk.compiler,
        jdk.incubator.vector, // participates in preview features
        jdk.jshell;

My question is why not making a "real" public like e.g
"java.lang.preview.PreviewFeature" but export it only to "java.*" such
that it can be documented properly in the API docs and also appears on
all the relevant classes/methods in the API doc?

>
> But note that external tools won't be able to retrieve this annotation reflectively (e.g. using Method::getAnnotation), because the annotation is not really "public".
>
> As for IDEs and external tools, it would be similar to how they handle preview features/API today (note also that, at the level of classfile processing - e.g. using the classfile API -  obviously you can see that an annotation is there).
>
> Maurizio
>
> On 24/08/2023 14:14, Volker Simonis wrote:
>
> I'm not a module expert but can't we create a public, documented
> annotation in a package which is only exported to the core JDK modules
> with the help of a qualified export?
>
> That said, an internal annotation like `@PreviewFeature` could be enough
> to provide javac support along the lines you describe.
>
> Yes, that would be enough for javac but not for IDEs and external tools.
>


More information about the jdk-dev mailing list