langtools/src/jdk.jshell/share/classes/jdk/jshell/spi/ExecutionControl.java
author rfield
Sun, 06 Nov 2016 22:50:46 -0800
changeset 41941 a935ac3f5274
parent 39807 ba0ff343d241
child 42969 a48d4f74d322
permissions -rw-r--r--
8161983: JShell API: Clean-up following 8160127 et. al. Reviewed-by: jlahoda
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
38535
4a25025e0b0d 8156101: JShell SPI: Provide a pluggable execution control SPI
rfield
parents:
diff changeset
     1
/*
4a25025e0b0d 8156101: JShell SPI: Provide a pluggable execution control SPI
rfield
parents:
diff changeset
     2
 * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
4a25025e0b0d 8156101: JShell SPI: Provide a pluggable execution control SPI
rfield
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4a25025e0b0d 8156101: JShell SPI: Provide a pluggable execution control SPI
rfield
parents:
diff changeset
     4
 *
4a25025e0b0d 8156101: JShell SPI: Provide a pluggable execution control SPI
rfield
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
4a25025e0b0d 8156101: JShell SPI: Provide a pluggable execution control SPI
rfield
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
4a25025e0b0d 8156101: JShell SPI: Provide a pluggable execution control SPI
rfield
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
4a25025e0b0d 8156101: JShell SPI: Provide a pluggable execution control SPI
rfield
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
4a25025e0b0d 8156101: JShell SPI: Provide a pluggable execution control SPI
rfield
parents:
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
4a25025e0b0d 8156101: JShell SPI: Provide a pluggable execution control SPI
rfield
parents:
diff changeset
    10
 *
4a25025e0b0d 8156101: JShell SPI: Provide a pluggable execution control SPI
rfield
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
4a25025e0b0d 8156101: JShell SPI: Provide a pluggable execution control SPI
rfield
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
4a25025e0b0d 8156101: JShell SPI: Provide a pluggable execution control SPI
rfield
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
4a25025e0b0d 8156101: JShell SPI: Provide a pluggable execution control SPI
rfield
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
4a25025e0b0d 8156101: JShell SPI: Provide a pluggable execution control SPI
rfield
parents:
diff changeset
    15
 * accompanied this code).
4a25025e0b0d 8156101: JShell SPI: Provide a pluggable execution control SPI
rfield
parents:
diff changeset
    16
 *
4a25025e0b0d 8156101: JShell SPI: Provide a pluggable execution control SPI
rfield
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
4a25025e0b0d 8156101: JShell SPI: Provide a pluggable execution control SPI
rfield
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
4a25025e0b0d 8156101: JShell SPI: Provide a pluggable execution control SPI
rfield
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
4a25025e0b0d 8156101: JShell SPI: Provide a pluggable execution control SPI
rfield
parents:
diff changeset
    20
 *
4a25025e0b0d 8156101: JShell SPI: Provide a pluggable execution control SPI
rfield
parents:
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
4a25025e0b0d 8156101: JShell SPI: Provide a pluggable execution control SPI
rfield
parents:
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
4a25025e0b0d 8156101: JShell SPI: Provide a pluggable execution control SPI
rfield
parents:
diff changeset
    23
 * questions.
4a25025e0b0d 8156101: JShell SPI: Provide a pluggable execution control SPI
rfield
parents:
diff changeset
    24
 */
4a25025e0b0d 8156101: JShell SPI: Provide a pluggable execution control SPI
rfield
parents:
diff changeset
    25
package jdk.jshell.spi;
4a25025e0b0d 8156101: JShell SPI: Provide a pluggable execution control SPI
rfield
parents:
diff changeset
    26
39807
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
    27
import java.io.Serializable;
38535
4a25025e0b0d 8156101: JShell SPI: Provide a pluggable execution control SPI
rfield
parents:
diff changeset
    28
4a25025e0b0d 8156101: JShell SPI: Provide a pluggable execution control SPI
rfield
parents:
diff changeset
    29
/**
39807
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
    30
 * This interface specifies the functionality that must provided to implement a
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
    31
 * pluggable JShell execution engine.
38535
4a25025e0b0d 8156101: JShell SPI: Provide a pluggable execution control SPI
rfield
parents:
diff changeset
    32
 * <p>
39807
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
    33
 * The audience for this Service Provider Interface is engineers wishing to
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
    34
 * implement their own version of the execution engine in support of the JShell
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
    35
 * API.
38535
4a25025e0b0d 8156101: JShell SPI: Provide a pluggable execution control SPI
rfield
parents:
diff changeset
    36
 * <p>
39807
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
    37
 * A Snippet is compiled into code wrapped in a 'wrapper class'. The execution
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
    38
 * engine is used by the core JShell implementation to load and, for executable
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
    39
 * Snippets, execute the Snippet.
38535
4a25025e0b0d 8156101: JShell SPI: Provide a pluggable execution control SPI
rfield
parents:
diff changeset
    40
 * <p>
4a25025e0b0d 8156101: JShell SPI: Provide a pluggable execution control SPI
rfield
parents:
diff changeset
    41
 * Methods defined in this interface should only be called by the core JShell
4a25025e0b0d 8156101: JShell SPI: Provide a pluggable execution control SPI
rfield
parents:
diff changeset
    42
 * implementation.
4a25025e0b0d 8156101: JShell SPI: Provide a pluggable execution control SPI
rfield
parents:
diff changeset
    43
 * <p>
39807
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
    44
 * To install an {@code ExecutionControl}, its {@code Generator} is passed to
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
    45
 * {@link jdk.jshell.JShell.Builder#executionEngine(ExecutionControl.Generator)  }.
38535
4a25025e0b0d 8156101: JShell SPI: Provide a pluggable execution control SPI
rfield
parents:
diff changeset
    46
 */
41941
a935ac3f5274 8161983: JShell API: Clean-up following 8160127 et. al.
rfield
parents: 39807
diff changeset
    47
public interface ExecutionControl extends AutoCloseable {
38535
4a25025e0b0d 8156101: JShell SPI: Provide a pluggable execution control SPI
rfield
parents:
diff changeset
    48
4a25025e0b0d 8156101: JShell SPI: Provide a pluggable execution control SPI
rfield
parents:
diff changeset
    49
    /**
39807
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
    50
     * Defines a functional interface for creating {@link ExecutionControl}
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
    51
     * instances.
38535
4a25025e0b0d 8156101: JShell SPI: Provide a pluggable execution control SPI
rfield
parents:
diff changeset
    52
     */
41941
a935ac3f5274 8161983: JShell API: Clean-up following 8160127 et. al.
rfield
parents: 39807
diff changeset
    53
    @FunctionalInterface
39807
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
    54
    public interface Generator {
38535
4a25025e0b0d 8156101: JShell SPI: Provide a pluggable execution control SPI
rfield
parents:
diff changeset
    55
4a25025e0b0d 8156101: JShell SPI: Provide a pluggable execution control SPI
rfield
parents:
diff changeset
    56
        /**
39807
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
    57
         * Generates an execution engine, given an execution environment.
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
    58
         *
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
    59
         * @param env the context in which the {@link ExecutionControl} is to
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
    60
         * be created
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
    61
         * @return the created instance
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
    62
         * @throws Throwable if problems occurred
38535
4a25025e0b0d 8156101: JShell SPI: Provide a pluggable execution control SPI
rfield
parents:
diff changeset
    63
         */
39807
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
    64
        ExecutionControl generate(ExecutionEnv env) throws Throwable;
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
    65
    }
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
    66
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
    67
    /**
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
    68
     * Attempts to load new classes.
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
    69
     *
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
    70
     * @param cbcs the class name and bytecodes to load
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
    71
     * @throws ClassInstallException exception occurred loading the classes,
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
    72
     * some or all were not loaded
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
    73
     * @throws NotImplementedException if not implemented
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
    74
     * @throws EngineTerminationException the execution engine has terminated
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
    75
     */
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
    76
    void load(ClassBytecodes[] cbcs)
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
    77
            throws ClassInstallException, NotImplementedException, EngineTerminationException;
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
    78
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
    79
    /**
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
    80
     * Attempts to redefine previously loaded classes.
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
    81
     *
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
    82
     * @param cbcs the class name and bytecodes to redefine
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
    83
     * @throws ClassInstallException exception occurred redefining the classes,
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
    84
     * some or all were not redefined
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
    85
     * @throws NotImplementedException if not implemented
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
    86
     * @throws EngineTerminationException the execution engine has terminated
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
    87
     */
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
    88
    void redefine(ClassBytecodes[] cbcs)
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
    89
            throws ClassInstallException, NotImplementedException, EngineTerminationException;
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
    90
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
    91
    /**
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
    92
     * Invokes an executable Snippet by calling a method on the specified
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
    93
     * wrapper class. The method must have no arguments and return String.
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
    94
     *
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
    95
     * @param className the class whose method should be invoked
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
    96
     * @param methodName the name of method to invoke
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
    97
     * @return the result of the execution or null if no result
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
    98
     * @throws UserException the invoke raised a user exception
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
    99
     * @throws ResolutionException the invoke attempted to directly or
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   100
     * indirectly invoke an unresolved snippet
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   101
     * @throws StoppedException if the {@code invoke()} was canceled by
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   102
     * {@link ExecutionControl#stop}
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   103
     * @throws EngineTerminationException the execution engine has terminated
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   104
     * @throws InternalException an internal problem occurred
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   105
     */
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   106
    String invoke(String className, String methodName)
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   107
            throws RunException, EngineTerminationException, InternalException;
38535
4a25025e0b0d 8156101: JShell SPI: Provide a pluggable execution control SPI
rfield
parents:
diff changeset
   108
4a25025e0b0d 8156101: JShell SPI: Provide a pluggable execution control SPI
rfield
parents:
diff changeset
   109
    /**
39807
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   110
     * Returns the value of a variable.
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   111
     *
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   112
     * @param className the name of the wrapper class of the variable
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   113
     * @param varName the name of the variable
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   114
     * @return the value of the variable
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   115
     * @throws UserException formatting the value raised a user exception
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   116
     * @throws ResolutionException formatting the value attempted to directly or
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   117
     * indirectly invoke an unresolved snippet
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   118
     * @throws StoppedException if the formatting the value was canceled by
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   119
     * {@link ExecutionControl#stop}
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   120
     * @throws EngineTerminationException the execution engine has terminated
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   121
     * @throws InternalException an internal problem occurred
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   122
     */
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   123
    String varValue(String className, String varName)
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   124
            throws RunException, EngineTerminationException, InternalException;
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   125
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   126
    /**
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   127
     * Adds the path to the execution class path.
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   128
     *
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   129
     * @param path the path to add
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   130
     * @throws EngineTerminationException the execution engine has terminated
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   131
     * @throws InternalException an internal problem occurred
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   132
     */
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   133
    void addToClasspath(String path)
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   134
            throws EngineTerminationException, InternalException;
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   135
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   136
    /**
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   137
     * Sets the execution class path to the specified path.
38535
4a25025e0b0d 8156101: JShell SPI: Provide a pluggable execution control SPI
rfield
parents:
diff changeset
   138
     *
39807
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   139
     * @param path the path to add
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   140
     * @throws EngineTerminationException the execution engine has terminated
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   141
     * @throws InternalException an internal problem occurred
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   142
     */
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   143
    void setClasspath(String path)
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   144
            throws EngineTerminationException, InternalException;
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   145
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   146
    /**
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   147
     * Interrupts a running invoke.
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   148
     *
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   149
     * @throws EngineTerminationException the execution engine has terminated
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   150
     * @throws InternalException an internal problem occurred
38535
4a25025e0b0d 8156101: JShell SPI: Provide a pluggable execution control SPI
rfield
parents:
diff changeset
   151
     */
39807
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   152
    void stop()
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   153
            throws EngineTerminationException, InternalException;
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   154
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   155
    /**
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   156
     * Run a non-standard command (or a standard command from a newer version).
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   157
     *
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   158
     * @param command the non-standard command
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   159
     * @param arg the commands argument
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   160
     * @return the commands return value
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   161
     * @throws UserException the command raised a user exception
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   162
     * @throws ResolutionException the command attempted to directly or
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   163
     * indirectly invoke an unresolved snippet
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   164
     * @throws StoppedException if the command was canceled by
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   165
     * {@link ExecutionControl#stop}
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   166
     * @throws EngineTerminationException the execution engine has terminated
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   167
     * @throws NotImplementedException if not implemented
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   168
     * @throws InternalException an internal problem occurred
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   169
     */
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   170
    Object extensionCommand(String command, Object arg)
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   171
            throws RunException, EngineTerminationException, InternalException;
38535
4a25025e0b0d 8156101: JShell SPI: Provide a pluggable execution control SPI
rfield
parents:
diff changeset
   172
4a25025e0b0d 8156101: JShell SPI: Provide a pluggable execution control SPI
rfield
parents:
diff changeset
   173
    /**
4a25025e0b0d 8156101: JShell SPI: Provide a pluggable execution control SPI
rfield
parents:
diff changeset
   174
     * Shuts down this execution engine. Implementation should free all
4a25025e0b0d 8156101: JShell SPI: Provide a pluggable execution control SPI
rfield
parents:
diff changeset
   175
     * resources held by this execution engine.
4a25025e0b0d 8156101: JShell SPI: Provide a pluggable execution control SPI
rfield
parents:
diff changeset
   176
     * <p>
4a25025e0b0d 8156101: JShell SPI: Provide a pluggable execution control SPI
rfield
parents:
diff changeset
   177
     * No calls to methods on this interface should be made after close.
4a25025e0b0d 8156101: JShell SPI: Provide a pluggable execution control SPI
rfield
parents:
diff changeset
   178
     */
4a25025e0b0d 8156101: JShell SPI: Provide a pluggable execution control SPI
rfield
parents:
diff changeset
   179
    void close();
4a25025e0b0d 8156101: JShell SPI: Provide a pluggable execution control SPI
rfield
parents:
diff changeset
   180
4a25025e0b0d 8156101: JShell SPI: Provide a pluggable execution control SPI
rfield
parents:
diff changeset
   181
    /**
39807
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   182
     * Bundles class name with class bytecodes.
38535
4a25025e0b0d 8156101: JShell SPI: Provide a pluggable execution control SPI
rfield
parents:
diff changeset
   183
     */
39807
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   184
    public static final class ClassBytecodes implements Serializable {
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   185
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   186
        private static final long serialVersionUID = 0xC1A55B47EC0DE5L;
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   187
        private final String name;
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   188
        private final byte[] bytecodes;
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   189
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   190
        /**
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   191
         * Creates a name/bytecode pair.
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   192
         * @param name the class name
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   193
         * @param bytecodes the class bytecodes
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   194
         */
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   195
        public ClassBytecodes(String name, byte[] bytecodes) {
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   196
            this.name = name;
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   197
            this.bytecodes = bytecodes;
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   198
        }
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   199
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   200
        /**
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   201
         * The bytecodes for the class.
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   202
         *
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   203
         * @return the bytecodes
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   204
         */
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   205
        public byte[] bytecodes() {
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   206
            return bytecodes;
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   207
        }
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   208
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   209
        /**
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   210
         * The class name.
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   211
         *
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   212
         * @return the class name
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   213
         */
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   214
        public String name() {
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   215
            return name;
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   216
        }
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   217
    }
38535
4a25025e0b0d 8156101: JShell SPI: Provide a pluggable execution control SPI
rfield
parents:
diff changeset
   218
4a25025e0b0d 8156101: JShell SPI: Provide a pluggable execution control SPI
rfield
parents:
diff changeset
   219
    /**
39807
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   220
     * The abstract base of all {@code ExecutionControl} exceptions.
38535
4a25025e0b0d 8156101: JShell SPI: Provide a pluggable execution control SPI
rfield
parents:
diff changeset
   221
     */
39807
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   222
    public static abstract class ExecutionControlException extends Exception {
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   223
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   224
        private static final long serialVersionUID = 1L;
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   225
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   226
        public ExecutionControlException(String message) {
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   227
            super(message);
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   228
        }
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   229
    }
38535
4a25025e0b0d 8156101: JShell SPI: Provide a pluggable execution control SPI
rfield
parents:
diff changeset
   230
4a25025e0b0d 8156101: JShell SPI: Provide a pluggable execution control SPI
rfield
parents:
diff changeset
   231
    /**
39807
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   232
     * Unbidden execution engine termination has occurred.
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   233
     */
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   234
    public static class EngineTerminationException extends ExecutionControlException {
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   235
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   236
        private static final long serialVersionUID = 1L;
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   237
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   238
        public EngineTerminationException(String message) {
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   239
            super(message);
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   240
        }
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   241
    }
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   242
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   243
    /**
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   244
     * The command is not implemented.
38535
4a25025e0b0d 8156101: JShell SPI: Provide a pluggable execution control SPI
rfield
parents:
diff changeset
   245
     */
39807
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   246
    public static class NotImplementedException extends InternalException {
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   247
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   248
        private static final long serialVersionUID = 1L;
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   249
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   250
        public NotImplementedException(String message) {
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   251
            super(message);
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   252
        }
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   253
    }
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   254
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   255
    /**
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   256
     * An internal problem has occurred.
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   257
     */
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   258
    public static class InternalException extends ExecutionControlException {
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   259
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   260
        private static final long serialVersionUID = 1L;
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   261
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   262
        public InternalException(String message) {
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   263
            super(message);
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   264
        }
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   265
    }
38535
4a25025e0b0d 8156101: JShell SPI: Provide a pluggable execution control SPI
rfield
parents:
diff changeset
   266
4a25025e0b0d 8156101: JShell SPI: Provide a pluggable execution control SPI
rfield
parents:
diff changeset
   267
    /**
39807
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   268
     * A class install (load or redefine) encountered a problem.
38535
4a25025e0b0d 8156101: JShell SPI: Provide a pluggable execution control SPI
rfield
parents:
diff changeset
   269
     */
39807
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   270
    public static class ClassInstallException extends ExecutionControlException {
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   271
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   272
        private static final long serialVersionUID = 1L;
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   273
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   274
        private final boolean[] installed;
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   275
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   276
        public ClassInstallException(String message, boolean[] installed) {
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   277
            super(message);
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   278
            this.installed = installed;
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   279
        }
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   280
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   281
        /**
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   282
         * Indicates which of the passed classes were successfully
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   283
         * loaded/redefined.
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   284
         * @return a one-to-one array with the {@link ClassBytecodes}{@code[]}
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   285
         * array -- {@code true} if installed
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   286
         */
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   287
        public boolean[] installed() {
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   288
            return installed;
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   289
        }
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   290
    }
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   291
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   292
    /**
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   293
     * The abstract base of of exceptions specific to running user code.
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   294
     */
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   295
    public static abstract class RunException extends ExecutionControlException {
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   296
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   297
        private static final long serialVersionUID = 1L;
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   298
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   299
        private RunException(String message) {
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   300
            super(message);
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   301
        }
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   302
    }
38535
4a25025e0b0d 8156101: JShell SPI: Provide a pluggable execution control SPI
rfield
parents:
diff changeset
   303
4a25025e0b0d 8156101: JShell SPI: Provide a pluggable execution control SPI
rfield
parents:
diff changeset
   304
    /**
39807
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   305
     * A 'normal' user exception occurred.
38535
4a25025e0b0d 8156101: JShell SPI: Provide a pluggable execution control SPI
rfield
parents:
diff changeset
   306
     */
39807
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   307
    public static class UserException extends RunException {
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   308
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   309
        private static final long serialVersionUID = 1L;
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   310
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   311
        private final String causeExceptionClass;
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   312
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   313
        public UserException(String message, String causeExceptionClass, StackTraceElement[] stackElements) {
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   314
            super(message);
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   315
            this.causeExceptionClass = causeExceptionClass;
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   316
            this.setStackTrace(stackElements);
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   317
        }
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   318
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   319
        /**
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   320
         * Returns the class of the user exception.
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   321
         * @return the name of the user exception class
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   322
         */
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   323
        public String causeExceptionClass() {
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   324
            return causeExceptionClass;
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   325
        }
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   326
    }
38535
4a25025e0b0d 8156101: JShell SPI: Provide a pluggable execution control SPI
rfield
parents:
diff changeset
   327
4a25025e0b0d 8156101: JShell SPI: Provide a pluggable execution control SPI
rfield
parents:
diff changeset
   328
    /**
39807
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   329
     * An exception indicating that a {@code DeclarationSnippet} with unresolved
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   330
     * references has been encountered.
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   331
     * <p>
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   332
     * Contrast this with the initiating {@link SPIResolutionException}
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   333
     * (a {@code RuntimeException}) which is embedded in generated corralled
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   334
     * code.  Also, contrast this with
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   335
     * {@link jdk.jshell.UnresolvedReferenceException} the high-level
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   336
     * exception (with {@code DeclarationSnippet} reference) provided in the
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   337
     * main API.
38535
4a25025e0b0d 8156101: JShell SPI: Provide a pluggable execution control SPI
rfield
parents:
diff changeset
   338
     */
39807
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   339
    public static class ResolutionException extends RunException {
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   340
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   341
        private static final long serialVersionUID = 1L;
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   342
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   343
        private final int id;
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   344
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   345
        /**
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   346
         * Constructs an exception indicating that a {@code DeclarationSnippet}
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   347
         * with unresolved references has been encountered.
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   348
         *
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   349
         * @param id An internal identifier of the specific method
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   350
         * @param stackElements the stack trace
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   351
         */
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   352
        public ResolutionException(int id, StackTraceElement[] stackElements) {
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   353
            super("resolution exception: " + id);
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   354
            this.id = id;
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   355
            this.setStackTrace(stackElements);
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   356
        }
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   357
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   358
        /**
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   359
         * Retrieves the internal identifier of the unresolved identifier.
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   360
         *
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   361
         * @return the internal identifier
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   362
         */
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   363
        public int id() {
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   364
            return id;
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   365
        }
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   366
    }
38535
4a25025e0b0d 8156101: JShell SPI: Provide a pluggable execution control SPI
rfield
parents:
diff changeset
   367
4a25025e0b0d 8156101: JShell SPI: Provide a pluggable execution control SPI
rfield
parents:
diff changeset
   368
    /**
39807
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   369
     * An exception indicating that an
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   370
     * {@link ExecutionControl#invoke(java.lang.String, java.lang.String) }
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   371
     * (or theoretically a
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   372
     * {@link ExecutionControl#varValue(java.lang.String, java.lang.String) })
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   373
     * has been interrupted by a {@link ExecutionControl#stop() }.
38535
4a25025e0b0d 8156101: JShell SPI: Provide a pluggable execution control SPI
rfield
parents:
diff changeset
   374
     */
39807
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   375
    public static class StoppedException extends RunException {
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   376
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   377
        private static final long serialVersionUID = 1L;
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   378
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   379
        public StoppedException() {
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   380
            super("stopped by stop()");
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   381
        }
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   382
    }
ba0ff343d241 8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents: 38535
diff changeset
   383
38535
4a25025e0b0d 8156101: JShell SPI: Provide a pluggable execution control SPI
rfield
parents:
diff changeset
   384
}