-
Bug
-
Resolution: Fixed
-
P3
-
9
-
b144
-
Not verified
It is a module anomaly to reference Desktop from core JDK tools. Edit Pad needs to be moved out of the jshell tool.
Paul Sandoz writes --
One approach for an out of the box solution is to split out the editor functionality into a separate module and for jshell to define a service provider interface. Thereby on a full JDK distribution you can the same functionality but on a more minimal distribution it is not present. A lesser solution is to provide the service provider interface and an example implementation that is not distributed, thereby teaching institutions could still use that.
Robert Field writes --
That would certainly be doable. If the critical concern is module boundaries. But that exposes the Edit Pad to use outside of jshell -- is that an issue?
Mark writes --
You can prevent undue exposure by defining the service type in the
jdk.jshell module and exporting its containing package only to the
new module that contains Edit Pad, something like this:
module jdk.jshell {
exports jdk.jshell.editor.spi to jdk.internal.editpad;
...
}
module jdk.internal.editpad {
requires java.desktop;
requires jdk.jshell;
provides jdk.jshell.editor.spi.Editor
with jdk.internal.editpad.EditorProvider;
}
Paul Sandoz writes --
One approach for an out of the box solution is to split out the editor functionality into a separate module and for jshell to define a service provider interface. Thereby on a full JDK distribution you can the same functionality but on a more minimal distribution it is not present. A lesser solution is to provide the service provider interface and an example implementation that is not distributed, thereby teaching institutions could still use that.
Robert Field writes --
That would certainly be doable. If the critical concern is module boundaries. But that exposes the Edit Pad to use outside of jshell -- is that an issue?
Mark writes --
You can prevent undue exposure by defining the service type in the
jdk.jshell module and exporting its containing package only to the
new module that contains Edit Pad, something like this:
module jdk.jshell {
exports jdk.jshell.editor.spi to jdk.internal.editpad;
...
}
module jdk.internal.editpad {
requires java.desktop;
requires jdk.jshell;
provides jdk.jshell.editor.spi.Editor
with jdk.internal.editpad.EditorProvider;
}