RFR: 8027682: javac wrongly accepts semicolons in package and import decls [v4]

Archie L. Cobbs duke at openjdk.org
Thu Feb 9 15:01:20 UTC 2023


On Thu, 9 Feb 2023 04:11:52 GMT, Vicente Romero <vromero at openjdk.org> wrote:

> the new extraneous semicolon error is reported but the compiler doesn't report the fact that there is no class named NO inside of java.util or java.io I think that those other errors should be reported too

Hmm, this seems like an orthogonal issue to me.

In other words, the problem you're describing already exists, and it's just being uncovered by this change.

For example, if you compile this class:

import java.util.NO;
while
import java.io.NO;

you get this result:

Test.java:2: error: class, interface, enum, or record expected
while
^
1 error


If you compile this class:

import java.util.NO;
(
import java.io.NO;

you get this result:

Test.java:2: error: class, interface, enum, or record expected
(
^
1 error

The fact that a syntax error inhibits resolution of imported package names is happening somewhere else downstream in the compiler.

I'm not opposed to fixing that, but it seems like it should be filed as a separate issue, because (as the above examples show) it's a more general problem than just with extra semicolons.

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

PR: https://git.openjdk.org/jdk/pull/12448


More information about the compiler-dev mailing list