mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-08 15:09:39 +07:00
removed unused class
This commit is contained in:
@@ -1,94 +0,0 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed 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 com.intellij.debugger.apiAdapters;
|
||||
|
||||
import com.intellij.execution.ExecutionException;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import com.sun.jdi.connect.spi.TransportService;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
|
||||
/**
|
||||
* @author max
|
||||
*/
|
||||
public class TransportServiceWrapper {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.debugger.apiAdapters.TransportService");
|
||||
|
||||
private final TransportService myTransport;
|
||||
private final Class<? extends TransportService> myDelegateClass;
|
||||
|
||||
private static final String SOCKET_TRANSPORT_CLASS = "com.sun.tools.jdi.SocketTransportService";
|
||||
private static final String SHMEM_TRANSPORT_CLASS = "com.sun.tools.jdi.SharedMemoryTransportService";
|
||||
|
||||
private TransportServiceWrapper(Class<? extends TransportService> delegateClass) throws NoSuchMethodException,
|
||||
IllegalAccessException,
|
||||
InvocationTargetException,
|
||||
InstantiationException {
|
||||
myDelegateClass = delegateClass;
|
||||
final Constructor constructor = delegateClass.getDeclaredConstructor(ArrayUtil.EMPTY_CLASS_ARRAY);
|
||||
constructor.setAccessible(true);
|
||||
myTransport = (TransportService)constructor.newInstance(ArrayUtil.EMPTY_OBJECT_ARRAY);
|
||||
}
|
||||
|
||||
public TransportService.ListenKey startListening() throws IOException {
|
||||
return myTransport.startListening();
|
||||
}
|
||||
|
||||
public TransportService.ListenKey startListening(String address) throws IOException {
|
||||
return myTransport.startListening(address);
|
||||
}
|
||||
|
||||
public void stopListening(final TransportService.ListenKey address) throws IOException {
|
||||
myTransport.stopListening(address);
|
||||
}
|
||||
|
||||
@SuppressWarnings({"HardCodedStringLiteral"})
|
||||
public String transportId() {
|
||||
if (SOCKET_TRANSPORT_CLASS.equals(myDelegateClass.getName())) {
|
||||
return "dt_socket";
|
||||
}
|
||||
if (SHMEM_TRANSPORT_CLASS.equals(myDelegateClass.getName())) {
|
||||
return "dt_shmem";
|
||||
}
|
||||
LOG.error("Unknown service");
|
||||
return "<unknown>";
|
||||
}
|
||||
|
||||
public static TransportServiceWrapper getTransportService(boolean forceSocketTransport) throws ExecutionException {
|
||||
TransportServiceWrapper transport;
|
||||
try {
|
||||
try {
|
||||
if (forceSocketTransport) {
|
||||
transport = new TransportServiceWrapper((Class<? extends TransportService>)Class.forName(SOCKET_TRANSPORT_CLASS));
|
||||
}
|
||||
else {
|
||||
transport = new TransportServiceWrapper((Class<? extends TransportService>)Class.forName(SHMEM_TRANSPORT_CLASS));
|
||||
}
|
||||
}
|
||||
catch (UnsatisfiedLinkError ignored) {
|
||||
transport = new TransportServiceWrapper((Class<? extends TransportService>)Class.forName(SOCKET_TRANSPORT_CLASS));
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw new ExecutionException(e.getClass().getName() + " : " + e.getMessage());
|
||||
}
|
||||
return transport;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -307,13 +307,7 @@ public abstract class DebugProcessImpl extends UserDataHolderBase implements Deb
|
||||
return;
|
||||
}
|
||||
if(myConnection.isServerMode()) {
|
||||
ListeningConnector connector = (ListeningConnector)findConnector(SOCKET_LISTENING_CONNECTOR_NAME);
|
||||
if (connector == null) {
|
||||
LOG.error("Cannot find connector: " + SOCKET_LISTENING_CONNECTOR_NAME);
|
||||
}
|
||||
else {
|
||||
connector.stopListening(arguments);
|
||||
}
|
||||
((ListeningConnector)findConnector(SOCKET_LISTENING_CONNECTOR_NAME)).stopListening(arguments);
|
||||
}
|
||||
}
|
||||
catch (IOException | IllegalConnectorArgumentsException e) {
|
||||
@@ -450,11 +444,7 @@ public abstract class DebugProcessImpl extends UserDataHolderBase implements Deb
|
||||
|
||||
final String address = myConnection.getAddress();
|
||||
if (myConnection.isServerMode()) {
|
||||
ListeningConnector connector = (ListeningConnector)findConnector(
|
||||
myConnection.isUseSockets() ? SOCKET_LISTENING_CONNECTOR_NAME : SHMEM_LISTENING_CONNECTOR_NAME);
|
||||
if (connector == null) {
|
||||
throw new CantRunException(DebuggerBundle.message("error.debug.connector.not.found", DebuggerBundle.getTransportName(myConnection)));
|
||||
}
|
||||
ListeningConnector connector = (ListeningConnector)findConnector(myConnection.isUseSockets(), true);
|
||||
myArguments = connector.defaultArguments();
|
||||
if (myArguments == null) {
|
||||
throw new CantRunException(DebuggerBundle.message("error.no.debug.listen.port"));
|
||||
@@ -507,13 +497,7 @@ public abstract class DebugProcessImpl extends UserDataHolderBase implements Deb
|
||||
}
|
||||
}
|
||||
else { // is client mode, should attach to already running process
|
||||
AttachingConnector connector = (AttachingConnector)findConnector(
|
||||
myConnection.isUseSockets() ? SOCKET_ATTACHING_CONNECTOR_NAME : SHMEM_ATTACHING_CONNECTOR_NAME
|
||||
);
|
||||
|
||||
if (connector == null) {
|
||||
throw new CantRunException( DebuggerBundle.message("error.debug.connector.not.found", DebuggerBundle.getTransportName(myConnection)));
|
||||
}
|
||||
AttachingConnector connector = (AttachingConnector)findConnector(myConnection.isUseSockets(), false);
|
||||
myArguments = connector.defaultArguments();
|
||||
if (myConnection.isUseSockets()) {
|
||||
//noinspection HardCodedStringLiteral
|
||||
@@ -573,17 +557,31 @@ public abstract class DebugProcessImpl extends UserDataHolderBase implements Deb
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
static Connector findConnector(String connectorName) throws ExecutionException {
|
||||
@NotNull
|
||||
public static Connector findConnector(boolean useSockets, boolean listen) throws ExecutionException {
|
||||
if (listen) {
|
||||
return findConnector(useSockets ? SOCKET_LISTENING_CONNECTOR_NAME : SHMEM_LISTENING_CONNECTOR_NAME);
|
||||
}
|
||||
else {
|
||||
return findConnector(useSockets ? SOCKET_ATTACHING_CONNECTOR_NAME : SHMEM_ATTACHING_CONNECTOR_NAME);
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static Connector findConnector(String connectorName) throws ExecutionException {
|
||||
VirtualMachineManager virtualMachineManager;
|
||||
try {
|
||||
virtualMachineManager = Bootstrap.virtualMachineManager();
|
||||
}
|
||||
catch (Error e) {
|
||||
final String error = e.getClass().getName() + " : " + e.getLocalizedMessage();
|
||||
throw new ExecutionException(DebuggerBundle.message("debugger.jdi.bootstrap.error", error));
|
||||
throw new ExecutionException(DebuggerBundle.message("debugger.jdi.bootstrap.error",
|
||||
e.getClass().getName() + " : " + e.getLocalizedMessage()));
|
||||
}
|
||||
return StreamEx.of(virtualMachineManager.allConnectors()).findFirst(c -> connectorName.equals(c.name())).orElse(null);
|
||||
Connector connector = StreamEx.of(virtualMachineManager.allConnectors()).findFirst(c -> connectorName.equals(c.name())).orElse(null);
|
||||
if (connector == null) {
|
||||
throw new CantRunException(DebuggerBundle.message("error.debug.connector.not.found", connectorName));
|
||||
}
|
||||
return connector;
|
||||
}
|
||||
|
||||
private void checkVirtualMachineVersion(VirtualMachine vm) {
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
// Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
/*
|
||||
* Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
*/
|
||||
package com.intellij.debugger.impl;
|
||||
|
||||
import com.intellij.debugger.*;
|
||||
import com.intellij.debugger.apiAdapters.TransportServiceWrapper;
|
||||
import com.intellij.debugger.engine.*;
|
||||
import com.intellij.debugger.settings.CaptureSettingsProvider;
|
||||
import com.intellij.debugger.settings.DebuggerSettings;
|
||||
@@ -457,9 +458,9 @@ public class DebuggerManagerImpl extends DebuggerManagerEx implements Persistent
|
||||
address = debugPort;
|
||||
}
|
||||
|
||||
final TransportServiceWrapper transportService = TransportServiceWrapper.getTransportService(useSockets);
|
||||
final String debugAddress = debuggerInServerMode && useSockets ? LOCALHOST_ADDRESS_FALLBACK + ":" + address : address;
|
||||
String debuggeeRunProperties = "transport=" + transportService.transportId() + ",address=" + debugAddress;
|
||||
String debuggeeRunProperties =
|
||||
"transport=" + DebugProcessImpl.findConnector(useSockets, debuggerInServerMode).transport().name() + ",address=" + debugAddress;
|
||||
if (debuggerInServerMode) {
|
||||
debuggeeRunProperties += ",suspend=y,server=n";
|
||||
}
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
// Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
/*
|
||||
* Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
*/
|
||||
package com.intellij.debugger.impl;
|
||||
|
||||
import com.intellij.debugger.actions.DebuggerAction;
|
||||
import com.intellij.debugger.apiAdapters.TransportServiceWrapper;
|
||||
import com.intellij.debugger.engine.DebugProcess;
|
||||
import com.intellij.debugger.engine.DebugProcessImpl;
|
||||
import com.intellij.debugger.engine.StackFrameContext;
|
||||
@@ -38,12 +39,15 @@ import com.sun.jdi.InternalException;
|
||||
import com.sun.jdi.ObjectCollectedException;
|
||||
import com.sun.jdi.VMDisconnectedException;
|
||||
import com.sun.jdi.Value;
|
||||
import com.sun.jdi.connect.spi.TransportService;
|
||||
import com.sun.jdi.connect.Connector;
|
||||
import com.sun.jdi.connect.IllegalConnectorArgumentsException;
|
||||
import com.sun.jdi.connect.ListeningConnector;
|
||||
import org.jdom.Element;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
|
||||
public class DebuggerUtilsImpl extends DebuggerUtilsEx{
|
||||
public static final Key<PsiType> PSI_TYPE_KEY = Key.create("PSI_TYPE_KEY");
|
||||
@@ -181,15 +185,15 @@ public class DebuggerUtilsImpl extends DebuggerUtilsEx{
|
||||
return Integer.toString(freePort);
|
||||
}
|
||||
else {
|
||||
TransportServiceWrapper transportService = TransportServiceWrapper.getTransportService(false);
|
||||
ListeningConnector connector = (ListeningConnector)DebugProcessImpl.findConnector(false, true);
|
||||
try {
|
||||
return tryShmemConnect(transportService, null);
|
||||
return tryShmemConnect(connector, "");
|
||||
}
|
||||
catch (IOException e) {
|
||||
catch (Exception e) {
|
||||
int tryNum = 0;
|
||||
while (true) {
|
||||
try {
|
||||
return tryShmemConnect(transportService, "javadebug_" + (int)(Math.random() * 1000));
|
||||
return tryShmemConnect(connector, "javadebug_" + (int)(Math.random() * 1000));
|
||||
}
|
||||
catch (Exception ex) {
|
||||
if (tryNum++ > 10) {
|
||||
@@ -201,10 +205,12 @@ public class DebuggerUtilsImpl extends DebuggerUtilsEx{
|
||||
}
|
||||
}
|
||||
|
||||
private static String tryShmemConnect(TransportServiceWrapper transportService, String address) throws IOException {
|
||||
TransportService.ListenKey listenKey = transportService.startListening(address);
|
||||
address = listenKey.address();
|
||||
transportService.stopListening(listenKey);
|
||||
private static String tryShmemConnect(ListeningConnector connector, String address)
|
||||
throws IOException, IllegalConnectorArgumentsException {
|
||||
Map<String, Connector.Argument> map = connector.defaultArguments();
|
||||
map.get("name").setValue(address);
|
||||
address = connector.startListening(map);
|
||||
connector.stopListening(map);
|
||||
return address;
|
||||
}
|
||||
|
||||
|
||||
@@ -70,7 +70,7 @@ status.connect.failed=Failed to establish connection to the target VM, address:
|
||||
error.debugger.already.listening=Debugger is already listening
|
||||
transport.name.shared.memory=shared memory
|
||||
transport.name.socket=socket
|
||||
error.debug.connector.not.found=Cannot connect using transport ''{0}'': required connector not found. Check your JDK installation.
|
||||
error.debug.connector.not.found=Required connector ''{0}'' not found. Check your JDK installation.
|
||||
error.no.debug.listen.port=The port to listen at unspecified
|
||||
error.no.debug.attach.port=The port to attach to unspecified
|
||||
error.no.shmem.address=Shared memory address unspecified
|
||||
|
||||
Reference in New Issue
Block a user