changeset 43136:24d62ba7ad5e

8172414: jshell not working in exploded JDK build Summary: Using Class.getResourceAsStream instead of a direct reference to JRT. Reviewed-by: rfield, sundar
author jlahoda
date Tue, 10 Jan 2017 13:53:44 +0100
parents 0c7c13fa7bee
children 9a96f02a6293
files langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/JShellTool.java
diffstat 1 files changed, 6 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/JShellTool.java	Tue Jan 10 10:17:47 2017 +0100
+++ b/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/JShellTool.java	Tue Jan 10 13:53:44 2017 +0100
@@ -218,7 +218,7 @@
 
     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 @@
     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