[NEW BUG] jdk.internal.module.Checks seems to miss a check for 'var'
christoph.dreis at freenet.de
Fri Mar 22 11:30:11 UTC 2019
I recently stumbled upon jdk.internal.module.Checks and was wondering if you
could help me understanding if I face a bug. The mentioned class has a
private static field containing a list of reserved keywords. When checking
the list for completeness, I noticed that "var" seems to be missing here and
I wonder if it should be added. I found two relevant links in the spec
The first one being the list of keywords:
"var is not a keyword, but rather an identifier with special meaning
as the type of a local variable declaration"
And secondly the section about identifiers
"Type identifiers are used in certain contexts involving the
declaration or use of types. For example, the name of a class must be a
TypeIdentifier, so it is illegal to declare a class named var."
Especially the last one got me thinking. Imagine a call like the following:
This will currently return true, while it should return false, shouldn't it?
I attached a patch for what I think should be implemented. And if my
assumption turns out to be correct, I'd be more than happy if this is
sponsored and earns a "contributed-by". If this is already known or an
incorrect assumption, I'm very sorry for bothering you guys.
========= PATCH ==========
diff -r 96c45aa61056
--- a/src/java.base/share/classes/jdk/internal/module/Checks.java Fri
Mar 22 13:42:45 2019 +0530
+++ b/src/java.base/share/classes/jdk/internal/module/Checks.java Fri
Mar 22 12:24:27 2019 +0100
@@ -242,6 +242,7 @@
More information about the core-libs-dev