ppisl commented on a change in pull request #3350: URL: https://github.com/apache/netbeans/pull/3350#discussion_r763803443
########## File path: groovy/groovy.support/src/org/netbeans/modules/groovy/support/actions/singlefilerun/JPDAStart.java ########## @@ -0,0 +1,145 @@ +/* + * 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.groovy.support.actions.singlefilerun; + +import com.sun.jdi.Bootstrap; +import com.sun.jdi.connect.Connector; +import com.sun.jdi.connect.ListeningConnector; +import com.sun.jdi.connect.Transport; +import java.io.File; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; +import java.util.logging.Level; +import java.util.logging.Logger; +import org.netbeans.api.debugger.jpda.DebuggerStartException; +import org.netbeans.api.debugger.jpda.JPDADebugger; +import org.netbeans.api.java.classpath.ClassPath; +import org.netbeans.spi.java.classpath.support.ClassPathSupport; +import org.openide.filesystems.FileObject; +import org.openide.filesystems.FileUtil; +import org.openide.util.RequestProcessor; +import org.openide.windows.InputOutput; + +// This class is copy of org.netbeans.modules.java.api.common.singlesourcefile.JPDAStart +/** + * Start the JPDA debugger. + * + * @author Arunava Sinha + */ +public class JPDAStart implements Runnable { + + static final Logger LOG = Logger.getLogger(JPDAStart.class.getPackage().getName()); + + private static final RequestProcessor RP = new RequestProcessor(JPDAStart.class); + private static final String TRANSPORT = "dt_socket"; //NOI18N + + private final Object[] lock = new Object[2]; + private final InputOutput io; + private final FileObject fileObject; + + JPDAStart(InputOutput inputOutput, FileObject fileObject) { + io = inputOutput; + this.fileObject = fileObject; + } + + /** + * returns the port that the debugger listens to.. + */ + public String execute() throws Exception { + LOG.log(Level.INFO, "JPDA Listening Start"); //NOI18N + synchronized (lock) { + RP.post(this); + lock.wait(); + if (lock[1] != null) { + throw ((Exception) lock[1]); //NOI18N + } + } + return (String) lock[0]; + } + + @Override + public void run() { + synchronized (lock) { + + try { + + ListeningConnector lc = null; + Iterator i = Bootstrap.virtualMachineManager(). + listeningConnectors().iterator(); + for (; i.hasNext();) { + lc = (ListeningConnector) i.next(); + Transport t = lc.transport(); + if (t != null && t.name().equals(getTransport())) { + break; + } + } + if (lc == null) { + throw new RuntimeException("No trasports named " + getTransport() + " found!"); //NOI18N + } + + final Map args = lc.defaultArguments(); + String address = lc.startListening(args); + try { + int port = Integer.parseInt(address.substring(address.indexOf(':') + 1)); + Connector.IntegerArgument portArg = (Connector.IntegerArgument) args.get("port"); //NOI18N + portArg.setValue(port); + lock[0] = Integer.toString(port); + } catch (NumberFormatException e) { + lock[0] = address; + } + LOG.log(Level.INFO, "Debug Port:{0}", lock[0]); //NOI18N + + final Map properties = new HashMap(); + + ClassPath sourcePath = ClassPathSupport.createClassPath(fileObject.getParent()); + ClassPath jdkPath = ClassPathSupport.createClassPath(System.getProperty("java.class.path")); Review comment: It is no there now. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected] For further information about the NetBeans mailing lists, visit: https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
