[NEW BUG] jdk.internal.module.Checks seems to miss a check for 'var'
christoph.dreis at freenet.de
Fri Mar 22 11:59:53 UTC 2019
On a second thought, the patched posted is not safe as it is used for
package name checks as well.
And while var is not a type-identifier, it is still an identifier. So it
should be possible to name your package "var" if I'm not mistaken.
The question remains. Should we change anything here in the Checks class?
> 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
> 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
> type of a local variable declaration"
> And secondly the section about identifiers
> "Type identifiers are used in certain contexts involving the
> use of types. For example, the name of a class must be a TypeIdentifier,
> is illegal to declare a class named var."
> Especially the last one got me thinking. Imagine a call like the
> This will currently return true, while it should return false, shouldn't
> 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
> Mar 22 13:42:45 2019 +0530
> +++ b/src/java.base/share/classes/jdk/internal/module/Checks.java
> Mar 22 12:24:27 2019 +0100
> @@ -242,6 +242,7 @@
> + "var",
More information about the core-libs-dev