vscode-java-debug
vscode-java-debug copied to clipboard
Refactor the launch connector design for launch and attach debugging
- For the launch debugging, we provide two kinds of implementation: SocketLaunchingConnector and ListeningConnector. Need revisit the design to see whether to keep using one kind of implementation.
- For the attach debugging, support both Socket Attach and Socket Listen. See #415
Hi @testforstephen, I'm an AI Support assistant here to help with your issue. While the team reviews your request, I wanted to provide some possible tips and documentation that might help you in the meantime.
Suggestions for refactoring the connector design:
- Introduce a common Connector interface or abstract base class that encapsulates shared logic (e.g., JDWP handshake, argument parsing).
- Implement LaunchConnector and AttachConnector as concrete classes, delegating socket-attach vs socket-listen modes via a configuration flag or factory method.
- For launch mode, consolidate SocketLaunchingConnector and ListeningConnector into a single LaunchConnector with a “mode” option if both behaviors must be preserved.
- For attach mode, support both “socketAttach” and “socketListen” by wiring them through the same AttachConnector implementation.
- Ensure the VS Code launch.json supports both modes, e.g.:
{ "type": "java", "name": "Attach", "request": "attach", "hostName": "localhost", "port": "<debug port>", "mode": "socketAttach", // or "socketListen" "preLaunchTask": "<your launch task>" }
Other references with low confidence:
See also
- “Cannot debug JDK17 itself with "Debugger for Java" v0.49.1”: describes an attach-mode sample configuration. https://github.com/microsoft/vscode-java-debug/issues/1330#issuecomment-1522735228
The team will respond to your issue shortly. I hope these suggestions are helpful in the meantime. If this comment helped you, please give it a 👍. If the suggestion was not helpful or incorrect, please give it a 👎. Your feedback helps us improve!