8172414: jshell not working in exploded JDK build
Using Class.getResourceAsStream instead of a direct reference to JRT. Reviewed-by: rfield, sundar
This commit is contained in:
parent
fd12ea2d58
commit
b8bdb56985
@ -218,7 +218,7 @@ public class JShellTool implements MessageHandler {
|
||||
|
||||
static final String DEFAULT_STARTUP_NAME = "DEFAULT";
|
||||
static final Pattern BUILTIN_FILE_PATTERN = Pattern.compile("\\w+");
|
||||
static final String BUILTIN_FILE_PATH_FORMAT = "jrt:/jdk.jshell/jdk/jshell/tool/resources/%s.jsh";
|
||||
static final String BUILTIN_FILE_PATH_FORMAT = "/jdk/jshell/tool/resources/%s.jsh";
|
||||
|
||||
// match anything followed by whitespace
|
||||
private static final Pattern OPTION_PRE_PATTERN =
|
||||
@ -2426,9 +2426,11 @@ public class JShellTool implements MessageHandler {
|
||||
String readResource(String name) throws IOException {
|
||||
// Attempt to find the file as a resource
|
||||
String spec = String.format(BUILTIN_FILE_PATH_FORMAT, name);
|
||||
URL url = new URL(spec);
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(url.openStream()));
|
||||
return reader.lines().collect(Collectors.joining("\n"));
|
||||
|
||||
try (InputStream in = JShellTool.class.getResourceAsStream(spec);
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(in))) {
|
||||
return reader.lines().collect(Collectors.joining("\n"));
|
||||
}
|
||||
}
|
||||
|
||||
// retrieve the default startup string
|
||||
|
Loading…
x
Reference in New Issue
Block a user