JDK-8199194 : Add javac support for preview features
  • Type: Enhancement
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 11
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • Submitted: 2018-03-06
  • Updated: 2019-06-25
  • Resolved: 2018-04-12
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 11
11 b10Fixed
Related Reports
Blocks :  
Blocks :  
CSR :  
Relates :  
Relates :  
Relates :  
Description
# Class files

- With --enable-preview, every class file written by javac is a preview class file (minor_version is 65535). Without --enable-preview, every class file written by javac is not a preview class file (minor_version is 0).

- With --enable-preview, javac reads preview class files from the module path/class path as necessary. Without --enable-preview, javac gives an error if it attempts to read a preview class file.

# Diagnostics

- With --enable-preview, if javac detects the use of one or more preview features in source, then javac prints a "note" at the end of the compilation to indicate the use of preview features. Compiling with --enable-preview -Xlint:preview will cause javac to print info about all uses.

* Without --enable-preview, if javac detects the use any preview feature in source, then javac fails with an error. As well as giving the error, javac also mentions that a preview feature was used, and that --enable-preview can be given.

* If a source file depends on one or more preview class files, then javac counts that as a use of a preview feature. Accordingly, javac either gives a "note"/lint warning (with --enable-preview) or an error (without --enable-preview).