Skip to content

Commit

Permalink
Fixes classpath in CompilerClassLoader for windows support
Browse files Browse the repository at this point in the history
  • Loading branch information
rach-id committed Sep 14, 2020
1 parent 7ab0f6a commit 5f708fc
Showing 1 changed file with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -92,14 +92,27 @@ private Optional<File> compileClass(final String name) {
}

private String buildClassPath() {
return buildClassPath(urls) + ':' + System.getProperty("java.class.path");
return buildClassPath(urls) + getClassPathSeparator() + System.getProperty("java.class.path");
}

private String getClassPathSeparator() {
if(isWindows()) {
return ";";
}
else {
return ":";
}
}

private boolean isWindows() {
return System.getProperty("os.name").toLowerCase().startsWith("windows");
}

private String buildClassPath(final URL... urls) {
return Arrays.stream(urls)
.map(URL::toExternalForm)
.map(url -> url.replaceAll("file:", ""))
.collect(Collectors.joining(":"));
.collect(Collectors.joining(getClassPathSeparator()));
}

private Optional<byte[]> readBytes(final File file) {
Expand Down

0 comments on commit 5f708fc

Please # to comment.