RFR: 8129418: JShell: better highlighting of errors in imports on demand

Nizar Benalla duke at openjdk.org
Sat May 4 19:25:06 UTC 2024


When Type-Import-on-Demand fails, we now point the position of the first incorrect PackageOrTypeName which clearly isn't package, a class,or an interface.

old behavior:

|  Welcome to JShell -- Version 22.0.1
|  For an introduction type: /help intro

jshell> import unknown.*;
|  Error:
|  package unknown does not exist
|  import unknown.*;
|  ^

New behavior:

|  Welcome to JShell -- Version 23-internal
|  For an introduction type: /help intro

jshell> import unknown.*;
|  Error:
|  package unknown does not exist
|  import unknown.*;
|         ^-----^



jshell> import unknown.unknown.unknown.*;
|  Error:
|  package unknown.unknown.unknown does not exist
|  import unknown.unknown.unknown.*;
|         ^---------------------^

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

Commit messages:
 - Pass a `DiagnosticPosition` with a start/position/end to the logging method rather than an int
 - When Type-Import-on-Demand fails, log the position of the first PackageOrTypeName

Changes: https://git.openjdk.org/jdk/pull/19073/files
  Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=19073&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8129418
  Stats: 11 lines in 7 files changed: 0 ins; 1 del; 10 mod
  Patch: https://git.openjdk.org/jdk/pull/19073.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/19073/head:pull/19073

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


More information about the compiler-dev mailing list