RFR: 8368848: JShell's code completion not always working for multi-snippet inputs

Jan Lahoda jlahoda at openjdk.org
Mon Sep 29 16:24:58 UTC 2025


Having a JShell input like:

jshell> String s() { return "";} s(). 


the code completion is not working for it. The reason is that the input is two snippets, but the code completion will interpret it as only one snippet, and a method declaration and method invocation cannot coexist inside one snippet (as one is a declaration that must appear outside of a method, and the invocation must be inside a method body or field initializer).

The proposal herein is for the JShell's code completion to split the input into snippets, and create a wrapper/compilation unit based on all the snippets.

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

Commit messages:
 - 8368848: JShell's code completion not always working for multi-snippet inputs

Changes: https://git.openjdk.org/jdk/pull/27552/files
  Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=27552&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8368848
  Stats: 140 lines in 4 files changed: 114 ins; 15 del; 11 mod
  Patch: https://git.openjdk.org/jdk/pull/27552.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/27552/head:pull/27552

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


More information about the compiler-dev mailing list