From pm at goldmensch.dev Tue Jul 8 03:30:35 2025 From: pm at goldmensch.dev (Goldmensch) Date: Tue, 08 Jul 2025 03:30:35 +0000 Subject: Locally enabled preview features Message-ID: Hi folks! I?m wondering if the idea of ?locally? enabled preview features came up yet. It would make it possible to enable certain preview features for a class, package or module by annotating it for example. Doing so would allow to use preview features much easier in production to test them, while keeping the usage ?scope? small so that changes can be easily integrated without risking the integrity of the codebase. Of course some feature like virtual threads (by the time they were in preview) could not be enabled in such way due to the consequences to ?non preview enabled code? but flexible constructor bodies, module import declarations, perhaps even scoped values and much more could be. Was this idea ever considered yet and if yes, what are the points against it? Best regards, Nick Hensel -------------- next part -------------- An HTML attachment was scrubbed... URL: From forax at univ-mlv.fr Tue Jul 8 09:05:55 2025 From: forax at univ-mlv.fr (Remi Forax) Date: Tue, 8 Jul 2025 11:05:55 +0200 (CEST) Subject: Locally enabled preview features In-Reply-To: References: Message-ID: <1353378114.37870818.1751965555884.JavaMail.zimbra@univ-eiffel.fr> > From: "Goldmensch" > To: "amber-dev" > Sent: Tuesday, July 8, 2025 5:30:35 AM > Subject: Locally enabled preview features > Hi folks! > I?m wondering if the idea of ?locally? enabled preview features came up yet. It > would make it possible to enable certain preview features for a class, package > or module by annotating it for example. Doing so would allow to use preview > features much easier in production to test them, while keeping the usage > ?scope? small so that changes can be easily integrated without risking the > integrity of the codebase. Of course some feature like virtual threads (by the > time they were in preview) could not be enabled in such way due to the > consequences to ?non preview enabled code? but flexible constructor bodies, > module import declarations, perhaps even scoped values and much more could be. > Was this idea ever considered yet and if yes, what are the points against it? It was considered and rejected. The preview mechanism has to be rough / raw, so it conveys the fact that there is no guarantee of backward compatibility from a release to the next one. Also, the implementation of a feature may change from one version to the next, a feature can be implemented as only a javac change in one version and as a bytecode change in the next version, so the notion of "scope" of a feature does not really exist. > Best regards, > Nick Hensel regards, R?mi -------------- next part -------------- An HTML attachment was scrubbed... URL: From davidalayachew at gmail.com Tue Jul 8 11:47:51 2025 From: davidalayachew at gmail.com (David Alayachew) Date: Tue, 8 Jul 2025 07:47:51 -0400 Subject: Locally enabled preview features In-Reply-To: <1353378114.37870818.1751965555884.JavaMail.zimbra@univ-eiffel.fr> References: <1353378114.37870818.1751965555884.JavaMail.zimbra@univ-eiffel.fr> Message-ID: To add onto that, having the option as a commandline makes it 100% unavoidable for the person running the code to know that they are running preview code. That's the entire point of making it a CLI option vs an annotation -- so that the person running the code can be made aware of the risk. On Tue, Jul 8, 2025, 5:06?AM Remi Forax wrote: > > > ------------------------------ > > *From: *"Goldmensch" > *To: *"amber-dev" > *Sent: *Tuesday, July 8, 2025 5:30:35 AM > *Subject: *Locally enabled preview features > > Hi folks! > I?m wondering if the idea of ?locally? enabled preview features came up > yet. It would make it possible to enable certain preview features for a > class, package or module by annotating it for example. Doing so would allow > to use preview features much easier in production to test them, while > keeping the usage ?scope? small so that changes can be easily integrated > without risking the integrity of the codebase. Of course some feature like > virtual threads (by the time they were in preview) could not be enabled in > such way due to the consequences to ?non preview enabled code? but flexible > constructor bodies, module import declarations, perhaps even scoped values > and much more could be. > > Was this idea ever considered yet and if yes, what are the points against > it? > > > It was considered and rejected. > > The preview mechanism has to be rough / raw, so it conveys the fact that > there is no guarantee of backward compatibility from a release to the next > one. > > Also, the implementation of a feature may change from one version to the > next, a feature can be implemented as only a javac change in one version > and as a bytecode change in the next version, so the notion of "scope" of a > feature does not really exist. > > > Best regards, > Nick Hensel > > > regards, > R?mi > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From chen.l.liang at oracle.com Tue Jul 8 14:03:58 2025 From: chen.l.liang at oracle.com (Chen Liang) Date: Tue, 8 Jul 2025 14:03:58 +0000 Subject: Locally enabled preview features In-Reply-To: References: Message-ID: I think there are something related to your problem - the multi-release jars do attempt to increase integration with different feature sets, and in fact, JLS requires class files that is compiled with --enable-preview but did not make use of any preview features to have their minor version set to 0. So to control the scope, I think either using multiple compilation (multiple source sets) or checking the minor version in class files to determine the scope works. As to your proposal - you see others have already listed a few arguments against it, and it is not the only way to address your problem. I hope the two existing solutions I listed above can somewhat alleviate the problem you face. Regards, Chen ________________________________ From: amber-dev on behalf of Goldmensch Sent: Monday, July 7, 2025 10:30 PM To: amber-dev at openjdk.org Subject: Locally enabled preview features Hi folks! I?m wondering if the idea of ?locally? enabled preview features came up yet. It would make it possible to enable certain preview features for a class, package or module by annotating it for example. Doing so would allow to use preview features much easier in production to test them, while keeping the usage ?scope? small so that changes can be easily integrated without risking the integrity of the codebase. Of course some feature like virtual threads (by the time they were in preview) could not be enabled in such way due to the consequences to ?non preview enabled code? but flexible constructor bodies, module import declarations, perhaps even scoped values and much more could be. Was this idea ever considered yet and if yes, what are the points against it? Best regards, Nick Hensel -------------- next part -------------- An HTML attachment was scrubbed... URL: