RFR: JDK-8264488: Improve warning for module names ending with digits

Sebastian Stenzel duke at openjdk.org
Thu May 25 04:26:54 UTC 2023


On Thu, 25 May 2023 00:45:39 GMT, Alex Buckley <alex.buckley at oracle.com> wrote:

> "terminal digits" means "the digits at the end", so there's no need to say "ends on" -- it would just be "module name {0} has terminal digits". In any case, "terminal digits" is a dense phrase that appeals to the technical construct of "Java digit" without spelling it out -- this is hard work for readers -- "number" is more straightforward.

I agree on the "terminal" and "ends on" being redundant.

However, digits don't necessarily need to be a number. This depends on whether or not they are used to denote a numeric value (see example below). Without context, they are just a set of characters. Since we strive for a concise error message, we should be very precise here.

> Also, the phrase "must not" is inappropriate for a warning message. "must not" is for error messages.

Agreed, that's why the warning says "should not" to the digits, while pointing out that it "must not" be a version number.

> 
> Here's a rewrite of your suggestion:
> 
> module name {0} ends with a number, which should not encode a version

This would be incorrect, though. While ["the specification was revised to allow digits at the end of module names"](https://openjdk.org/projects/jigsaw/spec/minutes/2017-05-18#VersionsInModuleNames) for non-version cases, we still don't want to allow adding version numbers (according to my understanding of the whole discussion about it). Hence, "should not" in conjunction with "encode a version" is too soft.

> The good thing about this text is that it starts by stating a fact, and only then (after the comma) presenting a judgement. That's how we phrase run-time warnings for illegal reflective access and for dynamic installation of a Security Manager (https://openjdk.org/jeps/411#Issue-warnings). However, javac warnings need to be brief, and tend to skip directly to the judgement that X is bad.

If the compiler can be sure about its judgement, that is fine. In this case, the compiler can not really make such a judgement. It requires human intelligence to judge whether one or more digits denote a number and whether this number denotes a version:

| module name        | digit? | number? | version? | judgement |
|--------------------|--------|---------|----------|-----------|
| com.bar.f00        | ✔︎      | ✘       | ✘        | allowed   |
| com.example.pkcs11 | ✔︎      | ✔︎       | ✘        | allowed   |
| org.openjdk.java17 | ✔︎      | ✔︎       | ✔︎        | forbidden |

Hence, directly skipping to the judgement without stating the fact might be a bit too hasty. But I believe we can put both, the observation and the cause of the problem in a very concise message without dropping any information.

> [...]
> module name {0} ends with a number that looks like a version

Quite good. But for the reasons stated above, let's stick to "terminal digits":

`terminal digits in module name {0} look like a version number`

Being semantically closer to the original warning also has the side effect that e.g. existing discussions on Stack Overflow [can easier be found](https://stackoverflow.com/search?q=terminal+digits+in+module+name) if devs look for help when when encountering the updated warning.

-------------

PR Comment: https://git.openjdk.org/jdk/pull/14099#issuecomment-1562245181


More information about the compiler-dev mailing list