Merge pull request #314 from Parabot/feature/class-path-stripper

[FEATURE] Added valid class path
This commit is contained in:
Jeroen Ketelaar
2019-05-22 07:13:42 -05:00
committed by GitHub
@@ -9,7 +9,7 @@ public class SystemRedirect {
public static PrintStream out = System.out; public static PrintStream out = System.out;
public static PrintStream err = System.err; public static PrintStream err = System.err;
public static InputStream in = System.in; public static InputStream in = System.in;
public static long currentTimeMillis() { public static long currentTimeMillis() {
return System.currentTimeMillis(); return System.currentTimeMillis();
@@ -23,11 +23,23 @@ public class SystemRedirect {
System.exit(i); System.exit(i);
} }
private static String getClassPath(){
String classPath = System.getProperty("java.class.path");
StringBuilder finalClassPath = new StringBuilder();
for (String path : classPath.split(":")) {
if (!path.toLowerCase().contains("parabot")) {
finalClassPath.append(path).append(":");
}
}
return finalClassPath.toString();
}
public static String getProperty(String s) { public static String getProperty(String s) {
String value; String value;
switch (s) { switch (s) {
case "java.class.path": case "java.class.path":
value = "."; value = getClassPath();
break; break;
default: default:
value = System.getProperty(s); value = System.getProperty(s);
@@ -42,14 +54,14 @@ public class SystemRedirect {
String value = null; String value = null;
switch (s2) { switch (s2) {
case "java.class.path": case "java.class.path":
value = "."; value = getClassPath();
break; break;
} }
if (value == null) { if (value == null) {
switch (s) { switch (s) {
case "java.class.path": case "java.class.path":
value = "."; value = getClassPath();
break; break;
default: default:
value = System.getProperty(s); value = System.getProperty(s);