Preview APIs for preview features -- JDK 14+

Alex Buckley alex.buckley at oracle.com
Mon Aug 5 19:11:31 UTC 2019


On 8/5/2019 12:00 PM, Alan Bateman wrote:
> On 05/08/2019 11:23, Alex Buckley wrote:
>> To be clear: this proposal means there will be APIs in the Java SE 
>> Platform that can only be used when preview features are enabled -- 
>> just as there are already language features in the Platform that can 
>> only be used when preview features are enabled.
>>
> Just to double check my understanding: There is no run-time enforcement 
> and also no run-time filtering of methods for preview features when not 
> running with --enable-preview. The methods for preview features will be 
> discoverable (and usable) by reflection but that an untypical usage that 
> we shouldn't be concerned about.

Correct. This proposal is about strengthening the developer's awareness 
of incautious usage of associated APIs, by strengthening the 
compile-time story from a removal warning to an error. At run time, we 
do NOT propose to reject a class file referencing String::stripIndent 
when preview features are disabled; the checking would be heavyweight 
and could never account for reflective use. Again, the goal here is 
developer awareness when they read javadoc and write code.

Alex


More information about the jdk-dev mailing list