Skip to content

Commit

Permalink
more asserts
Browse files Browse the repository at this point in the history
  • Loading branch information
mbien committed Sep 21, 2023
1 parent 8f8a30f commit 2c379f8
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import java.io.File;
import java.net.URL;
import junit.framework.Test;
import static junit.framework.TestCase.assertEquals;

import org.netbeans.api.debugger.DebuggerManager;
import org.netbeans.api.debugger.jpda.JPDADebugger;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import java.io.File;
import java.net.URL;
import junit.framework.Test;
import static junit.framework.TestCase.assertEquals;

import org.netbeans.api.debugger.DebuggerManager;
import org.netbeans.api.debugger.jpda.JPDADebugger;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import java.io.File;
import java.net.URL;
import junit.framework.Test;
import static junit.framework.TestCase.assertEquals;

import org.netbeans.api.debugger.DebuggerManager;
import org.netbeans.api.debugger.jpda.JPDADebugger;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@
import java.util.logging.Level;
import junit.framework.Test;
import junit.framework.TestCase;
import static junit.framework.TestCase.assertEquals;
import static junit.framework.TestCase.assertNotNull;
import org.netbeans.api.debugger.jpda.JPDADebugger;
import org.netbeans.api.debugger.jpda.JPDASupport;
import org.netbeans.api.debugger.jpda.JPDAThread;
Expand Down Expand Up @@ -79,6 +77,7 @@ protected final File getJavaSourceFile(String javaFileName) {
}

protected final void runScriptUnderJPDA(String launcher, String scriptPath, ThrowableConsumer<JPDASupport> supportConsumer) throws Exception {
assertTrue("'"+launcher+"' launcher not available", JPDASupport.isLauncherAvailable(launcher));
// Translate script path from source dir to target dir:
scriptPath = getBinariesPath(scriptPath);
JPDASupport support = JPDASupport.attachScript(launcher, scriptPath);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLClassLoader;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
Expand Down Expand Up @@ -64,14 +66,13 @@
*/
public final class JPDASupport implements DebuggerManagerListener {

private static final boolean verbose = false;
private static DebuggerManager dm = DebuggerManager.getDebuggerManager ();
private static final DebuggerManager dm = DebuggerManager.getDebuggerManager ();

private JPDADebugger jpdaDebugger;
private DebuggerEngine debuggerEngine;
private final ProcessIO processIO;

private Object STATE_LOCK = new Object ();
private final Object STATE_LOCK = new Object ();

private JPDASupport (JPDADebugger jpdaDebugger, ProcessIO pio) {
this.jpdaDebugger = jpdaDebugger;
Expand Down Expand Up @@ -210,8 +211,7 @@ public static JPDASupport attach (String[] vmArgs, String mainClass, String[] ar

public static JPDASupport attachScript(String launcher, String path) throws IOException, DebuggerStartException {
String [] cmdArray = new String [] {
System.getProperty ("java.home") + File.separatorChar +
"bin" + File.separatorChar + launcher,
launcherPath(launcher),
"--jvm",
"--vm.agentlib:jdwp=transport=dt_socket,suspend=y,server=y",
path
Expand Down Expand Up @@ -245,6 +245,13 @@ public static JPDASupport attachScript(String launcher, String path) throws IOEx
return new JPDASupport(jpdaDebugger, pio);
}

private static String launcherPath(String launcher) {
return System.getProperty("java.home") + File.separatorChar + "bin" + File.separatorChar + launcher;
}

public static boolean isLauncherAvailable(String launcher) {
return Files.exists(Paths.get(launcherPath(launcher)));
}

// public interface ........................................................

Expand Down Expand Up @@ -405,8 +412,7 @@ private static Process launchVM (

List<String> cmdArgs = new ArrayList<>();

cmdArgs.add(System.getProperty ("java.home") + File.separatorChar +
"bin" + File.separatorChar + "java");
cmdArgs.add(launcherPath("java"));
cmdArgs.add("-agentlib:jdwp=transport=" + "dt_socket" + ",address=" +
connectorAddress + ",suspend=y,server=" +
(server ? "y" : "n"));
Expand Down

0 comments on commit 2c379f8

Please sign in to comment.