JDK-8061549 : Disallow _ as a one-character identifier
  • Type: Enhancement
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 9
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • Submitted: 2014-10-20
  • Updated: 2024-06-26
  • Resolved: 2014-12-08
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 9
9 b43Fixed
Related Reports
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Sub Tasks
JDK-8065599 :  
JDK-8065998 :  
Description
Complete the removal, begun in Java SE 8, of underscore from the set of legal identifier names.
Comments
URL: http://hg.openjdk.java.net/jdk9/jdk9/langtools/rev/84a76798cff3 User: lana Date: 2014-12-17 21:52:40 +0000
17-12-2014

URL: http://hg.openjdk.java.net/jdk9/dev/langtools/rev/84a76798cff3 User: jlahoda Date: 2014-12-08 17:16:47 +0000
08-12-2014

To demonstrate the output of the current proposed patch, consider this source code: --- public interface Lambda { public int a(int _); public default void t(Lambda l) { t(_ -> 0); } } --- Compiling with JDK8, this leads to: --- $ javac Lambda.java Lambda.java:2: warning: '_' used as an identifier public int a(int _); ^ (use of '_' as an identifier might not be supported in releases after Java SE 8) Lambda.java:4: error: '_' used as an identifier t(_ -> 0); ^ (use of '_' as an identifier is forbidden for lambda parameters) 1 error 1 warning --- Compiling with the proposed patch and -source 9 leads to: --- $ javac -source 9 Lambda.java Lambda.java:2: error: as of release 9, '_' is a keyword, and may not be used as an identifier public int a(int _); ^ Lambda.java:4: error: '_' used as an identifier t(_ -> 0); ^ (use of '_' as an identifier is forbidden for lambda parameters) 2 errors --- Compiling with the proposed patch and -source 8 leads to: --- $ javac -source 8 Lambda.java warning: [options] bootstrap class path not set in conjunction with -source 1.8 Lambda.java:2: warning: as of release 9, '_' is a keyword, and may not be used as an identifier public int a(int _); ^ Lambda.java:4: error: '_' used as an identifier t(_ -> 0); ^ (use of '_' as an identifier is forbidden for lambda parameters) 1 error 2 warnings ---
05-12-2014

Attaching a simple finder for underscore as one-character identifiers. Needs tools.jar on classpath. Takes a single parameter, which is the directory that should be searched.
03-12-2014

No known instances of using "_" as an identifier in the jdk or langtools repos, but the other repos would need to be tested.
27-10-2014