JDK-8158738 : jshell tool: Save does not affect jshell if started from another editor
  • Type: Bug
  • Component: tools
  • Sub-Component: jshell
  • Affected Version: 9
  • Priority: P4
  • Status: Closed
  • Resolution: Fixed
  • OS: linux
  • CPU: x86_64
  • Submitted: 2016-06-02
  • Updated: 2016-09-02
  • Resolved: 2016-08-26
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 b134Fixed
Related Reports
Duplicate :  
Relates :  
Description
FULL PRODUCT VERSION :
JDK1.9b120

ADDITIONAL OS VERSION INFORMATION :
4.4.0-22-generic #40-Ubuntu SMP Thu May 12 22:03:46 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux


EXTRA RELEVANT SYSTEM CONFIGURATION :
NetBeans Development version, build 20160602

A DESCRIPTION OF THE PROBLEM :
If jshell is started from within NetBeans terminal window and the editor is set to NetBeans, then saving the edited statement list is ignored by the jshell

Unclear whether this is a NetBeans or jshell issue. I filed the same problem to NB
https://netbeans.org/bugzilla/show_bug.cgi?id=262315

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
STEPS:
1* download JDK 9 (actual: build 120)
2* launch jshell
3* /set editor netbeans-dev-201606020002/bin/netbeans (or appropriate path)
4* enter Java statement
5* /edit
--> Netbeans will be started if not yet running, Java statements of jshell session will be displayed
6* modify or add statement(s)
7* press ctrl+S to save
--> jshell uses the modified commands
8* open terminal window (window, ide tools, terminal)
9* perform steps 2* to 7* using the terminal window
--> jshell ignores the modified data

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
jshell accepts the modified statements
ACTUAL -
jshell ignores the edited statements

REPRODUCIBILITY :
This bug can be reproduced always.


Comments
Another option: (4) Add a "-wait" option to '/set editor' which prompts and waits before transitioning from edit mode. I will try (4).
23-08-2016

When the /edit command is used, until the editor exits, no jshell prompt is displayed and no input is accepted, during this time the jshell tool watches the temp file for changes, entering any changes. When the editor exits the jshell tool stops watching. From my experiments with gedit, what is happening in this case is that the first time the gedit command is used it creates the window and waits for all windows to close before exiting. Subsequent calls to gedit add a pane for the file and return immediately. As a result the jshell tool assumes the editor has exited, stops watching the file, and queries for input with a prompt. For gedit, this can be addressed by using the --wait or maybe better the --standalone option: /set editor gedit -s There are three ways to resolve this issue: (1) Add documentation to the '/set editor' command describing this requirement. (2) Change the behaviour of the /edit command to continually watch every temporary file that was ever opened. The concern with this is that then changes could be made from multiple angles at overlapping times: the jshell prompt, and multiple open editors. Changes in one would not be reflected in the others, allowing changes to be smashed. This might be acceptable because the same could occur in other contexts with multiple editors, though there would usually be notifications that the file had changed underneath you. Note: there is no "file" with which to do this in the jshell tool -- synthetically manufacturing one would be fraught with data loss peril. Another issue is that output would be coming from multiple threads -- while waiting (or typing) at the jshell prompt you would get notifications about editor changes " modified method m()". (3) If (2) were considered appropriate, then it might be reasonable to take the next step, always return immediately from the /edit command, thus allowing jshell commands while in the editor.
17-07-2016

This issue is reproducible with gedit also, hence it is not Netbeans issue. Below is the result of launching from 2 terminals Terminal1: fairoz@fairoz:/opt/java$ /opt/java/jdk-9_121/bin/jshell | Welcome to JShell -- Version 9-ea | For an introduction type: /help intro jshell> /seteditor gedit | No such command or snippet id: /seteditor | Type /help for help. jshell> /set editor gedit | Editor set to: gedit jshell> System.out.println("Hello") Hello jshell> /edit Hello Hello1 Terminal 2: fairoz@fairoz:~$ /opt/java/jdk-9_121/bin/jshell | Welcome to JShell -- Version 9-ea | For an introduction type: /help intro jshell> /set editor gedit | Editor set to: gedit jshell> System.out.println("a"); a jshell> /edit jshell> //No value is being saved Problem observed in 9 ea b121
06-06-2016