langtools/test/jdk/jshell/DyingRemoteAgent.java
author rfield
Tue, 22 Nov 2016 19:24:02 -0800
changeset 42272 82e273c4f2b3
child 42969 a48d4f74d322
permissions -rw-r--r--
8169519: JShell: Handle start-up failures and hangs gracefully 8166581: JShell: locks forever if -R options is wrong 8169234: JShell: hangs on startup on some computers caused by hostname Reviewed-by: jlahoda
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
42272
82e273c4f2b3 8169519: JShell: Handle start-up failures and hangs gracefully
rfield
parents:
diff changeset
     1
/*
82e273c4f2b3 8169519: JShell: Handle start-up failures and hangs gracefully
rfield
parents:
diff changeset
     2
 * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
82e273c4f2b3 8169519: JShell: Handle start-up failures and hangs gracefully
rfield
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
82e273c4f2b3 8169519: JShell: Handle start-up failures and hangs gracefully
rfield
parents:
diff changeset
     4
 *
82e273c4f2b3 8169519: JShell: Handle start-up failures and hangs gracefully
rfield
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
82e273c4f2b3 8169519: JShell: Handle start-up failures and hangs gracefully
rfield
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
82e273c4f2b3 8169519: JShell: Handle start-up failures and hangs gracefully
rfield
parents:
diff changeset
     7
 * published by the Free Software Foundation.
82e273c4f2b3 8169519: JShell: Handle start-up failures and hangs gracefully
rfield
parents:
diff changeset
     8
 *
82e273c4f2b3 8169519: JShell: Handle start-up failures and hangs gracefully
rfield
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
82e273c4f2b3 8169519: JShell: Handle start-up failures and hangs gracefully
rfield
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
82e273c4f2b3 8169519: JShell: Handle start-up failures and hangs gracefully
rfield
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
82e273c4f2b3 8169519: JShell: Handle start-up failures and hangs gracefully
rfield
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
82e273c4f2b3 8169519: JShell: Handle start-up failures and hangs gracefully
rfield
parents:
diff changeset
    13
 * accompanied this code).
82e273c4f2b3 8169519: JShell: Handle start-up failures and hangs gracefully
rfield
parents:
diff changeset
    14
 *
82e273c4f2b3 8169519: JShell: Handle start-up failures and hangs gracefully
rfield
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
82e273c4f2b3 8169519: JShell: Handle start-up failures and hangs gracefully
rfield
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
82e273c4f2b3 8169519: JShell: Handle start-up failures and hangs gracefully
rfield
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
82e273c4f2b3 8169519: JShell: Handle start-up failures and hangs gracefully
rfield
parents:
diff changeset
    18
 *
82e273c4f2b3 8169519: JShell: Handle start-up failures and hangs gracefully
rfield
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
82e273c4f2b3 8169519: JShell: Handle start-up failures and hangs gracefully
rfield
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
82e273c4f2b3 8169519: JShell: Handle start-up failures and hangs gracefully
rfield
parents:
diff changeset
    21
 * questions.
82e273c4f2b3 8169519: JShell: Handle start-up failures and hangs gracefully
rfield
parents:
diff changeset
    22
 */
82e273c4f2b3 8169519: JShell: Handle start-up failures and hangs gracefully
rfield
parents:
diff changeset
    23
82e273c4f2b3 8169519: JShell: Handle start-up failures and hangs gracefully
rfield
parents:
diff changeset
    24
import jdk.jshell.JShell;
82e273c4f2b3 8169519: JShell: Handle start-up failures and hangs gracefully
rfield
parents:
diff changeset
    25
import jdk.jshell.execution.JdiDefaultExecutionControl;
82e273c4f2b3 8169519: JShell: Handle start-up failures and hangs gracefully
rfield
parents:
diff changeset
    26
import jdk.jshell.execution.RemoteExecutionControl;
82e273c4f2b3 8169519: JShell: Handle start-up failures and hangs gracefully
rfield
parents:
diff changeset
    27
import static jdk.jshell.execution.JdiDefaultExecutionControl.defaultTimeout;
82e273c4f2b3 8169519: JShell: Handle start-up failures and hangs gracefully
rfield
parents:
diff changeset
    28
82e273c4f2b3 8169519: JShell: Handle start-up failures and hangs gracefully
rfield
parents:
diff changeset
    29
class DyingRemoteAgent extends RemoteExecutionControl {
82e273c4f2b3 8169519: JShell: Handle start-up failures and hangs gracefully
rfield
parents:
diff changeset
    30
82e273c4f2b3 8169519: JShell: Handle start-up failures and hangs gracefully
rfield
parents:
diff changeset
    31
    static final boolean INFRA_VERIFY = false;
82e273c4f2b3 8169519: JShell: Handle start-up failures and hangs gracefully
rfield
parents:
diff changeset
    32
82e273c4f2b3 8169519: JShell: Handle start-up failures and hangs gracefully
rfield
parents:
diff changeset
    33
    public static void main(String[] args) throws Exception {
82e273c4f2b3 8169519: JShell: Handle start-up failures and hangs gracefully
rfield
parents:
diff changeset
    34
        if (INFRA_VERIFY) {
82e273c4f2b3 8169519: JShell: Handle start-up failures and hangs gracefully
rfield
parents:
diff changeset
    35
            RemoteExecutionControl.main(args);
82e273c4f2b3 8169519: JShell: Handle start-up failures and hangs gracefully
rfield
parents:
diff changeset
    36
        } else {
82e273c4f2b3 8169519: JShell: Handle start-up failures and hangs gracefully
rfield
parents:
diff changeset
    37
            System.exit(1);
82e273c4f2b3 8169519: JShell: Handle start-up failures and hangs gracefully
rfield
parents:
diff changeset
    38
        }
82e273c4f2b3 8169519: JShell: Handle start-up failures and hangs gracefully
rfield
parents:
diff changeset
    39
    }
82e273c4f2b3 8169519: JShell: Handle start-up failures and hangs gracefully
rfield
parents:
diff changeset
    40
82e273c4f2b3 8169519: JShell: Handle start-up failures and hangs gracefully
rfield
parents:
diff changeset
    41
    static JShell state(boolean isLaunch, String host) {
82e273c4f2b3 8169519: JShell: Handle start-up failures and hangs gracefully
rfield
parents:
diff changeset
    42
        return JShell.builder().executionEngine(
82e273c4f2b3 8169519: JShell: Handle start-up failures and hangs gracefully
rfield
parents:
diff changeset
    43
                JdiDefaultExecutionControl.create(
82e273c4f2b3 8169519: JShell: Handle start-up failures and hangs gracefully
rfield
parents:
diff changeset
    44
                        DyingRemoteAgent.class.getName(),
82e273c4f2b3 8169519: JShell: Handle start-up failures and hangs gracefully
rfield
parents:
diff changeset
    45
                        isLaunch,
82e273c4f2b3 8169519: JShell: Handle start-up failures and hangs gracefully
rfield
parents:
diff changeset
    46
                        host,
82e273c4f2b3 8169519: JShell: Handle start-up failures and hangs gracefully
rfield
parents:
diff changeset
    47
                        defaultTimeout())).build();
82e273c4f2b3 8169519: JShell: Handle start-up failures and hangs gracefully
rfield
parents:
diff changeset
    48
    }
82e273c4f2b3 8169519: JShell: Handle start-up failures and hangs gracefully
rfield
parents:
diff changeset
    49
}