PreviewFeature on packages and modules

Alex Buckley alex.buckley at
Thu Feb 4 17:53:57 UTC 2021

On 2/4/2021 8:44 AM, Jan Lahoda wrote:
> On 03. 02. 21 23:58, Alex Buckley wrote:
>> In sum, there's a strong case for saying that everything in a preview 
>> module has preview status. (Where marking anything in the module with 
>> @PreviewFeature is legal but redundant.) This would be convenient for 
>> preview API designers, who could write @PreviewFeature once and have 
>> it trickle down.
>> I suspect this is either very painful to implement in javac/javadoc, 
>> or very easy. Jan, please tell us which! :-)
> Propagating the preview flag from module to (top-level, presumably) 
> classes seems to be fairly easy when compiling against classfiles. 
> Propagating the flag from packages to classes would be more difficult, 
> as the preview flag is commonly not read for packages - if we were to 
> change that, we would need start reading all package-info.class files, 
> with possible implications on performance.

Thanks Jan (and Jon). Propagating the preview flag from module to 
top-level classes is all that's required. I'm happy to cut packages out 
of the discussion completely, both for the reason you give and because 
package-level annotations were a mistake. (Sharp-eyed readers will 
notice that JLS no longer mentions "package" as a program 
element that can be deprecated.)  If an API designer wishes to preview a 
new package, then every top-level class in the package will need to be 
flagged @PreviewFeature. JEP 12 can document all this after implementation.


More information about the compiler-dev mailing list