jdk/test/java/rmi/testlibrary/JavaVM.java
author amurillo
Wed, 15 Aug 2012 16:49:38 -0700
changeset 13465 d3fc5d192448
parent 12692 72f0847dd477
child 16094 ac85c7fc438d
child 14342 8435a30053c1
permissions -rw-r--r--
7191765: make jdk8 the default jprt release for hs24 Reviewed-by: jcoomes
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     2
 * Copyright (c) 1998, 2006, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    21
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    22
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import java.io.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import java.util.Arrays;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import java.util.Properties;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
import java.util.StringTokenizer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
 * RMI regression test utility class that uses Runtime.exec to spawn a
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 * java process that will run a named java class.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
public class JavaVM {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
    protected Process vm = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
    private String classname = "";
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
    private String args = "";
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
    private String options = "";
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
    private OutputStream outputStream = System.out;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
    private OutputStream errorStream = System.err;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
    private String policyFileName = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
12692
72f0847dd477 7144861: speed up RMI activation tests
olagneau
parents: 5506
diff changeset
    48
    // This is used to shorten waiting time at startup.
72f0847dd477 7144861: speed up RMI activation tests
olagneau
parents: 5506
diff changeset
    49
    private volatile boolean started = false;
72f0847dd477 7144861: speed up RMI activation tests
olagneau
parents: 5506
diff changeset
    50
    private boolean forcesOutput = true; // default behavior
72f0847dd477 7144861: speed up RMI activation tests
olagneau
parents: 5506
diff changeset
    51
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
    private static void mesg(Object mesg) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
        System.err.println("JAVAVM: " + mesg.toString());
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
    /** string name of the program execd by JavaVM */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
    private static String javaProgram = "java";
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
    static {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
            javaProgram = TestLibrary.getProperty("java.home", "") +
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
                File.separator + "bin" + File.separator + javaProgram;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
        } catch (SecurityException se) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
    public JavaVM(String classname) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
        this.classname = classname;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
    public JavaVM(String classname,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
                  String options, String args) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
        this.classname = classname;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
        this.options = options;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
        this.args = args;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
    public JavaVM(String classname,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
                  String options, String args,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
                  OutputStream out, OutputStream err) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
        this(classname, options, args);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
        this.outputStream = out;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
        this.errorStream = err;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
12692
72f0847dd477 7144861: speed up RMI activation tests
olagneau
parents: 5506
diff changeset
    85
    /* This constructor will instantiate a JavaVM object for which caller
72f0847dd477 7144861: speed up RMI activation tests
olagneau
parents: 5506
diff changeset
    86
     * can ask for forcing initial version output on child vm process
72f0847dd477 7144861: speed up RMI activation tests
olagneau
parents: 5506
diff changeset
    87
     * (if forcesVersionOutput is true), or letting the started vm behave freely
72f0847dd477 7144861: speed up RMI activation tests
olagneau
parents: 5506
diff changeset
    88
     * (when forcesVersionOutput is false).
72f0847dd477 7144861: speed up RMI activation tests
olagneau
parents: 5506
diff changeset
    89
     */
72f0847dd477 7144861: speed up RMI activation tests
olagneau
parents: 5506
diff changeset
    90
    public JavaVM(String classname,
72f0847dd477 7144861: speed up RMI activation tests
olagneau
parents: 5506
diff changeset
    91
                  String options, String args,
72f0847dd477 7144861: speed up RMI activation tests
olagneau
parents: 5506
diff changeset
    92
                  OutputStream out, OutputStream err,
72f0847dd477 7144861: speed up RMI activation tests
olagneau
parents: 5506
diff changeset
    93
                  boolean forcesVersionOutput) {
72f0847dd477 7144861: speed up RMI activation tests
olagneau
parents: 5506
diff changeset
    94
        this(classname, options, args, out, err);
72f0847dd477 7144861: speed up RMI activation tests
olagneau
parents: 5506
diff changeset
    95
        this.forcesOutput = forcesVersionOutput;
72f0847dd477 7144861: speed up RMI activation tests
olagneau
parents: 5506
diff changeset
    96
    }
72f0847dd477 7144861: speed up RMI activation tests
olagneau
parents: 5506
diff changeset
    97
72f0847dd477 7144861: speed up RMI activation tests
olagneau
parents: 5506
diff changeset
    98
72f0847dd477 7144861: speed up RMI activation tests
olagneau
parents: 5506
diff changeset
    99
    public void setStarted() {
72f0847dd477 7144861: speed up RMI activation tests
olagneau
parents: 5506
diff changeset
   100
        started = true;
72f0847dd477 7144861: speed up RMI activation tests
olagneau
parents: 5506
diff changeset
   101
    }
72f0847dd477 7144861: speed up RMI activation tests
olagneau
parents: 5506
diff changeset
   102
72f0847dd477 7144861: speed up RMI activation tests
olagneau
parents: 5506
diff changeset
   103
    // Prepends passed opts array to current options
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
    public void addOptions(String[] opts) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
        String newOpts = "";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
        for (int i = 0 ; i < opts.length ; i ++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
            newOpts += " " + opts[i];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
        newOpts += " ";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
        options = newOpts + options;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
    }
12692
72f0847dd477 7144861: speed up RMI activation tests
olagneau
parents: 5506
diff changeset
   112
72f0847dd477 7144861: speed up RMI activation tests
olagneau
parents: 5506
diff changeset
   113
    // Prepends passed arguments array to current args
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
    public void addArguments(String[] arguments) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
        String newArgs = "";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
        for (int i = 0 ; i < arguments.length ; i ++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
            newArgs += " " + arguments[i];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
        newArgs += " ";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
        args = newArgs + args;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
    public void setPolicyFile(String policyFileName) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
        this.policyFileName = policyFileName;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
     * This method is used for setting VM options on spawned VMs.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
     * It returns the extra command line options required
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
     * to turn on jcov code coverage analysis.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
    protected static String getCodeCoverageOptions() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
        return TestLibrary.getExtraProperty("jcov.options","");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
     * Exec the VM as specified in this object's constructor.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
    public void start() throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
        if (vm != null) return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
        /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
         * If specified, add option for policy file
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
        if (policyFileName != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
            String option = "-Djava.security.policy=" + policyFileName;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
            addOptions(new String[] { option });
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
        addOptions(new String[] { getCodeCoverageOptions() });
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
12692
72f0847dd477 7144861: speed up RMI activation tests
olagneau
parents: 5506
diff changeset
   154
        /*
72f0847dd477 7144861: speed up RMI activation tests
olagneau
parents: 5506
diff changeset
   155
         * If forcesOutput is true :
72f0847dd477 7144861: speed up RMI activation tests
olagneau
parents: 5506
diff changeset
   156
         *  We force the new starting vm to output something so that we can know
72f0847dd477 7144861: speed up RMI activation tests
olagneau
parents: 5506
diff changeset
   157
         *  when it is effectively started by redirecting standard output through
72f0847dd477 7144861: speed up RMI activation tests
olagneau
parents: 5506
diff changeset
   158
         *  the next StreamPipe call (the vm is considered started when a first
72f0847dd477 7144861: speed up RMI activation tests
olagneau
parents: 5506
diff changeset
   159
         *  output has been streamed out).
72f0847dd477 7144861: speed up RMI activation tests
olagneau
parents: 5506
diff changeset
   160
         *  We do this by prepnding a "-showversion" option in the command line.
72f0847dd477 7144861: speed up RMI activation tests
olagneau
parents: 5506
diff changeset
   161
         */
72f0847dd477 7144861: speed up RMI activation tests
olagneau
parents: 5506
diff changeset
   162
        if (forcesOutput) {
72f0847dd477 7144861: speed up RMI activation tests
olagneau
parents: 5506
diff changeset
   163
            addOptions(new String[] {"-showversion"});
72f0847dd477 7144861: speed up RMI activation tests
olagneau
parents: 5506
diff changeset
   164
        }
72f0847dd477 7144861: speed up RMI activation tests
olagneau
parents: 5506
diff changeset
   165
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
        StringTokenizer optionsTokenizer = new StringTokenizer(options);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
        StringTokenizer argsTokenizer = new StringTokenizer(args);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
        int optionsCount = optionsTokenizer.countTokens();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
        int argsCount = argsTokenizer.countTokens();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
        String javaCommand[] = new String[optionsCount + argsCount + 2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
        int count = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
        javaCommand[count++] = JavaVM.javaProgram;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
        while (optionsTokenizer.hasMoreTokens()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
            javaCommand[count++] = optionsTokenizer.nextToken();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
        javaCommand[count++] = classname;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
        while (argsTokenizer.hasMoreTokens()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
            javaCommand[count++] = argsTokenizer.nextToken();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
        mesg("command = " + Arrays.asList(javaCommand).toString());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
        System.err.println("");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
        vm = Runtime.getRuntime().exec(javaCommand);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
        /* output from the execed process may optionally be captured. */
12692
72f0847dd477 7144861: speed up RMI activation tests
olagneau
parents: 5506
diff changeset
   189
        StreamPipe.plugTogether(this, vm.getInputStream(), this.outputStream);
72f0847dd477 7144861: speed up RMI activation tests
olagneau
parents: 5506
diff changeset
   190
        StreamPipe.plugTogether(this, vm.getErrorStream(), this.errorStream);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
        try {
12692
72f0847dd477 7144861: speed up RMI activation tests
olagneau
parents: 5506
diff changeset
   193
            if (forcesOutput) {
72f0847dd477 7144861: speed up RMI activation tests
olagneau
parents: 5506
diff changeset
   194
                // Wait distant vm to start, by using waiting time slices of 100 ms.
72f0847dd477 7144861: speed up RMI activation tests
olagneau
parents: 5506
diff changeset
   195
                // Wait at most for 2secs, after it considers the vm to be started.
72f0847dd477 7144861: speed up RMI activation tests
olagneau
parents: 5506
diff changeset
   196
                final long vmStartSleepTime = 100;
72f0847dd477 7144861: speed up RMI activation tests
olagneau
parents: 5506
diff changeset
   197
                final int maxTrials = 20;
72f0847dd477 7144861: speed up RMI activation tests
olagneau
parents: 5506
diff changeset
   198
                int numTrials = 0;
72f0847dd477 7144861: speed up RMI activation tests
olagneau
parents: 5506
diff changeset
   199
                while (!started && numTrials < maxTrials) {
72f0847dd477 7144861: speed up RMI activation tests
olagneau
parents: 5506
diff changeset
   200
                    numTrials++;
72f0847dd477 7144861: speed up RMI activation tests
olagneau
parents: 5506
diff changeset
   201
                    Thread.sleep(vmStartSleepTime);
72f0847dd477 7144861: speed up RMI activation tests
olagneau
parents: 5506
diff changeset
   202
                }
72f0847dd477 7144861: speed up RMI activation tests
olagneau
parents: 5506
diff changeset
   203
72f0847dd477 7144861: speed up RMI activation tests
olagneau
parents: 5506
diff changeset
   204
                // Outputs running status of distant vm
72f0847dd477 7144861: speed up RMI activation tests
olagneau
parents: 5506
diff changeset
   205
                String message =
72f0847dd477 7144861: speed up RMI activation tests
olagneau
parents: 5506
diff changeset
   206
                    "after " + (numTrials * vmStartSleepTime) + " milliseconds";
72f0847dd477 7144861: speed up RMI activation tests
olagneau
parents: 5506
diff changeset
   207
                if (started) {
72f0847dd477 7144861: speed up RMI activation tests
olagneau
parents: 5506
diff changeset
   208
                    mesg("distant vm process running, " + message);
72f0847dd477 7144861: speed up RMI activation tests
olagneau
parents: 5506
diff changeset
   209
                }
72f0847dd477 7144861: speed up RMI activation tests
olagneau
parents: 5506
diff changeset
   210
                else {
72f0847dd477 7144861: speed up RMI activation tests
olagneau
parents: 5506
diff changeset
   211
                    mesg("unknown running status of distant vm process, " + message);
72f0847dd477 7144861: speed up RMI activation tests
olagneau
parents: 5506
diff changeset
   212
                }
72f0847dd477 7144861: speed up RMI activation tests
olagneau
parents: 5506
diff changeset
   213
            }
72f0847dd477 7144861: speed up RMI activation tests
olagneau
parents: 5506
diff changeset
   214
            else {
72f0847dd477 7144861: speed up RMI activation tests
olagneau
parents: 5506
diff changeset
   215
                // Since we have no way to know if the distant vm is started,
72f0847dd477 7144861: speed up RMI activation tests
olagneau
parents: 5506
diff changeset
   216
                // we just consider the vm to be started after a 2secs waiting time.
72f0847dd477 7144861: speed up RMI activation tests
olagneau
parents: 5506
diff changeset
   217
                Thread.sleep(2000);
72f0847dd477 7144861: speed up RMI activation tests
olagneau
parents: 5506
diff changeset
   218
                mesg("distant vm considered to be started after a waiting time of 2 secs");
72f0847dd477 7144861: speed up RMI activation tests
olagneau
parents: 5506
diff changeset
   219
            }
72f0847dd477 7144861: speed up RMI activation tests
olagneau
parents: 5506
diff changeset
   220
        } catch (InterruptedException e) {
72f0847dd477 7144861: speed up RMI activation tests
olagneau
parents: 5506
diff changeset
   221
            Thread.currentThread().interrupt();
72f0847dd477 7144861: speed up RMI activation tests
olagneau
parents: 5506
diff changeset
   222
            mesg("Thread interrupted while checking if distant vm is started. Giving up check.");
72f0847dd477 7144861: speed up RMI activation tests
olagneau
parents: 5506
diff changeset
   223
            mesg("Distant vm state unknown");
72f0847dd477 7144861: speed up RMI activation tests
olagneau
parents: 5506
diff changeset
   224
            return;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
    public void destroy() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
        if (vm != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
            vm.destroy();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
        vm = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
    protected Process getVM() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
        return vm;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
}