Skip to content

Commit

Permalink
Fix standalone attach on Windows (#484)
Browse files Browse the repository at this point in the history
  • Loading branch information
lucko committed Jan 15, 2025
1 parent 273f9bc commit 509aa7a
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@
import com.sun.tools.attach.VirtualMachine;
import com.sun.tools.attach.VirtualMachineDescriptor;

import java.io.File;
import java.lang.instrument.Instrumentation;
import java.net.URI;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
Expand Down Expand Up @@ -51,9 +55,9 @@ public static void main(String[] args) {

try {
VirtualMachine vm = VirtualMachine.attach(args[0]);
String agentPath = StandaloneSparkAgent.class.getProtectionDomain().getCodeSource().getLocation().getPath();
URI agentPath = StandaloneSparkAgent.class.getProtectionDomain().getCodeSource().getLocation().toURI();
String arguments = String.join(",", Arrays.copyOfRange(args, 1, args.length));
vm.loadAgent(agentPath, arguments);
vm.loadAgent(Paths.get(agentPath).toAbsolutePath().toString(), arguments);
System.out.println("[spark] Agent loaded successfully.");
vm.detach();
} catch (Throwable e) {
Expand Down

0 comments on commit 509aa7a

Please sign in to comment.