History

My first initial commit with all of mine experimental changes.

Dmitry Kabak (userdima committed 13 years ago

Commit d37b88d1 parent 3f5b46618352 files · +2598093 −-8690Browse files

Showing the changes to java/pkg/com/sun/tools/jdi/RawCommandLineLauncher.java (1 of 18352 files). Show all

Unified · Split

java/pkg/com/sun/tools/jdi/RawCommandLineLauncher.java+132−0
@@ -0,0 +1,132 @@
1+/*
2+ * Copyright (c) 1999, 2004, Oracle and/or its affiliates. All rights reserved.
3+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+ *
5+ * This code is free software; you can redistribute it and/or modify it
6+ * under the terms of the GNU General Public License version 2 only, as
7+ * published by the Free Software Foundation. Oracle designates this
8+ * particular file as subject to the "Classpath" exception as provided
9+ * by Oracle in the LICENSE file that accompanied this code.
10+ *
11+ * This code is distributed in the hope that it will be useful, but WITHOUT
12+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+ * version 2 for more details (a copy is included in the LICENSE file that
15+ * accompanied this code).
16+ *
17+ * You should have received a copy of the GNU General Public License version
18+ * 2 along with this work; if not, write to the Free Software Foundation,
19+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20+ *
21+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22+ * or visit www.oracle.com if you need additional information or have any
23+ * questions.
24+ */
25+
26+package com.sun.tools.jdi;
27+
28+import com.sun.tools.jdi.*;
29+import com.sun.jdi.connect.*;
30+import com.sun.jdi.connect.spi.*;
31+import com.sun.jdi.VirtualMachine;
32+import java.util.Map;
33+import java.io.IOException;
34+
35+public class RawCommandLineLauncher extends AbstractLauncher implements LaunchingConnector {
36+
37+ static private final String ARG_COMMAND = "command";
38+ static private final String ARG_ADDRESS = "address";
39+ static private final String ARG_QUOTE = "quote";
40+
41+ TransportService transportService;
42+ Transport transport;
43+
44+ public TransportService transportService() {
45+ return transportService;
46+ }
47+
48+ public Transport transport() {
49+ return transport;
50+ }
51+
52+ public RawCommandLineLauncher() {
53+ super();
54+
55+ try {
56+ Class c = Class.forName("com.sun.tools.jdi.SharedMemoryTransportService");
57+ transportService = (TransportService)c.newInstance();
58+ transport = new Transport() {
59+ public String name() {
60+ return "dt_shmem";
61+ }
62+ };
63+ } catch (ClassNotFoundException x) {
64+ } catch (UnsatisfiedLinkError x) {
65+ } catch (InstantiationException x) {
66+ } catch (IllegalAccessException x) {
67+ };
68+
69+ if (transportService == null) {
70+ transportService = new SocketTransportService();
71+ transport = new Transport() {
72+ public String name() {
73+ return "dt_socket";
74+ }
75+ };
76+ }
77+
78+ addStringArgument(
79+ ARG_COMMAND,
80+ getString("raw.command.label"),
81+ getString("raw.command"),
82+ "",
83+ true);
84+ addStringArgument(
85+ ARG_QUOTE,
86+ getString("raw.quote.label"),
87+ getString("raw.quote"),
88+ "\"",
89+ true);
90+
91+ addStringArgument(
92+ ARG_ADDRESS,
93+ getString("raw.address.label"),
94+ getString("raw.address"),
95+ "",
96+ true);
97+ }
98+
99+
100+ public VirtualMachine
101+ launch(Map<String,? extends Connector.Argument> arguments)
102+ throws IOException, IllegalConnectorArgumentsException,
103+ VMStartException
104+ {
105+ String command = argument(ARG_COMMAND, arguments).value();
106+ String address = argument(ARG_ADDRESS, arguments).value();
107+
108+ String quote = argument(ARG_QUOTE, arguments).value();
109+
110+ if (quote.length() > 1) {
111+ throw new IllegalConnectorArgumentsException("Invalid length",
112+ ARG_QUOTE);
113+ }
114+
115+ TransportService.ListenKey listener = transportService.startListening(address);
116+
117+ try {
118+ return launch(tokenizeCommand(command, quote.charAt(0)),
119+ address, listener, transportService);
120+ } finally {
121+ transportService.stopListening(listener);
122+ }
123+ }
124+
125+ public String name() {
126+ return "com.sun.jdi.RawCommandLineLaunch";
127+ }
128+
129+ public String description() {
130+ return getString("raw.description");
131+ }
132+}