File: DebugeeArgumentHandler.java

package info (click to toggle)
openjdk-25 25.0.1%2B8-1~deb13u1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 825,408 kB
  • sloc: java: 5,585,680; cpp: 1,333,948; xml: 1,321,242; ansic: 488,034; asm: 404,003; objc: 21,088; sh: 15,106; javascript: 13,265; python: 8,319; makefile: 2,518; perl: 357; awk: 351; pascal: 103; exp: 83; sed: 72; jsp: 24
file content (784 lines) | stat: -rw-r--r-- 25,829 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
/*
 * Copyright (c) 2001, 2025, Oracle and/or its affiliates. All rights reserved.
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 *
 * This code is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License version 2 only, as
 * published by the Free Software Foundation.
 *
 * This code is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 * version 2 for more details (a copy is included in the LICENSE file that
 * accompanied this code).
 *
 * You should have received a copy of the GNU General Public License version
 * 2 along with this work; if not, write to the Free Software Foundation,
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 *
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 * or visit www.oracle.com if you need additional information or have any
 * questions.
 */

package nsk.share.jpda;

import nsk.share.*;

import java.io.*;
import java.net.ServerSocket;

/**
 * Parser for JPDA test's launching and connection arguments.
 * <p>
 * <Code>DebugeeArgumentHandler</code> handles specific JDI/JDWP/JDB tests
 * command line arguments related to launching and connection parameters
 * for debugee VM in addition to general arguments recognized by
 * <code>ArgumentParser</code>.
 * <p>
 * Following is the list of specific options for
 * <code>DebugeeAgrumentHandler</code>:
 * <ul>
 * <li> <code>-test.host=</code>&lt;<i>host</i>&gt; -
 *   address of a host where test executes
 * <li> <code>-debugee.host=</code>&lt;<i>host</i>&gt; -
 *   address of a host where debugee VM executes
 * <li> <code>-connector=[attaching|listening]</code> -
 *   connector type to connect to debugee VM
 * <li> <code>-transport=[socket|shmem]</code> -
 *   transport type to connect to debugee VM
 * <li> <code>-transport.port=</code>&lt;<i>port</i>&gt; -
 *   port number for <code>socket</code> transport
 * <li> <code>-transport.shname=</code>&lt;<i>name</i>&gt; -
 *   shared memory name for <code>shmem</code> transport
 * <li> <code>-transport.address=</code>&lt;<i>dynamic</i>&gt; -
 *   use dynamically allocated unique transport address for JDWP connection
 *   ignoring settings for <code>-transport.port</code> and <code>-transport.shname</code>
 *   (this works only with <code>-connector=listening</code> and <code>-transport=socket</code>)
 * <li> <code>-debugee.suspend=[yes|no|default]</code> -
 *   should debugee start in suspend mode or not
 * <li> <code>-debugee.vmhome=</code>&lt;<i>path</i>&gt; -
 *   path to JDK used for launching debugee VM
 * <li> <code>-debugee.vmkind=</code>&lt;<i>name</i>&gt; -
 *   name of debugee VM launcher executable
 * <li> <code>-debugee.vmkeys=</code>&lt;<i>string</i>&gt; -
 *   additional options for launching debugee VM
 * <li> <code>-jvmdi.strict=[yes|no|default]</code> -
 *   using JVMDI strict mode
 * <li> <code>-pipe.port=</code>&lt;<i>port</i>&gt; -
 *   port number for internal IOPipe connection
 * <li> <code>-bind.port=</code>&lt;<i>port</i>&gt; -
 *   port number for BindServer connection
 * </ul>
 * <p>
 * See also list of basic options recognized by
 * <code>ArgumentParser</code>.
 * <p>
 * See also comments to <code>ArgumentParser</code> for list of general
 * recognized options and how to work with command line arguments and options.
 *
 * @see ArgumentParser
 * @see nsk.share.jdi.ArgumentHandler
 * @see nsk.share.jdwp.ArgumentHandler
 */
public class DebugeeArgumentHandler extends ArgumentParser {

    public static final String DEFAULT_PIPE_PORT      = "7123";
    public static final String DEFAULT_TRANSPORT_PORT = "8123";
    public static final String DEFAULT_BIND_PORT      = "9123";


    /**
     * Keep a copy of raw command-line arguments and parse them;
     * but throw an exception on parsing error.
     *
     * @param  args  Array of the raw command-line arguments.
     *
     * @throws  BadOption  If unknown option or illegal
     *                     option value found
     *
     * @see #setRawArguments(String[])
     */
    public DebugeeArgumentHandler(String args[]) {
        super(args);
    }

    /**
     * Return <i>true</i> if <code>-includevirtualthreads</code> command line option
     * is specified.
     *
     * @see #setRawArguments(String[])
     */
    public boolean isIncludeVirtualThreads() {
        return options.getProperty("includevirtualthreads") != null;
    }

    /**
     * Return name of the host where test executes, specified by
     * <code>-test.host</code> command line option or
     * empty string (represents an address of the loopback interface) by default.
     *
     * @see #setRawArguments(String[])
     */
    public String getTestHost() {
        return options.getProperty("test.host", "");
    }

    /**
     * Return name of host where the debugee VM is executed, specified by
     * <code>-debugee.host</code> command line option or value of
     * getTestHost() by default.
     *
     * @see #getTestHost()
     * @see #setRawArguments(String[])
     */
    public String getDebugeeHost() {
        return options.getProperty("debugee.host", getTestHost());
    }

    private boolean transportPortInited = false;
    /**
     * Return string representation of port number for socket transport,
     * specified by <code>-tranport.port</code> command line option or
     * "<code>DEFAULT_TRANSPORT_PORT</code>" string by default.
     *
     * @see #getTransportPortIfNotDynamic()
     * @see #getTransportPortNumber()
     * @see #setTransportPortNumber(int)
     * @see #setRawArguments(String[])
     */
    synchronized public String getTransportPort() {
        String port = options.getProperty("transport.port");
        if (port == null) {
            if (!transportPortInited) {
                port = findFreePort();
                if (port == null) {
                    port = DEFAULT_TRANSPORT_PORT;
                }
                options.setProperty("transport.port", port);
                transportPortInited = true;
            }
        }
        return port;
    }

    /**
     * Return string representation of port number for socket transport,
     * specified by <code>-tranport.port</code> command line option or
     * "<code>DEFAULT_TRANSPORT_PORT</code>" string by default in case transport address is
     * not dynamic.
     * Otherwise null is returned.
     *
     * @see #getTransportPort()
     * @see #getTransportPortNumber()
     * @see #setTransportPortNumber(int)
     * @see #setRawArguments(String[])
     */
    public String getTransportPortIfNotDynamic() {
        return ( isTransportAddressDynamic() ?
                    null : getTransportPort() );
    }

    /**
     * Return string port number for socket transport,
     * specified by <code>-debugee.port</code> command line option or
     * <code>DEFAULT_TRANSPORT_PORT</code> port number by default.
     *
     * @see #getTransportPort()
     * @see #getTransportPortIfNotDynamic()
     * @see #setTransportPortNumber(int)
     * @see #setRawArguments(String[])
     */
    public int getTransportPortNumber() {
        String value = getTransportPort();
        try {
            return Integer.parseInt(value);
        } catch (NumberFormatException e) {
            throw new TestBug("Not integer value of \"-transport.port\" argument: " + value);
        }
    }

    /**
     * Add or replace value of option <code>-transport.port</code> in options list
     * with the specified port number.
     *
     * @see #getTransportPortNumber()
     * @see #setRawArguments(String[])
     */
    public void setTransportPortNumber(int port) {
        String value = Integer.toString(port);
        setOption("-", "transport.port", value);
    }

    /**
     * Return shared name for shmem transport, specified by
     * <code>-transport.shname</code> command line option, or
     * "<i>nskjpdatestchannel</i>" + a process unique string by default.
     *
     * @see #setTransportSharedName(String)
     * @see #setRawArguments(String[])
     */
    // Use a unique id for this process by default. This makes sure that
    // tests running concurrently do not use the same shared name.
    private static String defaultTransportSharedName
            = "nskjpdatestchannel" + ProcessHandle.current().pid();
    public String getTransportSharedName() {
        return options.getProperty("transport.shname", defaultTransportSharedName);
    }

    /**
     * Add or replace value of option <code>-transport.shname</code> in options list
     * with the specified name.
     *
     * @see #getTransportSharedName()
     * @see #setRawArguments(String[])
     */
    public void setTransportSharedName(String name) {
        setOption("-", "transport.shname", name);
    }

    /**
     * Return <i>true</i> if <code>-transport.address=dynamic</code> command line option
     * is specified.
     *
     * @see #setRawArguments(String[])
     */
    public boolean isTransportAddressDynamic() {
        String value = options.getProperty("transport.address", null);
        if (value != null && value.equals("dynamic"))
            return true;
        return false;
    }

    /**
     * Return suspend mode for launching debugee VM, specified by
     * <code>-debugee.suspend</code> command line option, or
     * "<i>default</i>" string by default.
     *
     * @see #isDefaultDebugeeSuspendMode()
     * @see #willDebugeeSuspended()
     * @see #setRawArguments(String[])
     */
    public String getDebugeeSuspendMode() {
        return options.getProperty("debugee.suspend", "default");
    }

    /**
     * Return <i>true</i> if default suspend mode is used
     * for launching debugee VM.
     *
     * @see #getDebugeeSuspendMode()
     * @see #willDebugeeSuspended()
     */
    public boolean isDefaultDebugeeSuspendMode() {
        String mode = getDebugeeSuspendMode();
        return mode.equals("default");
    }

    /**
     * Return <i>true</i> if debugee VM will be suspended after launching,
     * either according to specified suspend mode or by default.
     *
     * @see #getDebugeeSuspendMode()
     * @see #isDefaultDebugeeSuspendMode()
     */
    public boolean willDebugeeSuspended() {
        String mode = getDebugeeSuspendMode();
        return mode.equals("no");
    }

    private boolean pipePortInited = false;
    /**
     * Return string representation of the port number for IOPipe connection,
     * specified by <code>-pipe.port</code> command line option, or
     * "<i>DEFAULT_PIPE_PORT</i>" string by default.
     *
     * @see #getPipePortNumber()
     * @see #setPipePortNumber(int)
     * @see #setRawArguments(String[])
     */
    synchronized public String getPipePort() {
        String port = options.getProperty("pipe.port");
        if (port == null) {
            if (!pipePortInited) {
                port = findFreePort();
                if (port == null) {
                    port = DEFAULT_PIPE_PORT;
                }
                pipePortInited = true;
                options.setProperty("pipe.port", port);
            }
        }
        return port;
    }

    /**
     * Return port number for IOPipe connection,
     * specified by <code>-pipe.port</code> command line option, or
     * <i>DEFAULT_PIPE_PORT</i> port number by default.
     *
     * @see #getPipePort()
     * @see #setPipePortNumber(int)
     * @see #setRawArguments(String[])
     */
    public int getPipePortNumber() {
        String value = getPipePort();
        try {
            return Integer.parseInt(value);
        } catch (NumberFormatException e) {
            throw new TestBug("Not integer value of \"-pipe.port\" argument: " + value);
        }
    }

    /**
     * Add or replace value of option <code>-pipe.port</code> in options list
     * with the specified port number.
     *
     * @see #getPipePortNumber()
     * @see #setRawArguments(String[])
     */
    public void setPipePortNumber(int port) {
        String value = Integer.toString(port);
        setOption("-", "pipe.port", value);
    }


    /**
     * Return additional options for launching debugee VM, specified by
     * <code>-launch.options</code> command line option, or
     * empty string by default.
     *
     * @see #setRawArguments(String[])
     */
    public String getLaunchOptions() {
        String result = options.getProperty("debugee.vmkeys", "").trim();
        if (result.startsWith("\"") && result.endsWith("\"")) {
            result = result.substring(1, result.length() - 1);
        }
        return result;
    }

    /**
     * Return name of debugee VM launcher executable, specified by
     * <code>-launch.vmexec</code> command line option, or
     * "<i>java</i>" string by default.
     *
     * @see #setRawArguments(String[])
     */
    public String getLaunchExecName() {
        return options.getProperty("debugee.vmkind", "java");
    }

    /**
     * Return full path to debugee VM launcher executable.
     *
     * @see #getLaunchExecName()
     * @see #getLaunchExecPath(String)
     * @see #getDebugeeJavaHome()
     */
    public String getLaunchExecPath() {
        String java_home = getDebugeeJavaHome();
        return getLaunchExecPath(java_home);
    }

    /**
     * Return full path to VM launcher executable using givet JAVA_HOME path.
     *
     * @see #getLaunchExecName()
     */
    public String getLaunchExecPath(String java_home) {
        String filesep = System.getProperty("file.separator");
        return java_home + filesep + "bin" + filesep + getLaunchExecName();
    }

    /**
     * Return full JAVA_HOME path for debugee VM.
     *
     * @see #getLaunchExecName()
     */
    public String getDebugeeJavaHome() {
        String java_home = System.getProperty("java.home");
        return options.getProperty("debugee.vmhome", java_home);
    }

    /**
     * Return true if default debuggee VM launcher executable is used.
     *
     * @see #getLaunchExecName()
     */
    public boolean isDefaultLaunchExecName() {
        String vmkind = options.getProperty("debugee.vmkind", null);
        return (vmkind == null);
    }

    /**
     * Return true if default JAVA_HOME path for debuggee VM is used.
     *
     * @see #getDebugeeJavaHome()
     */
    public boolean isDefaultDebugeeJavaHome() {
        String java_home = options.getProperty("debugee.vmhome", null);
        return (java_home == null);
    }

    private boolean bindPortInited = false;
    /**
     * Return string representation of the port number for BindServer connection,
     * specified by <code>-bind.port</code> command line option, or
     * "<i>DEFAULT_BIND_PORT</i>" string by default.
     *
     * @see #getBindPortNumber()
     * @see #setRawArguments(String[])
     */
    public String getBindPort() {
        String port = options.getProperty("bind.port");
        if (port == null) {
            if (!bindPortInited) {
                port = findFreePort();
                if (port == null) {
                    port = DEFAULT_BIND_PORT;
                }
                options.setProperty("bind.port", port);
                bindPortInited = true;
            }
        }
        return port;
    }

    /**
     * Return port number for BindServer connection,
     * specified by <code>-bind.port</code> command line option, or
     * "<i>DEFAULT_BIND_PORT</i>" port number by default.
     *
     * @see #getBindPort()
     * @see #setRawArguments(String[])
     */
    public int getBindPortNumber() {
        String value = getBindPort();
        try {
            return Integer.parseInt(value);
        } catch (NumberFormatException e) {
            throw new TestBug("Not integer value of \"bind.port\" argument: " + value);
        }
    }

    /**
     * Return JVMDI strict mode for launching debugee VM, specified by.
     * <code>-jvmdi.strict</code> command line option, or
     * "<i>default</i>" string by default.
     *
     * Possible values for this option are:
     * <ul>
     * <li> "<code>yes</code>"
     * <li> "<code>no</code>"
     * <li> "<code>default</code>"
     * </ul>
     *
     * @see #setRawArguments(String[])
     */
    public String getJVMDIStrictMode() {
        return options.getProperty("jvmdi.strict", "default");
    }

    /**
     * Return <i>true</i> if JVMDI strict mode for launching debugeeVM is used
     * either by specifying in command line or by default.
     *
     * @see #getJVMDIStrictMode()
     * @see #isDefaultJVMDIStrictMode()
     * @see #setRawArguments(String[])
     */
    public boolean isJVMDIStrictMode() {
        String mode = getJVMDIStrictMode();
        return mode.equals("yes");
    }

    /**
     * Return <i>true</i> if JVMDI default strict mode for launching debugee VM is used.
     *
     * @see #getJVMDIStrictMode()
     * @see #isJVMDIStrictMode()
     * @see #setRawArguments(String[])
     */
    public boolean isDefaultJVMDIStrictMode() {
        String mode = getJVMDIStrictMode();
        return mode.equals("default");
    }

    /**
     * Return type of JDI connector used for connecting to debugee VM, specified by
     * <code>-connector</code> command line option, or
     * "<i>listening</i>" string by default.
     *
     * Possible values for this option are:
     * <ul>
     * <li> "<code>attaching</code>"
     * <li> "<code>listening</code>"
     * </ul>
     *
     * @see #isAttachingConnector()
     * @see #isListeningConnector()
     * @see #setRawArguments(String[])
     */
    public String getConnectorType() {
        return options.getProperty("connector", "listening");
    }

    /**
     * Return <i>true</i> if type of the used JDI connector is <code>attaching</code>.
     *
     * @see #getConnectorType()
     */
    public boolean isAttachingConnector() {
        return getConnectorType().equals("attaching");
    }

    /**
     * Return <i>true</i> if type of the used JDI connector is <code>listening</code>.
     *
     * @see #getConnectorType()
     */
    public boolean isListeningConnector() {
        return getConnectorType().equals("listening");
    }

    /**
     * Return <i>true</i> if connector type is not actually specified.
     * In this case getConnectorType() returns some default connector type.
     *
     * @see #getConnectorType()
     */
    public boolean isDefaultConnector() {
        return options.getProperty("connector") == null;
    }

    /**
     * Return type of JDWP transport for connecting to debugee VM, specified by
     * <code>-transport</code> command line option, or
     * "<i>socket</i>" string by default.
     *
     * Possible values for this option are:
     * <ul>
     * <li> "<code>socket</code>"
     * <li> "<code>shmem</code>"
     * </ul>
     *
     * @see #getTransportName()
     * @see #isSocketTransport()
     * @see #isShmemTransport()
     * @see #setRawArguments(String[])
     */
    public String getTransportType() {
        return options.getProperty("transport", "socket");
    }

    /**
     * Return transport name corresponding to the used JDWP transport type.
     *
     * @see #getTransportType()
     */
    public String getTransportName() {
        if (isSocketTransport()) {
            return "dt_socket";
        } else if (isShmemTransport()) {
            return "dt_shmem";
        } else {
            throw new TestBug("Undefined transport type");
        }
    }

    /**
     * Return <i>true</i> if the used JDWP transport type is <code>socket</code>,
     * either by specifying in command line or as a platform default transport.
     *
     * @see #getTransportType()
     */
    public boolean isSocketTransport() {
        String transport = getTransportType();
        return transport.equals("socket");
    }

    /**
     * Return <i>true</i> if the used JDWP transport type is <code>shmem</code>,
     * either by specifying in command line or as a platform default transport.
     *
     * @see #getTransportType()
     */
    public boolean isShmemTransport() {
        String transport = getTransportType();
        return transport.equals("shmem");
    }

    /**
     * Return <i>true</i> if transport type is not actually specified.
     * In this case getTransportType() returns some default transport kind.
     *
     * @see #getTransportType()
     */
    public boolean isDefaultTransport() {
        return options.getProperty("transport") == null;
    }

    /**
     * Create <code>Log</code> for debugee application using command line options.
     */
    public Log createDebugeeLog() {
        return new Log(System.err, this);
    };

    /**
     * Create IOPipe for debugee application using command line options.
     */
    public IOPipe createDebugeeIOPipe() {
        return createDebugeeIOPipe(createDebugeeLog());
    };

    /**
     * Create IOPipe for debugee application using connection
     * parameters from the command line and specify Log.
     */
    public IOPipe createDebugeeIOPipe(Log log) {
        return new IOPipe(this, log);
    };

    /**
     * Check if an option is aloowed and has proper value.
     * This method is invoked by <code>parseArgumentss()</code>
     *
     * @param option option name
     * @param value string representation of value
     *                      (could be an empty string too)
     *              null if this option has no value
     * @return <i>true</i> if option is allowed and has proper value
     *         <i>false</i> if otion is not admissible
     *
     * @throws <i>BadOption</i> if option has an illegal value
     *
     * @see #parseArguments()
     */
    protected boolean checkOption(String option, String value) {

        if (option.equals("traceAll")
            || option.equals("includevirtualthreads")) {
            if (!(value == null || value.length() == 0)) {
                throw new BadOption(option + ": no value must be specified");
            }
           return true;
        }

        // option with any string value
        if (option.equals("debugee.vmkeys")) {
            return true;
        }

        // option with any nonempty string value
        if (option.equals("debugee.vmkind")
            || option.equals("debugee.vmhome")
            || option.equals("transport.shname")) {
            if (value.length() <= 0) {
                throw new BadOption(option + ": cannot be an empty string");
            }
            return true;
        }

        // option with positive integer port value
        if (option.equals("transport.port")
            || option.equals("bind.port")
            || option.equals("pipe.port")) {
            try {
                int number = Integer.parseInt(value);
                if (number < 0) {
                    throw new BadOption(option + ": must be a positive integer");
                }
            } catch (NumberFormatException e) {
                throw new BadOption(option + ": must be an integer");
            }
            return true;
        }

        // options with enumerated values

        if (option.equals("debugee.suspend")) {
            if ((!value.equals("yes"))
                && (!value.equals("no"))
                && (!value.equals("default"))) {
                throw new BadOption(option + ": must be one of: "
                                           + "yes, no, default");
            }
            return true;
        }

        if (option.equals("debugee.launch")
                || option.equals("debugee.host")
                || option.equals("test.host")) {
            throw new RuntimeException("option " + option + " is not supported.");
        }

        if (option.equals("jvmdi.strict")) {
            if ((!value.equals("yes"))
                && (!value.equals("no"))
                && (!value.equals("default"))) {
                throw new BadOption(option + ": must be one of: "
                                           + "yes, no, default");
            }
            return true;
        }

        if (option.equals("transport")) {
            if ((!value.equals("socket"))
                && (!value.equals("shmem"))) {
                throw new BadOption(option + ": must be one of: "
                                           + "socket, shmem");
            }
            return true;
        }

        if (option.equals("connector")) {
            if ((!value.equals("attaching"))
                && (!value.equals("listening"))) {
                throw new BadOption(option + ": value must be one of: "
                                           + "attaching, listening");
            }
            return true;
        }

        if (option.equals("transport.address")) {
            if (!value.equals("dynamic")) {
                throw new BadOption(option + ": must be only: "
                                           + "dynamic");
            }
            return true;
        }

        return super.checkOption(option, value);
    }

    /**
     * Check if the values of all options are consistent.
     * This method is invoked by <code>parseArguments()</code>
     *
     * @throws <i>BadOption</i> if options have inconsistent values
     *
     * @see #parseArguments()
     */
    protected void checkOptions() {
        super.checkOptions();
    }

    private String findFreePort() {
        ServerSocket ss = null;
        try {
            ss = new ServerSocket(0);
            return String.valueOf(ss.getLocalPort());
        } catch (IOException e) {
            return null;
        } finally {
            try {
                ss.close();
            } catch (Throwable t) {
                // ignore
            }
        }
    }

} // DebugeeArgumentHandler