RFR: 8177650: JShell tool: packages in classpath don't appear in completions

Christian Stein cstein at openjdk.org
Mon Jul 7 12:46:56 UTC 2025


On Fri, 4 Jul 2025 17:32:38 GMT, Jan Lahoda <jlahoda at openjdk.org> wrote:

> JShell provides the code completion feature, where it suggests possible follow ups for a given snippet prefix. To allow completion for packages, JShell uses a background task to go through known classes and create an index for them.
> 
> There are two problems with this background task:
> - the classpath is read from the JShell's FileManager, but the FileManager may not be configured with the compile options yet, so the classpath may not be filled yet,
> - the module path is not included in the list of paths to paths to search
> 
> This PR proposes to:
> - use FileManager configured by passing the compile options through javac
> - include the module path in the search path

Changes requested by cstein (Committer).

test/langtools/jdk/jshell/ToolCompletionTest.java line 196:

> 194:         Files.createDirectories(lib);
> 195:         compiler.jar(p1, jarName, "p1/p2/Test.class", "p1/p3/Test.class");
> 196:         Files.move(compiler.getPath(p1.resolve(jarName)), lib.resolve(jarName));

Suggestion:

        Files.copy(compiler.getPath(p1.resolve(jarName)), lib.resolve(jarName));


Prevent `java.nio.file.FileSystemException` on Windows:


ToolCompletionTest.d\\tool_completion_test\\dir1\\test.jar -> tool_completion_test\\lib\\test.jar: The process cannot access the file because it is being used by another process


Seems like `compiler.jar(p1, jarName, "p1/p2/Test.class", "p1/p3/Test.class");` keeps an open file handle to the created `JAR` file.

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

PR Review: https://git.openjdk.org/jdk/pull/26137#pullrequestreview-2993683578
PR Review Comment: https://git.openjdk.org/jdk/pull/26137#discussion_r2189970293


More information about the kulla-dev mailing list