JDK-8189146 : Have use of "var" in 9 and earlier source versions issue a warning for type declarations
  • Type: Enhancement
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 10
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2017-10-11
  • Updated: 2018-04-05
  • Resolved: 2018-01-18
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 10 JDK 11
10Fixed 11 b01Fixed
Related Reports
Blocks :  
Relates :  
Relates :  
When the possibility of "_" being removed from the future set of valid identifiers was determined, javac was updated to issue a warning to that effect in JDK 8. Underscore was removed from the set of valid identifiers as of JDK 9.

With local variable type inference, the name "var" should be given similar treatment in source versions 9 and earlier.

Late enhancement approved for JDK 10. Please update the description above to indicate the precise scope of the warning, which is more limited than first proposed.

The review thread has settled and the version of the change in http://cr.openjdk.java.net/~darcy/8189146.4/ is presented for inclusion in JDK 10. Follow-up work with a more comprehensive fix will go into JDK 11.

Request noted. I'll reserve judgement until the review thread reaches a conclusion.

Late Enhancement Request The change in question, some variant of http://cr.openjdk.java.net/~darcy/8189146.1/ is a localized and low-risk change to warn about use of the name "var" in pre-10 source levels. This will allow a smoother transition by alerting users that the name "var" will not be available in the same way starting in 10. An analogous warning was issued about underscores as parameter names in JDK 8. I expect this change will be ready to push by 2018-01-12. (The webrev above is against JDK 11, but adapting the patch to JDK 10 should be trivial.)

Review thread: http://mail.openjdk.java.net/pipermail/compiler-dev/2018-January/011518.html