diff -r 093027a037cf -r 191ae61bd1e9 src/jdk.jshell/share/classes/jdk/internal/jshell/tool/JShellTool.java --- a/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/JShellTool.java Wed Dec 13 13:27:45 2017 +0530 +++ b/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/JShellTool.java Wed Dec 13 10:25:38 2017 -0800 @@ -43,6 +43,7 @@ import java.nio.charset.Charset; import java.nio.file.FileSystems; import java.nio.file.Files; +import java.nio.file.InvalidPathException; import java.nio.file.Path; import java.nio.file.Paths; import java.text.MessageFormat; @@ -387,7 +388,7 @@ private Collection validPaths(Collection vals, String context, boolean isModulePath) { Stream result = vals.stream() .map(s -> Arrays.stream(s.split(File.pathSeparator)) - .map(sp -> toPathResolvingUserHome(sp)) + .flatMap(sp -> toPathImpl(sp, context)) .filter(p -> checkValidPathEntry(p, context, isModulePath)) .map(p -> p.toString()) .collect(Collectors.joining(File.pathSeparator))); @@ -427,6 +428,16 @@ return false; } + private Stream toPathImpl(String path, String context) { + try { + return Stream.of(toPathResolvingUserHome(path)); + } catch (InvalidPathException ex) { + msg("jshell.err.file.not.found", context, path); + failed = true; + return Stream.empty(); + } + } + Options parse(OptionSet options) { addOptions(OptionKind.CLASS_PATH, validPaths(options.valuesOf(argClassPath), "--class-path", false));