RFR: 8282722: Regard mapping array in enum switches as stable for constant folding

Joshua Zhu jzhu at openjdk.java.net
Wed Mar 9 13:13:03 UTC 2022


On Tue, 8 Mar 2022 16:29:56 GMT, Paul Sandoz <psandoz at openjdk.org> wrote:

> Unfortunately the `@Stable` annotation can only be used by classes in the `java.base` module and other select modules. It cannot be used generally by application code given its unsafe nature.
> 
> We need read-only/frozen/constant arrays to do this properly in code outside of the JDK.
> 
> Perhaps there is a clever alternative strategy javac could use, e.g. using a bootstrap method although nothing specific comes to mind at this moment. I would hold off on that until the code generation strategy for patterns in switch settles down.

Got it. Paul, thanks for your detailed explanation.
As you suggested, I made a change in VectorAPI.

-------------

PR: https://git.openjdk.java.net/jdk/pull/7721


More information about the hotspot-dev mailing list