langtools/src/jdk.jshell/share/classes/jdk/jshell/execution/FailOverExecutionControlProvider.java
author jlahoda
Tue, 09 May 2017 12:22:15 +0200
changeset 45044 7c50549b7744
parent 44683 610dc2b48954
permissions -rw-r--r--
8179531: JShell: fails to provide bytecode for dynamically created lambdas Summary: Adding support for getResource(s) to the JShell's ClassLoader Reviewed-by: psandoz, rfield
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
42969
a48d4f74d322 8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
diff changeset
     1
/*
a48d4f74d322 8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
diff changeset
     2
 * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
a48d4f74d322 8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a48d4f74d322 8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
diff changeset
     4
 *
a48d4f74d322 8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
a48d4f74d322 8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
a48d4f74d322 8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
a48d4f74d322 8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
a48d4f74d322 8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
a48d4f74d322 8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
diff changeset
    10
 *
a48d4f74d322 8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
a48d4f74d322 8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a48d4f74d322 8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
a48d4f74d322 8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
a48d4f74d322 8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
diff changeset
    15
 * accompanied this code).
a48d4f74d322 8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
diff changeset
    16
 *
a48d4f74d322 8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
a48d4f74d322 8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
a48d4f74d322 8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a48d4f74d322 8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
diff changeset
    20
 *
a48d4f74d322 8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
a48d4f74d322 8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
a48d4f74d322 8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
diff changeset
    23
 * questions.
a48d4f74d322 8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
diff changeset
    24
 */
a48d4f74d322 8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
diff changeset
    25
a48d4f74d322 8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
diff changeset
    26
package jdk.jshell.execution;
a48d4f74d322 8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
diff changeset
    27
a48d4f74d322 8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
diff changeset
    28
import java.io.PrintWriter;
a48d4f74d322 8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
diff changeset
    29
import java.io.StringWriter;
a48d4f74d322 8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
diff changeset
    30
import java.util.HashMap;
a48d4f74d322 8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
diff changeset
    31
import java.util.Map;
a48d4f74d322 8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
diff changeset
    32
import java.util.logging.Level;
a48d4f74d322 8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
diff changeset
    33
import java.util.logging.Logger;
a48d4f74d322 8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
diff changeset
    34
import jdk.jshell.spi.ExecutionControl;
a48d4f74d322 8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
diff changeset
    35
import jdk.jshell.spi.ExecutionControlProvider;
a48d4f74d322 8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
diff changeset
    36
import jdk.jshell.spi.ExecutionEnv;
a48d4f74d322 8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
diff changeset
    37
a48d4f74d322 8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
diff changeset
    38
/**
a48d4f74d322 8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
diff changeset
    39
 * Tries other providers in sequence until one works.
43770
a321bed02000 8174762: JShell: @since tags missing
rfield
parents: 43566
diff changeset
    40
 *
a321bed02000 8174762: JShell: @since tags missing
rfield
parents: 43566
diff changeset
    41
 * @since 9
42969
a48d4f74d322 8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
diff changeset
    42
 */
a48d4f74d322 8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
diff changeset
    43
public class FailOverExecutionControlProvider  implements ExecutionControlProvider{
a48d4f74d322 8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
diff changeset
    44
a48d4f74d322 8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
diff changeset
    45
    private Logger logger = null;
a48d4f74d322 8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
diff changeset
    46
a48d4f74d322 8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
diff changeset
    47
    /**
a48d4f74d322 8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
diff changeset
    48
     * Create an instance. The instance can be used to start and return an
a48d4f74d322 8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
diff changeset
    49
     * {@link ExecutionControl} instance by attempting to start a series of
a48d4f74d322 8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
diff changeset
    50
     * {@code ExecutionControl} specs, until one is successful.
a48d4f74d322 8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
diff changeset
    51
     *
a48d4f74d322 8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
diff changeset
    52
     * @see #generate(jdk.jshell.spi.ExecutionEnv, java.util.Map)
a48d4f74d322 8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
diff changeset
    53
     */
a48d4f74d322 8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
diff changeset
    54
    public FailOverExecutionControlProvider() {
a48d4f74d322 8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
diff changeset
    55
    }
a48d4f74d322 8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
diff changeset
    56
a48d4f74d322 8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
diff changeset
    57
    /**
a48d4f74d322 8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
diff changeset
    58
     * The unique name of this {@code ExecutionControlProvider}.
a48d4f74d322 8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
diff changeset
    59
     *
a48d4f74d322 8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
diff changeset
    60
     * @return "failover"
a48d4f74d322 8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
diff changeset
    61
     */
a48d4f74d322 8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
diff changeset
    62
    @Override
a48d4f74d322 8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
diff changeset
    63
    public String name() {
a48d4f74d322 8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
diff changeset
    64
        return "failover";
a48d4f74d322 8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
diff changeset
    65
    }
a48d4f74d322 8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
diff changeset
    66
a48d4f74d322 8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
diff changeset
    67
    /**
a48d4f74d322 8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
diff changeset
    68
     * Create and return the default parameter map for this
a48d4f74d322 8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
diff changeset
    69
     * {@code ExecutionControlProvider}. There are ten parameters, "0" through
a48d4f74d322 8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
diff changeset
    70
     * "9", their values are {@code ExecutionControlProvider} specification
a48d4f74d322 8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
diff changeset
    71
     * strings, or empty string.
a48d4f74d322 8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
diff changeset
    72
     *
a48d4f74d322 8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
diff changeset
    73
     * @return a default parameter map
a48d4f74d322 8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
diff changeset
    74
     */
a48d4f74d322 8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
diff changeset
    75
    @Override
a48d4f74d322 8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
diff changeset
    76
    public Map<String, String> defaultParameters() {
a48d4f74d322 8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
diff changeset
    77
        Map<String, String> dp = new HashMap<>();
a48d4f74d322 8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
diff changeset
    78
        dp.put("0", "jdi");
a48d4f74d322 8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
diff changeset
    79
        for (int i = 1; i <= 9; ++i) {
a48d4f74d322 8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
diff changeset
    80
            dp.put("" + i, "");
a48d4f74d322 8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
diff changeset
    81
        }
a48d4f74d322 8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
diff changeset
    82
        return dp;
a48d4f74d322 8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
diff changeset
    83
    }
a48d4f74d322 8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
diff changeset
    84
a48d4f74d322 8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
diff changeset
    85
    /**
a48d4f74d322 8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
diff changeset
    86
     * Create and return a locally executing {@code ExecutionControl} instance.
a48d4f74d322 8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
diff changeset
    87
     * At least one parameter should have a spec.
a48d4f74d322 8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
diff changeset
    88
     *
a48d4f74d322 8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
diff changeset
    89
     * @param env the execution environment, provided by JShell
a48d4f74d322 8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
diff changeset
    90
     * @param parameters the modified parameter map.
a48d4f74d322 8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
diff changeset
    91
     * @return the execution engine
a48d4f74d322 8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
diff changeset
    92
     * @throws Throwable if all the given providers fail, the exception that
a48d4f74d322 8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
diff changeset
    93
     * occurred on the first attempt to create the execution engine.
a48d4f74d322 8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
diff changeset
    94
     */
a48d4f74d322 8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
diff changeset
    95
    @Override
a48d4f74d322 8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
diff changeset
    96
    public ExecutionControl generate(ExecutionEnv env, Map<String, String> parameters)
a48d4f74d322 8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
diff changeset
    97
            throws Throwable {
a48d4f74d322 8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
diff changeset
    98
        Throwable thrown = null;
a48d4f74d322 8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
diff changeset
    99
        for (int i = 0; i <= 9; ++i) {
a48d4f74d322 8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
diff changeset
   100
            String param = parameters.get("" + i);
a48d4f74d322 8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
diff changeset
   101
            if (param != null && !param.isEmpty()) {
a48d4f74d322 8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
diff changeset
   102
                try {
a48d4f74d322 8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
diff changeset
   103
                    ExecutionControl ec =  ExecutionControl.generate(env, param);
a48d4f74d322 8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
diff changeset
   104
                    logger().finest(
a48d4f74d322 8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
diff changeset
   105
                            String.format("FailOverExecutionControlProvider: Success %s -- %d = %s\n",
a48d4f74d322 8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
diff changeset
   106
                                    name(), i, param));
a48d4f74d322 8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
diff changeset
   107
                    return ec;
a48d4f74d322 8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
diff changeset
   108
                } catch (Throwable ex) {
a48d4f74d322 8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
diff changeset
   109
                    logger().warning(
a48d4f74d322 8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
diff changeset
   110
                            String.format("FailOverExecutionControlProvider: Failure %s -- %d = %s -- %s\n",
a48d4f74d322 8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
diff changeset
   111
                                    name(), i, param, ex.toString()));
a48d4f74d322 8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
diff changeset
   112
                    StringWriter writer = new StringWriter();
a48d4f74d322 8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
diff changeset
   113
                    PrintWriter log = new PrintWriter(writer);
a48d4f74d322 8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
diff changeset
   114
                    log.println("FailOverExecutionControlProvider:");
a48d4f74d322 8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
diff changeset
   115
                    ex.printStackTrace(log);
43566
71aef8336eaa 8173577: JShell tests: Some testng tests check nothing
rfield
parents: 42969
diff changeset
   116
                    log.flush();
71aef8336eaa 8173577: JShell tests: Some testng tests check nothing
rfield
parents: 42969
diff changeset
   117
                    logger().fine(writer.toString());
42969
a48d4f74d322 8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
diff changeset
   118
                    // only care about the first, and only if they all fail
a48d4f74d322 8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
diff changeset
   119
                    if (thrown == null) {
a48d4f74d322 8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
diff changeset
   120
                        thrown = ex;
a48d4f74d322 8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
diff changeset
   121
                    }
a48d4f74d322 8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
diff changeset
   122
                }
a48d4f74d322 8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
diff changeset
   123
            }
a48d4f74d322 8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
diff changeset
   124
a48d4f74d322 8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
diff changeset
   125
        }
a48d4f74d322 8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
diff changeset
   126
        logger().severe("FailOverExecutionControlProvider: Terminating, failovers exhausted");
a48d4f74d322 8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
diff changeset
   127
        if (thrown == null) {
a48d4f74d322 8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
diff changeset
   128
            throw new IllegalArgumentException("All least one parameter must be set to a provider.");
a48d4f74d322 8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
diff changeset
   129
        }
a48d4f74d322 8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
diff changeset
   130
        throw thrown;
a48d4f74d322 8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
diff changeset
   131
    }
a48d4f74d322 8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
diff changeset
   132
a48d4f74d322 8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
diff changeset
   133
    private Logger logger() {
a48d4f74d322 8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
diff changeset
   134
        if (logger == null) {
a48d4f74d322 8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
diff changeset
   135
            logger = Logger.getLogger("jdk.jshell.execution");
44683
610dc2b48954 8178023: jshell tool: crash with ugly message on attempt to add non-existant module path
rfield
parents: 43770
diff changeset
   136
            if (logger.getLevel() == null) {
610dc2b48954 8178023: jshell tool: crash with ugly message on attempt to add non-existant module path
rfield
parents: 43770
diff changeset
   137
                // Logging has not been specifically requested, turn it off
610dc2b48954 8178023: jshell tool: crash with ugly message on attempt to add non-existant module path
rfield
parents: 43770
diff changeset
   138
                logger.setLevel(Level.OFF);
610dc2b48954 8178023: jshell tool: crash with ugly message on attempt to add non-existant module path
rfield
parents: 43770
diff changeset
   139
            }
42969
a48d4f74d322 8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
diff changeset
   140
        }
a48d4f74d322 8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
diff changeset
   141
        return logger;
a48d4f74d322 8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
diff changeset
   142
    }
a48d4f74d322 8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
diff changeset
   143
a48d4f74d322 8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
diff changeset
   144
}