From c4d10e9f7fe4a6cf16ec2b4d92b07db3f828325f Mon Sep 17 00:00:00 2001 From: Jan Lahoda Date: Fri, 27 Mar 2026 08:19:04 +0100 Subject: [PATCH] [GITHUB-6925] Fixing debugger tests. --- .github/workflows/main.yml | 15 +-- .../nbproject/project.xml | 21 ++-- .../jpda/truffle/DebugAllBaseTest.java | 72 ------------- .../jpda/truffle/DebugPythonTest.java | 86 --------------- .../debugger/jpda/truffle/DebugRTest.java | 85 --------------- .../debugger/jpda/truffle/DebugRubyTest.java | 100 ------------------ .../debugger/jpda/truffle/JPDATestCase.java | 21 +++- .../api/debugger/jpda/JPDASupport.java | 40 ------- 8 files changed, 36 insertions(+), 404 deletions(-) delete mode 100644 java/debugger.jpda.truffle/test/unit/src/org/netbeans/modules/debugger/jpda/truffle/DebugPythonTest.java delete mode 100644 java/debugger.jpda.truffle/test/unit/src/org/netbeans/modules/debugger/jpda/truffle/DebugRTest.java delete mode 100644 java/debugger.jpda.truffle/test/unit/src/org/netbeans/modules/debugger/jpda/truffle/DebugRubyTest.java diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 86a6e602b316..6d303a48c7b4 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1575,8 +1575,8 @@ jobs: - name: debugger.jpda.projectsui run: ant $OPTS -f java/debugger.jpda.projectsui test -# - name: debugger.jpda.truffle -# run: ant $OPTS -f java/debugger.jpda.truffle test + - name: debugger.jpda.truffle + run: ant $OPTS -f java/debugger.jpda.truffle test - name: debugger.jpda.ui run: ant $OPTS -f java/debugger.jpda.ui test-unit @@ -2560,9 +2560,7 @@ jobs: timeout-minutes: 60 strategy: matrix: - # TODO uses GraalVM 17 / 22.3.1 which is the last known release which offers all required language extensions - # GraalVM based on JDK 21+ doesn't support the 'gu' tool anymore - extensions are now regular application dependencies - graal: [ '22.3.1' ] + graal: [ '21.0.2' ] fail-fast: false steps: @@ -2581,14 +2579,11 @@ jobs: - name: Setup GraalVM ${{ matrix.graal }} run: | - URL=https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-${{ matrix.graal }}/graalvm-ce-java17-linux-amd64-${{ matrix.graal }}.tar.gz + URL=https://github.com/graalvm/graalvm-ce-builds/releases/download/jdk-${{ matrix.graal }}/graalvm-community-jdk-${{ matrix.graal }}_linux-x64_bin.tar.gz curl -L $URL | tar -xz - GRAALVM=`pwd`/graalvm-ce-java17-${{ matrix.graal }} + GRAALVM=$(realpath graalvm-community-openjdk-*) echo "JAVA_HOME=$GRAALVM" >> $GITHUB_ENV - - name: Setup GraalVM Languages (python, R, ruby and js) - run: $JAVA_HOME/bin/gu install --no-progress python R ruby js - - name: platform/core.network run: ant $OPTS -f platform/core.network test diff --git a/java/debugger.jpda.truffle/nbproject/project.xml b/java/debugger.jpda.truffle/nbproject/project.xml index 3d345abe7907..1c82b5032a4c 100644 --- a/java/debugger.jpda.truffle/nbproject/project.xml +++ b/java/debugger.jpda.truffle/nbproject/project.xml @@ -258,6 +258,12 @@ unit + + org.netbeans.api.debugger.jpda + + + + org.netbeans.core.startup @@ -266,25 +272,22 @@ org.netbeans.libs.freemarker + + org.netbeans.libs.graaljs + org.netbeans.libs.javacapi - org.netbeans.modules.debugger.jpda - - + org.netbeans.libs.junit4 + - org.netbeans.api.debugger.jpda - + org.netbeans.modules.debugger.jpda - - org.netbeans.libs.junit4 - - org.netbeans.modules.nbjunit diff --git a/java/debugger.jpda.truffle/test/unit/src/org/netbeans/modules/debugger/jpda/truffle/DebugAllBaseTest.java b/java/debugger.jpda.truffle/test/unit/src/org/netbeans/modules/debugger/jpda/truffle/DebugAllBaseTest.java index 029aa1215e61..f5a6f85d0498 100644 --- a/java/debugger.jpda.truffle/test/unit/src/org/netbeans/modules/debugger/jpda/truffle/DebugAllBaseTest.java +++ b/java/debugger.jpda.truffle/test/unit/src/org/netbeans/modules/debugger/jpda/truffle/DebugAllBaseTest.java @@ -63,18 +63,6 @@ public void testBreakpoints_JS() throws Exception { runBreakpointsTest(JS_LAUNCHER); } - public void testBreakpoints_Python() throws Exception { - runBreakpointsTest(PYTHON_LAUNCHER); - } - - public void testBreakpoints_R() throws Exception { - runBreakpointsTest(RSCRIPT_LAUNCHER); - } - - public void testBreakpoints_Ruby() throws Exception { - runBreakpointsTest(RUBY_LAUNCHER); - } - private void runBreakpointsTest(String launcher) throws Exception { File source = getScriptSourceFileForLauncher(launcher); DebuggerManager dm = DebuggerManager.getDebuggerManager(); @@ -99,18 +87,6 @@ public void testBreakpointsConditional_JS() throws Exception { runBreakpointsConditionalTest(JS_LAUNCHER); } - public void testBreakpointsConditional_Python() throws Exception { - runBreakpointsConditionalTest(PYTHON_LAUNCHER); - } - - public void testBreakpointsConditional_R() throws Exception { - runBreakpointsConditionalTest(RSCRIPT_LAUNCHER); - } - - public void testBreakpointsConditional_Ruby() throws Exception { - runBreakpointsConditionalTest(RUBY_LAUNCHER); - } - public void runBreakpointsConditionalTest(String launcher) throws Exception { File source = getScriptSourceFileForLauncher(launcher); DebuggerManager dm = DebuggerManager.getDebuggerManager(); @@ -141,18 +117,6 @@ public void testSteps_JS() throws Exception { runStepsTest(JS_LAUNCHER); } - public void testSteps_Python() throws Exception { - runStepsTest(PYTHON_LAUNCHER); - } - - public void testSteps_R() throws Exception { - runStepsTest(RSCRIPT_LAUNCHER); - } - - public void testSteps_Ruby() throws Exception { - runStepsTest(RUBY_LAUNCHER); - } - public void runStepsTest(String launcher) throws Exception { File source = getScriptSourceFileForLauncher(launcher); DebuggerManager dm = DebuggerManager.getDebuggerManager(); @@ -177,18 +141,6 @@ public void testEval_JS() throws Exception { runEvalTest(JS_LAUNCHER); } - public void testEval_Python() throws Exception { - runEvalTest(PYTHON_LAUNCHER); - } - - public void testEval_R() throws Exception { - runEvalTest(RSCRIPT_LAUNCHER); - } - - public void testEval_Ruby() throws Exception { - runEvalTest(RUBY_LAUNCHER); - } - public void runEvalTest(String launcher) throws Exception { File source = getScriptSourceFileForLauncher(launcher); DebuggerManager dm = DebuggerManager.getDebuggerManager(); @@ -226,18 +178,6 @@ public void testLocalVariables_JS() throws Exception { runLocalVariablesTest(JS_LAUNCHER); } - public void testLocalVariables_Python() throws Exception { - runLocalVariablesTest(PYTHON_LAUNCHER); - } - - public void testLocalVariables_R() throws Exception { - runLocalVariablesTest(RSCRIPT_LAUNCHER); - } - - public void testLocalVariables_Ruby() throws Exception { - runLocalVariablesTest(RUBY_LAUNCHER); - } - public void runLocalVariablesTest(String launcher) throws Exception { File source = getScriptSourceFileForLauncher(launcher); DebuggerManager dm = DebuggerManager.getDebuggerManager(); @@ -286,18 +226,6 @@ public void testObjectProperties_JS() throws Exception { runObjectPropertiesTest(JS_LAUNCHER); } - public void testObjectProperties_Python() throws Exception { - runObjectPropertiesTest(PYTHON_LAUNCHER); - } - - public void testObjectProperties_R() throws Exception { - runObjectPropertiesTest(RSCRIPT_LAUNCHER); - } - - public void testObjectProperties_Ruby() throws Exception { - runObjectPropertiesTest(RUBY_LAUNCHER); - } - public void runObjectPropertiesTest(String launcher) throws Exception { File source = getScriptSourceFileForLauncher(launcher); DebuggerManager dm = DebuggerManager.getDebuggerManager(); diff --git a/java/debugger.jpda.truffle/test/unit/src/org/netbeans/modules/debugger/jpda/truffle/DebugPythonTest.java b/java/debugger.jpda.truffle/test/unit/src/org/netbeans/modules/debugger/jpda/truffle/DebugPythonTest.java deleted file mode 100644 index c67cffd477ba..000000000000 --- a/java/debugger.jpda.truffle/test/unit/src/org/netbeans/modules/debugger/jpda/truffle/DebugPythonTest.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.netbeans.modules.debugger.jpda.truffle; - -import java.io.File; -import java.net.URL; -import junit.framework.Test; - -import org.netbeans.api.debugger.DebuggerManager; -import org.netbeans.api.debugger.jpda.JPDADebugger; -import org.netbeans.modules.debugger.jpda.truffle.breakpoints.TruffleLineBreakpoint; -import org.netbeans.modules.debugger.jpda.truffle.frames.TruffleStackFrame; -import org.netbeans.modules.debugger.jpda.truffle.vars.TruffleVariable; -import org.netbeans.modules.debugger.jpda.truffle.vars.impl.TruffleScope; -import org.netbeans.modules.javascript2.debug.breakpoints.JSLineBreakpoint; - -public class DebugPythonTest extends JPDATestCase { - - public DebugPythonTest(String name) { - super(name); - } - - public static Test suite() { - return createSuite(DebugPythonTest.class); - } - - public void testPythonTypes() throws Exception { - DebuggerManager dm = DebuggerManager.getDebuggerManager(); - File source = new File(sourceRoot, "org/netbeans/modules/debugger/jpda/truffle/scripts/Types.py"); - URL url = source.toURI().toURL(); - String sourcePath = source.getAbsolutePath(); - int debugLine = 39; - String methodName = "typesTest"; - JSLineBreakpoint lb1 = new TruffleLineBreakpoint(url, debugLine); - dm.addBreakpoint(lb1); - runScriptUnderJPDA("python", source.getAbsolutePath(), support -> { - JPDADebugger debugger = support.getDebugger(); - TruffleStackFrame frame = checkStoppedAtScript(debugger.getCurrentThread(), sourcePath, debugLine); - assertEquals("Bad method name", methodName, frame.getMethodName()); - checkVariableTypes(frame.getScopes()); - support.doContinue(); - }); - } - - private static void checkVariableTypes(TruffleScope[] scopes) { - assertTrue(scopes.length >= 1); - TruffleVariable[] variables = scopes[0].getVariables(); - checkVar(variables[0], "a", "list", "[1, 2, 3, 42]"); - - checkVar(variables[1], "b1", "bool", "True"); - checkVar(variables[2], "b2", "bool", "False"); - - checkVar(variables[3], "i", "int", "42"); - checkVar(variables[4], "s", "str", "'string'"); - checkVar(variables[5], "n", "NoneType", "None"); - checkVar(variables[6], "f", "function", null); - assertTrue(variables[6].getValue().toString(), variables[6].getValue().toString().contains("Callable")); - checkVar(variables[7], "d", "datetime", null); - checkVar(variables[8], "map", "dict", null); - } - - private static void checkVar(TruffleVariable variable, String name, String type, String value) { - assertEquals("Name", name, variable.getName()); - assertEquals("Type of " + name, type, variable.getType()); - if (value != null) { - assertEquals("Value of " + name, value, variable.getValue()); - } - } - -} diff --git a/java/debugger.jpda.truffle/test/unit/src/org/netbeans/modules/debugger/jpda/truffle/DebugRTest.java b/java/debugger.jpda.truffle/test/unit/src/org/netbeans/modules/debugger/jpda/truffle/DebugRTest.java deleted file mode 100644 index 89bb8f75e932..000000000000 --- a/java/debugger.jpda.truffle/test/unit/src/org/netbeans/modules/debugger/jpda/truffle/DebugRTest.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.netbeans.modules.debugger.jpda.truffle; - -import java.io.File; -import java.net.URL; -import junit.framework.Test; - -import org.netbeans.api.debugger.DebuggerManager; -import org.netbeans.api.debugger.jpda.JPDADebugger; -import org.netbeans.modules.debugger.jpda.truffle.breakpoints.TruffleLineBreakpoint; -import org.netbeans.modules.debugger.jpda.truffle.frames.TruffleStackFrame; -import org.netbeans.modules.debugger.jpda.truffle.vars.TruffleVariable; -import org.netbeans.modules.debugger.jpda.truffle.vars.impl.TruffleScope; -import org.netbeans.modules.javascript2.debug.breakpoints.JSLineBreakpoint; - -public class DebugRTest extends JPDATestCase { - - public DebugRTest(String name) { - super(name); - } - - public static Test suite() { - return createSuite(DebugRTest.class); - } - - public void testRTypes() throws Exception { - DebuggerManager dm = DebuggerManager.getDebuggerManager(); - File source = new File(sourceRoot, "org/netbeans/modules/debugger/jpda/truffle/scripts/Types.r"); - URL url = source.toURI().toURL(); - String sourcePath = source.getAbsolutePath(); - int debugLine = 38; - String methodName = "typesTest"; - JSLineBreakpoint lb1 = new TruffleLineBreakpoint(url, debugLine); - dm.addBreakpoint(lb1); - runScriptUnderJPDA("Rscript", source.getAbsolutePath(), support -> { - JPDADebugger debugger = support.getDebugger(); - TruffleStackFrame frame = checkStoppedAtScript(debugger.getCurrentThread(), sourcePath, debugLine); - assertTrue("Bad method name: " + frame.getMethodName(), frame.getMethodName().contains(methodName)); - checkVariableTypes(frame.getScopes()); - support.doContinue(); - }); - } - - private static void checkVariableTypes(TruffleScope[] scopes) { - assertEquals(1, scopes.length); - TruffleVariable[] variables = scopes[0].getVariables(); - - checkVar(variables[0], "a", "double", "[1] 1 2 3 42"); - checkVar(variables[1], "b1", "logical", "[1] TRUE"); - checkVar(variables[2], "b2", "logical", "[1] FALSE"); - - checkVar(variables[3], "i", "double", "[1] 42"); - checkVar(variables[4], "s", "character", "[1] \"string\""); - checkVar(variables[5], "n", "NULL", "NULL"); - checkVar(variables[6], "f", "closure", "function() {\n\n}"); - checkVar(variables[7], "d", "double", null); - checkVar(variables[8], "map", "environment", null); - } - - private static void checkVar(TruffleVariable variable, String name, String type, String value) { - assertEquals("Name", name, variable.getName()); - assertEquals("Type of " + name, type, variable.getType()); - if (value != null) { - assertEquals("Value of " + name, value, variable.getValue()); - } - } - -} diff --git a/java/debugger.jpda.truffle/test/unit/src/org/netbeans/modules/debugger/jpda/truffle/DebugRubyTest.java b/java/debugger.jpda.truffle/test/unit/src/org/netbeans/modules/debugger/jpda/truffle/DebugRubyTest.java deleted file mode 100644 index 0897675c23e6..000000000000 --- a/java/debugger.jpda.truffle/test/unit/src/org/netbeans/modules/debugger/jpda/truffle/DebugRubyTest.java +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.netbeans.modules.debugger.jpda.truffle; - -import java.io.File; -import java.net.URL; -import junit.framework.Test; - -import org.netbeans.api.debugger.DebuggerManager; -import org.netbeans.api.debugger.jpda.JPDADebugger; -import org.netbeans.modules.debugger.jpda.truffle.breakpoints.TruffleLineBreakpoint; -import org.netbeans.modules.debugger.jpda.truffle.frames.TruffleStackFrame; -import org.netbeans.modules.debugger.jpda.truffle.vars.TruffleVariable; -import org.netbeans.modules.debugger.jpda.truffle.vars.impl.TruffleScope; -import org.netbeans.modules.javascript2.debug.breakpoints.JSLineBreakpoint; - -public class DebugRubyTest extends JPDATestCase { - - public DebugRubyTest(String name) { - super(name); - } - - public static Test suite() { - return createSuite(DebugRubyTest.class); - } - - public void testRubyTypes() throws Exception { - DebuggerManager dm = DebuggerManager.getDebuggerManager(); - File source = new File(sourceRoot, "org/netbeans/modules/debugger/jpda/truffle/scripts/Types.ruby"); - URL url = source.toURI().toURL(); - String sourcePath = source.getAbsolutePath(); - int debugLine = 46; - String methodName = "typesTest"; - JSLineBreakpoint lb1 = new TruffleLineBreakpoint(url, debugLine); - dm.addBreakpoint(lb1); - runScriptUnderJPDA("ruby", source.getAbsolutePath(), support -> { - JPDADebugger debugger = support.getDebugger(); - TruffleStackFrame frame = checkStoppedAtScript(debugger.getCurrentThread(), sourcePath, debugLine); - assertTrue("Bad method name: " + frame.getMethodName(), frame.getMethodName().contains(methodName)); - checkVariableTypes(frame.getScopes()); - support.doContinue(); - }); - } - - private static void checkVariableTypes(TruffleScope[] scopes) { - assertEquals(1, scopes.length); - TruffleVariable[] variables = scopes[0].getVariables(); - assertEquals("self", variables[0].getName()); - checkVar(variables[1], "a1", "Array", "[]"); - checkVar(variables[2], "a2", "Array", "[1, 2, [3, 4]]"); - - checkVar(variables[3], "b1", "", "true"); - checkVar(variables[4], "b2", "", "false"); - - checkVar(variables[5], "null", "NilClass", "nil"); - - checkVar(variables[6], "i1", "", "0"); - checkVar(variables[7], "i2", "", "42"); - checkVar(variables[8], "i3", "", "42.42"); - checkVar(variables[9], "i4", "", "-0.0"); - checkVar(variables[10], "i5", "", "-Infinity"); - checkVar(variables[11], "i6", "", "Infinity"); - checkVar(variables[12], "i7", "", "-Infinity"); - checkVar(variables[13], "i8", "", "NaN"); - - checkVar(variables[14], "nc", "Complex", "(2+3i)"); - checkVar(variables[15], "nr", "Rational", "(11/2)"); - checkVar(variables[16], "f", "Method", null); - assertTrue(variables[16].getValue().toString(), variables[16].getValue().toString().contains("Callable")); - checkVar(variables[17], "d", "Time", null); - checkVar(variables[18], "str", "String", "\"A String\""); - checkVar(variables[19], "symbol", "Symbol", ":symbolic"); - checkVar(variables[20], "hash", "Hash", "{:a=>1, \"b\"=>2}"); - } - - private static void checkVar(TruffleVariable variable, String name, String type, String value) { - assertEquals("Name", name, variable.getName()); - assertEquals("Type of " + name, type, variable.getType()); - if (value != null) { - assertEquals("Value of " + name, value, variable.getValue()); - } - } - -} diff --git a/java/debugger.jpda.truffle/test/unit/src/org/netbeans/modules/debugger/jpda/truffle/JPDATestCase.java b/java/debugger.jpda.truffle/test/unit/src/org/netbeans/modules/debugger/jpda/truffle/JPDATestCase.java index a8d16ac5b191..2438a6ef306d 100644 --- a/java/debugger.jpda.truffle/test/unit/src/org/netbeans/modules/debugger/jpda/truffle/JPDATestCase.java +++ b/java/debugger.jpda.truffle/test/unit/src/org/netbeans/modules/debugger/jpda/truffle/JPDATestCase.java @@ -19,9 +19,13 @@ package org.netbeans.modules.debugger.jpda.truffle; import java.io.File; +import java.io.IOException; +import java.util.Arrays; +import java.util.Map; import java.util.logging.Level; import junit.framework.Test; import junit.framework.TestCase; +import org.netbeans.api.debugger.jpda.DebuggerStartException; import org.netbeans.api.debugger.jpda.JPDADebugger; import org.netbeans.api.debugger.jpda.JPDASupport; import org.netbeans.api.debugger.jpda.JPDAThread; @@ -39,6 +43,10 @@ public abstract class JPDATestCase extends NbTestCase { + private static final Map LAUNCHER_TO_MAIN_CLASS = Map.of( + "js", "com.oracle.truffle.js.shell.JSLauncher" + ); + protected final File sourceRoot = new File(System.getProperty("test.dir.src")); protected static Test createSuite(Class clazz) { @@ -80,10 +88,10 @@ protected final File getJavaSourceFile(String javaFileName) { } protected final void runScriptUnderJPDA(String launcher, String scriptPath, ThrowableConsumer supportConsumer) throws Exception { - assertTrue("'"+launcher+"' launcher not available", JPDASupport.isLauncherAvailable(launcher)); + assertTrue("does not have launcher - main class mapping", LAUNCHER_TO_MAIN_CLASS.containsKey(launcher)); // Translate script path from source dir to target dir: scriptPath = getBinariesPath(scriptPath); - JPDASupport support = JPDASupport.attachScript(launcher, scriptPath); + JPDASupport support = attachScript(launcher, scriptPath); run(support, supportConsumer, false); } @@ -133,6 +141,15 @@ protected static TruffleVariable findVariable(TruffleScope scope, String name) { return null; } + public static JPDASupport attachScript(String launcher, String path) throws IOException, DebuggerStartException { + return JPDASupport.attach(LAUNCHER_TO_MAIN_CLASS.get(launcher), + new String[] {path}, + Arrays.stream(System.getProperty("java.class.path") + .split(File.pathSeparator)) + .map(loc -> new File(loc)) + .toArray(File[]::new)); + } + @FunctionalInterface protected interface ThrowableConsumer { diff --git a/java/debugger.jpda/test/unit/src/org/netbeans/api/debugger/jpda/JPDASupport.java b/java/debugger.jpda/test/unit/src/org/netbeans/api/debugger/jpda/JPDASupport.java index 0a2112f4696c..e9d174defc9f 100644 --- a/java/debugger.jpda/test/unit/src/org/netbeans/api/debugger/jpda/JPDASupport.java +++ b/java/debugger.jpda/test/unit/src/org/netbeans/api/debugger/jpda/JPDASupport.java @@ -209,50 +209,10 @@ public static JPDASupport attach (String[] vmArgs, String mainClass, String[] ar return new JPDASupport (jpdaDebugger, pio); } - public static JPDASupport attachScript(String launcher, String path) throws IOException, DebuggerStartException { - String [] cmdArray = new String [] { - launcherPath(launcher), - "--jvm", - "--vm.agentlib:jdwp=transport=dt_socket,suspend=y,server=y", - path - }; - Process process = Runtime.getRuntime ().exec (cmdArray); - String line = readLine (process.getInputStream ()); - int port = Integer.parseInt (line.substring (line.lastIndexOf (':') + 1).trim ()); - ProcessIO pio = new ProcessIO (process); - pio.go(); - - VirtualMachineManager vmm = Bootstrap.virtualMachineManager(); - List aconnectors = vmm.attachingConnectors(); - AttachingConnector connector = null; - for (Iterator i = aconnectors.iterator(); i.hasNext();) { - AttachingConnector ac = (AttachingConnector) i.next(); - Transport t = ac.transport (); - if (t != null && t.name().equals("dt_socket")) { - connector = ac; - break; - } - } - if (connector == null) { - throw new RuntimeException("No attaching socket connector available"); - } - - JPDADebugger jpdaDebugger = JPDADebugger.attach ( - "localhost", - port, - new Object[]{} - ); - 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 ........................................................ public void doContinue () {