JDK-8080843 : JShell tool: invalid key error occurs when external editor is used.
  • Type: Bug
  • Component: tools
  • Sub-Component: jshell
  • Affected Version: 9
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • Submitted: 2015-05-21
  • Updated: 2016-08-09
  • Resolved: 2016-05-31
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 9
9 b122Fixed
Related Reports
Relates :  
Description
For testing see: jshell/jdk/EditorTest.java

To reproduce use the following steps:
1. /seteditor vim
2. class A {}
3. /e A, modify sources.
4. save, close editor.
5. Output is: |  Edit Error: Invalid key

Comments
boolean valid = key.reset(); if (!valid) { errorHandler.accept("Invalid key"); break; } Interface WatchKey boolean reset() ... Returns: true if the watch key is valid and has been reset, and false if the watch key could not be reset because it is no longer valid -- where valid is defined in isValid() -- A watch key is valid upon creation and remains until it is cancelled, or its watch service is closed.
28-05-2016

For standard usage of the WatchService, see: https://docs.oracle.com/javase/tutorial/essential/io/notification.html#process The existing code is wrong in making the invalid key an error. On WatchService shutdown the key will be invalid.
28-05-2016