Skip to content

Commit

Permalink
fix cmd too long issuse
Browse files Browse the repository at this point in the history
  • Loading branch information
sunwu51 committed Jun 16, 2024
1 parent 07ccfff commit e247ab5
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
21 changes: 20 additions & 1 deletion src/main/java/w/App.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
import java.lang.instrument.Instrumentation;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;

Expand Down Expand Up @@ -56,12 +58,29 @@ public static void agentmain(String arg, Instrumentation instrumentation) throws
// }

public static void startCompiler() {

String os = System.getProperty("os.name").toLowerCase();
Global.unpackUberJar(Global.getClassLoader());
String javaHome = System.getProperty("java.home");
String javaBin = javaHome + "/bin/java";
String classpath = "";
Set<String> cps = new HashSet<>();
for (String cp : Global.getClassPaths()) {

// Windows os need to delete the first /
if (os.contains("win") && cp.startsWith("/")) {
cp = cp.substring(1);
}

if (cp.endsWith(".jar")) {
int pos = cp.lastIndexOf("/") < 0 ? cp.lastIndexOf("\\") : cp.lastIndexOf("/");
cp = cp.substring(0, pos + 1) + "*";
}
if (cp.endsWith(".class")) {
continue;
}
cps.add(cp);
}
for (String cp : cps) {
if (!classpath.isEmpty()) {
classpath += File.pathSeparator;
}
Expand Down
5 changes: 0 additions & 5 deletions src/main/java/w/Global.java
Original file line number Diff line number Diff line change
Expand Up @@ -424,11 +424,6 @@ public static Set<String> getClassPaths() {
String jarPath = codeSource.getLocation().getPath();
result.add(jarPath);
}
codeSource = getClassLoader().getClass().getProtectionDomain().getCodeSource();
if (codeSource != null) {
String jarPath = codeSource.getLocation().getFile();
result.add(jarPath);
}
return result;
}

Expand Down

0 comments on commit e247ab5

Please sign in to comment.