author | michaelm |
Fri, 16 Feb 2018 10:34:17 +0000 | |
branch | http-client-branch |
changeset 56137 | dd867826d55b |
parent 47216 | 71c04702a3d5 |
permissions | -rw-r--r-- |
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; |
42969
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
41941
diff
changeset
|
28 |
import java.util.Collections; |
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
41941
diff
changeset
|
29 |
import java.util.HashMap; |
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
41941
diff
changeset
|
30 |
import java.util.Map; |
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
41941
diff
changeset
|
31 |
import java.util.ServiceLoader; |
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
41941
diff
changeset
|
32 |
import java.util.Set; |
38535
4a25025e0b0d
8156101: JShell SPI: Provide a pluggable execution control SPI
rfield
parents:
diff
changeset
|
33 |
|
4a25025e0b0d
8156101: JShell SPI: Provide a pluggable execution control SPI
rfield
parents:
diff
changeset
|
34 |
/** |
39807
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
35 |
* 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
|
36 |
* pluggable JShell execution engine. |
38535
4a25025e0b0d
8156101: JShell SPI: Provide a pluggable execution control SPI
rfield
parents:
diff
changeset
|
37 |
* <p> |
39807
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
38 |
* 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
|
39 |
* 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
|
40 |
* API. |
38535
4a25025e0b0d
8156101: JShell SPI: Provide a pluggable execution control SPI
rfield
parents:
diff
changeset
|
41 |
* <p> |
39807
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
42 |
* 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
|
43 |
* 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
|
44 |
* Snippets, execute the Snippet. |
38535
4a25025e0b0d
8156101: JShell SPI: Provide a pluggable execution control SPI
rfield
parents:
diff
changeset
|
45 |
* <p> |
4a25025e0b0d
8156101: JShell SPI: Provide a pluggable execution control SPI
rfield
parents:
diff
changeset
|
46 |
* 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
|
47 |
* implementation. |
43770 | 48 |
* |
49 |
* @since 9 |
|
38535
4a25025e0b0d
8156101: JShell SPI: Provide a pluggable execution control SPI
rfield
parents:
diff
changeset
|
50 |
*/ |
41941
a935ac3f5274
8161983: JShell API: Clean-up following 8160127 et. al.
rfield
parents:
39807
diff
changeset
|
51 |
public interface ExecutionControl extends AutoCloseable { |
38535
4a25025e0b0d
8156101: JShell SPI: Provide a pluggable execution control SPI
rfield
parents:
diff
changeset
|
52 |
|
4a25025e0b0d
8156101: JShell SPI: Provide a pluggable execution control SPI
rfield
parents:
diff
changeset
|
53 |
/** |
39807
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
54 |
* Attempts to load new classes. |
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
55 |
* |
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
56 |
* @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
|
57 |
* @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
|
58 |
* some or all were not loaded |
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
59 |
* @throws NotImplementedException if not implemented |
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
60 |
* @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
|
61 |
*/ |
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
62 |
void load(ClassBytecodes[] cbcs) |
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
63 |
throws ClassInstallException, NotImplementedException, EngineTerminationException; |
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
64 |
|
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 |
* Attempts to redefine previously loaded classes. |
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 |
* @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
|
69 |
* @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
|
70 |
* some or all were not redefined |
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
71 |
* @throws NotImplementedException if not implemented |
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
72 |
* @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
|
73 |
*/ |
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
74 |
void redefine(ClassBytecodes[] cbcs) |
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
75 |
throws ClassInstallException, NotImplementedException, EngineTerminationException; |
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
76 |
|
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
77 |
/** |
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
78 |
* 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
|
79 |
* 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
|
80 |
* |
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
81 |
* @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
|
82 |
* @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
|
83 |
* @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
|
84 |
* @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
|
85 |
* @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
|
86 |
* indirectly invoke an unresolved snippet |
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
87 |
* @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
|
88 |
* {@link ExecutionControl#stop} |
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
89 |
* @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
|
90 |
* @throws InternalException an internal problem occurred |
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 |
String invoke(String className, String methodName) |
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
93 |
throws RunException, EngineTerminationException, InternalException; |
38535
4a25025e0b0d
8156101: JShell SPI: Provide a pluggable execution control SPI
rfield
parents:
diff
changeset
|
94 |
|
4a25025e0b0d
8156101: JShell SPI: Provide a pluggable execution control SPI
rfield
parents:
diff
changeset
|
95 |
/** |
39807
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
96 |
* Returns the value of a variable. |
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
97 |
* |
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
98 |
* @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
|
99 |
* @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
|
100 |
* @return the value of the variable |
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
101 |
* @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
|
102 |
* @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
|
103 |
* indirectly invoke an unresolved snippet |
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
104 |
* @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
|
105 |
* {@link ExecutionControl#stop} |
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
106 |
* @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
|
107 |
* @throws InternalException an internal problem occurred |
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
108 |
*/ |
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
109 |
String varValue(String className, String varName) |
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
110 |
throws RunException, EngineTerminationException, InternalException; |
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 |
/** |
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
113 |
* 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
|
114 |
* |
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
115 |
* @param path the path to add |
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
116 |
* @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
|
117 |
* @throws InternalException an internal problem occurred |
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
118 |
*/ |
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
119 |
void addToClasspath(String path) |
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
120 |
throws EngineTerminationException, InternalException; |
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
121 |
|
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 |
* Interrupts a running invoke. |
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
124 |
* |
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
125 |
* @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
|
126 |
* @throws InternalException an internal problem occurred |
38535
4a25025e0b0d
8156101: JShell SPI: Provide a pluggable execution control SPI
rfield
parents:
diff
changeset
|
127 |
*/ |
39807
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
128 |
void stop() |
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
129 |
throws EngineTerminationException, InternalException; |
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
130 |
|
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
131 |
/** |
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
132 |
* 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
|
133 |
* |
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
134 |
* @param command the non-standard command |
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
135 |
* @param arg the commands argument |
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
136 |
* @return the commands return value |
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
137 |
* @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
|
138 |
* @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
|
139 |
* indirectly invoke an unresolved snippet |
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
140 |
* @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
|
141 |
* {@link ExecutionControl#stop} |
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
142 |
* @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
|
143 |
* @throws NotImplementedException if not implemented |
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
144 |
* @throws InternalException an internal problem occurred |
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 |
Object extensionCommand(String command, Object arg) |
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
147 |
throws RunException, EngineTerminationException, InternalException; |
38535
4a25025e0b0d
8156101: JShell SPI: Provide a pluggable execution control SPI
rfield
parents:
diff
changeset
|
148 |
|
4a25025e0b0d
8156101: JShell SPI: Provide a pluggable execution control SPI
rfield
parents:
diff
changeset
|
149 |
/** |
4a25025e0b0d
8156101: JShell SPI: Provide a pluggable execution control SPI
rfield
parents:
diff
changeset
|
150 |
* Shuts down this execution engine. Implementation should free all |
4a25025e0b0d
8156101: JShell SPI: Provide a pluggable execution control SPI
rfield
parents:
diff
changeset
|
151 |
* resources held by this execution engine. |
4a25025e0b0d
8156101: JShell SPI: Provide a pluggable execution control SPI
rfield
parents:
diff
changeset
|
152 |
* <p> |
4a25025e0b0d
8156101: JShell SPI: Provide a pluggable execution control SPI
rfield
parents:
diff
changeset
|
153 |
* 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
|
154 |
*/ |
42969
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
41941
diff
changeset
|
155 |
@Override |
38535
4a25025e0b0d
8156101: JShell SPI: Provide a pluggable execution control SPI
rfield
parents:
diff
changeset
|
156 |
void close(); |
4a25025e0b0d
8156101: JShell SPI: Provide a pluggable execution control SPI
rfield
parents:
diff
changeset
|
157 |
|
4a25025e0b0d
8156101: JShell SPI: Provide a pluggable execution control SPI
rfield
parents:
diff
changeset
|
158 |
/** |
42969
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
41941
diff
changeset
|
159 |
* Search for a provider, then create and return the |
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
41941
diff
changeset
|
160 |
* {@code ExecutionControl} instance. |
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
41941
diff
changeset
|
161 |
* |
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
41941
diff
changeset
|
162 |
* @param env the execution environment (provided by JShell) |
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
41941
diff
changeset
|
163 |
* @param name the name of provider |
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
41941
diff
changeset
|
164 |
* @param parameters the parameter map. |
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
41941
diff
changeset
|
165 |
* @return the execution engine |
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
41941
diff
changeset
|
166 |
* @throws Throwable an exception that occurred attempting to find or create |
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
41941
diff
changeset
|
167 |
* the execution engine. |
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
41941
diff
changeset
|
168 |
* @throws IllegalArgumentException if no ExecutionControlProvider has the |
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
41941
diff
changeset
|
169 |
* specified {@code name} and {@code parameters}. |
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
41941
diff
changeset
|
170 |
*/ |
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
41941
diff
changeset
|
171 |
static ExecutionControl generate(ExecutionEnv env, String name, Map<String, String> parameters) |
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
41941
diff
changeset
|
172 |
throws Throwable { |
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
41941
diff
changeset
|
173 |
Set<String> keys = parameters == null |
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
41941
diff
changeset
|
174 |
? Collections.emptySet() |
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
41941
diff
changeset
|
175 |
: parameters.keySet(); |
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
41941
diff
changeset
|
176 |
for (ExecutionControlProvider p : ServiceLoader.load(ExecutionControlProvider.class)) { |
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
41941
diff
changeset
|
177 |
if (p.name().equals(name) |
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
41941
diff
changeset
|
178 |
&& p.defaultParameters().keySet().containsAll(keys)) { |
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
41941
diff
changeset
|
179 |
return p.generate(env, parameters); |
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
41941
diff
changeset
|
180 |
} |
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
41941
diff
changeset
|
181 |
} |
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
41941
diff
changeset
|
182 |
throw new IllegalArgumentException("No ExecutionControlProvider with name '" |
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
41941
diff
changeset
|
183 |
+ name + "' and parameter keys: " + keys.toString()); |
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
41941
diff
changeset
|
184 |
} |
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
41941
diff
changeset
|
185 |
|
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
41941
diff
changeset
|
186 |
/** |
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
41941
diff
changeset
|
187 |
* Search for a provider, then create and return the |
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
41941
diff
changeset
|
188 |
* {@code ExecutionControl} instance. |
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
41941
diff
changeset
|
189 |
* |
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
41941
diff
changeset
|
190 |
* @param env the execution environment (provided by JShell) |
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
41941
diff
changeset
|
191 |
* @param spec the {@code ExecutionControl} spec, which is described in |
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
41941
diff
changeset
|
192 |
* the documentation of this |
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
41941
diff
changeset
|
193 |
* {@linkplain jdk.jshell.spi package documentation}. |
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
41941
diff
changeset
|
194 |
* @return the execution engine |
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
41941
diff
changeset
|
195 |
* @throws Throwable an exception that occurred attempting to find or create |
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
41941
diff
changeset
|
196 |
* the execution engine. |
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
41941
diff
changeset
|
197 |
* @throws IllegalArgumentException if no ExecutionControlProvider has the |
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
41941
diff
changeset
|
198 |
* specified {@code name} and {@code parameters}. |
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
41941
diff
changeset
|
199 |
* @throws IllegalArgumentException if {@code spec} is malformed |
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
41941
diff
changeset
|
200 |
*/ |
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
41941
diff
changeset
|
201 |
static ExecutionControl generate(ExecutionEnv env, String spec) |
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
41941
diff
changeset
|
202 |
throws Throwable { |
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
41941
diff
changeset
|
203 |
class SpecReader { |
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
41941
diff
changeset
|
204 |
|
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
41941
diff
changeset
|
205 |
int len = spec.length(); |
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
41941
diff
changeset
|
206 |
int i = -1; |
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
41941
diff
changeset
|
207 |
|
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
41941
diff
changeset
|
208 |
char ch; |
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
41941
diff
changeset
|
209 |
|
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
41941
diff
changeset
|
210 |
SpecReader() { |
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
41941
diff
changeset
|
211 |
next(); |
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
41941
diff
changeset
|
212 |
} |
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
41941
diff
changeset
|
213 |
|
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
41941
diff
changeset
|
214 |
boolean more() { |
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
41941
diff
changeset
|
215 |
return i < len; |
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
41941
diff
changeset
|
216 |
} |
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
41941
diff
changeset
|
217 |
|
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
41941
diff
changeset
|
218 |
char current() { |
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
41941
diff
changeset
|
219 |
return ch; |
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
41941
diff
changeset
|
220 |
} |
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
41941
diff
changeset
|
221 |
|
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
41941
diff
changeset
|
222 |
final boolean next() { |
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
41941
diff
changeset
|
223 |
++i; |
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
41941
diff
changeset
|
224 |
if (i < len) { |
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
41941
diff
changeset
|
225 |
ch = spec.charAt(i); |
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
41941
diff
changeset
|
226 |
return true; |
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
41941
diff
changeset
|
227 |
} |
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
41941
diff
changeset
|
228 |
i = len; |
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
41941
diff
changeset
|
229 |
return false; |
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
41941
diff
changeset
|
230 |
} |
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
41941
diff
changeset
|
231 |
|
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
41941
diff
changeset
|
232 |
void skipWhite() { |
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
41941
diff
changeset
|
233 |
while (more() && Character.isWhitespace(ch)) { |
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
41941
diff
changeset
|
234 |
next(); |
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
41941
diff
changeset
|
235 |
} |
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
41941
diff
changeset
|
236 |
} |
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
41941
diff
changeset
|
237 |
|
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
41941
diff
changeset
|
238 |
String readId() { |
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
41941
diff
changeset
|
239 |
skipWhite(); |
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
41941
diff
changeset
|
240 |
StringBuilder sb = new StringBuilder(); |
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
41941
diff
changeset
|
241 |
while (more() && Character.isJavaIdentifierPart(ch)) { |
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
41941
diff
changeset
|
242 |
sb.append(ch); |
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
41941
diff
changeset
|
243 |
next(); |
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
41941
diff
changeset
|
244 |
} |
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
41941
diff
changeset
|
245 |
skipWhite(); |
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
41941
diff
changeset
|
246 |
String id = sb.toString(); |
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
41941
diff
changeset
|
247 |
if (id.isEmpty()) { |
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
41941
diff
changeset
|
248 |
throw new IllegalArgumentException("Expected identifier in " + spec); |
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
41941
diff
changeset
|
249 |
} |
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
41941
diff
changeset
|
250 |
return id; |
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
41941
diff
changeset
|
251 |
} |
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
41941
diff
changeset
|
252 |
|
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
41941
diff
changeset
|
253 |
void expect(char exp) { |
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
41941
diff
changeset
|
254 |
skipWhite(); |
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
41941
diff
changeset
|
255 |
if (!more() || ch != exp) { |
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
41941
diff
changeset
|
256 |
throw new IllegalArgumentException("Expected '" + exp + "' in " + spec); |
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
41941
diff
changeset
|
257 |
} |
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
41941
diff
changeset
|
258 |
next(); |
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
41941
diff
changeset
|
259 |
skipWhite(); |
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
41941
diff
changeset
|
260 |
} |
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
41941
diff
changeset
|
261 |
|
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
41941
diff
changeset
|
262 |
String readValue() { |
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
41941
diff
changeset
|
263 |
expect('('); |
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
41941
diff
changeset
|
264 |
int parenDepth = 1; |
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
41941
diff
changeset
|
265 |
StringBuilder sb = new StringBuilder(); |
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
41941
diff
changeset
|
266 |
while (more()) { |
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
41941
diff
changeset
|
267 |
if (ch == ')') { |
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
41941
diff
changeset
|
268 |
--parenDepth; |
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
41941
diff
changeset
|
269 |
if (parenDepth == 0) { |
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
41941
diff
changeset
|
270 |
break; |
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
41941
diff
changeset
|
271 |
} |
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
41941
diff
changeset
|
272 |
} else if (ch == '(') { |
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
41941
diff
changeset
|
273 |
++parenDepth; |
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
41941
diff
changeset
|
274 |
} |
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
41941
diff
changeset
|
275 |
sb.append(ch); |
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
41941
diff
changeset
|
276 |
next(); |
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
41941
diff
changeset
|
277 |
} |
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
41941
diff
changeset
|
278 |
expect(')'); |
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
41941
diff
changeset
|
279 |
return sb.toString(); |
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
41941
diff
changeset
|
280 |
} |
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
41941
diff
changeset
|
281 |
} |
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
41941
diff
changeset
|
282 |
Map<String, String> parameters = new HashMap<>(); |
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
41941
diff
changeset
|
283 |
SpecReader sr = new SpecReader(); |
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
41941
diff
changeset
|
284 |
String name = sr.readId(); |
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
41941
diff
changeset
|
285 |
if (sr.more()) { |
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
41941
diff
changeset
|
286 |
sr.expect(':'); |
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
41941
diff
changeset
|
287 |
while (sr.more()) { |
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
41941
diff
changeset
|
288 |
String key = sr.readId(); |
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
41941
diff
changeset
|
289 |
String value = sr.readValue(); |
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
41941
diff
changeset
|
290 |
parameters.put(key, value); |
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
41941
diff
changeset
|
291 |
if (sr.more()) { |
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
41941
diff
changeset
|
292 |
sr.expect(','); |
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
41941
diff
changeset
|
293 |
} |
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
41941
diff
changeset
|
294 |
} |
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
41941
diff
changeset
|
295 |
} |
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
41941
diff
changeset
|
296 |
return generate(env, name, parameters); |
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
41941
diff
changeset
|
297 |
} |
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
41941
diff
changeset
|
298 |
|
a48d4f74d322
8168615: JShell API: jdk.jshell.spi should be a pluggable ServiceLoader SPI
rfield
parents:
41941
diff
changeset
|
299 |
/** |
39807
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
300 |
* Bundles class name with class bytecodes. |
38535
4a25025e0b0d
8156101: JShell SPI: Provide a pluggable execution control SPI
rfield
parents:
diff
changeset
|
301 |
*/ |
39807
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
302 |
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
|
303 |
|
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
304 |
private static final long serialVersionUID = 0xC1A55B47EC0DE5L; |
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
305 |
private final String name; |
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
306 |
private final byte[] bytecodes; |
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
307 |
|
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 |
* Creates a name/bytecode pair. |
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
310 |
* @param name the class name |
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
311 |
* @param bytecodes the class bytecodes |
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 ClassBytecodes(String name, byte[] bytecodes) { |
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
314 |
this.name = name; |
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
315 |
this.bytecodes = bytecodes; |
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
316 |
} |
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 |
* The bytecodes for the class. |
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
320 |
* |
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
321 |
* @return the bytecodes |
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 byte[] bytecodes() { |
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
324 |
return bytecodes; |
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 |
|
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
327 |
/** |
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
328 |
* The class name. |
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
329 |
* |
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
330 |
* @return the class name |
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
331 |
*/ |
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
332 |
public String name() { |
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
333 |
return name; |
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
334 |
} |
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
335 |
} |
38535
4a25025e0b0d
8156101: JShell SPI: Provide a pluggable execution control SPI
rfield
parents:
diff
changeset
|
336 |
|
4a25025e0b0d
8156101: JShell SPI: Provide a pluggable execution control SPI
rfield
parents:
diff
changeset
|
337 |
/** |
39807
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
338 |
* The abstract base of all {@code ExecutionControl} exceptions. |
38535
4a25025e0b0d
8156101: JShell SPI: Provide a pluggable execution control SPI
rfield
parents:
diff
changeset
|
339 |
*/ |
39807
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
340 |
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
|
341 |
|
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
342 |
private static final long serialVersionUID = 1L; |
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
343 |
|
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
344 |
public ExecutionControlException(String message) { |
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
345 |
super(message); |
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
346 |
} |
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
347 |
} |
38535
4a25025e0b0d
8156101: JShell SPI: Provide a pluggable execution control SPI
rfield
parents:
diff
changeset
|
348 |
|
4a25025e0b0d
8156101: JShell SPI: Provide a pluggable execution control SPI
rfield
parents:
diff
changeset
|
349 |
/** |
39807
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
350 |
* Unbidden execution engine termination has occurred. |
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 static class EngineTerminationException extends ExecutionControlException { |
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
353 |
|
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
354 |
private static final long serialVersionUID = 1L; |
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
355 |
|
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
356 |
public EngineTerminationException(String message) { |
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
357 |
super(message); |
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 |
} |
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 |
/** |
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
362 |
* The command is not implemented. |
38535
4a25025e0b0d
8156101: JShell SPI: Provide a pluggable execution control SPI
rfield
parents:
diff
changeset
|
363 |
*/ |
39807
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
364 |
public static class NotImplementedException extends InternalException { |
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 |
private static final long serialVersionUID = 1L; |
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
367 |
|
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
368 |
public NotImplementedException(String message) { |
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
369 |
super(message); |
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
370 |
} |
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
371 |
} |
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
372 |
|
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
373 |
/** |
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
374 |
* An internal problem has occurred. |
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
375 |
*/ |
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
376 |
public static class InternalException extends ExecutionControlException { |
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
377 |
|
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
378 |
private static final long serialVersionUID = 1L; |
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
379 |
|
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
380 |
public InternalException(String message) { |
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
381 |
super(message); |
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 |
|
4a25025e0b0d
8156101: JShell SPI: Provide a pluggable execution control SPI
rfield
parents:
diff
changeset
|
385 |
/** |
39807
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
386 |
* A class install (load or redefine) encountered a problem. |
38535
4a25025e0b0d
8156101: JShell SPI: Provide a pluggable execution control SPI
rfield
parents:
diff
changeset
|
387 |
*/ |
39807
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
388 |
public static class ClassInstallException extends ExecutionControlException { |
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
389 |
|
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
390 |
private static final long serialVersionUID = 1L; |
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
391 |
|
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
392 |
private final boolean[] installed; |
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
393 |
|
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
394 |
public ClassInstallException(String message, boolean[] installed) { |
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
395 |
super(message); |
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
396 |
this.installed = installed; |
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
397 |
} |
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
398 |
|
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
399 |
/** |
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
400 |
* 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
|
401 |
* loaded/redefined. |
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
402 |
* @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
|
403 |
* array -- {@code true} if installed |
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
404 |
*/ |
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
405 |
public boolean[] installed() { |
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
406 |
return installed; |
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
407 |
} |
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
408 |
} |
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
409 |
|
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
410 |
/** |
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
411 |
* 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
|
412 |
*/ |
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
413 |
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
|
414 |
|
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
415 |
private static final long serialVersionUID = 1L; |
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
416 |
|
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
417 |
private RunException(String message) { |
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
418 |
super(message); |
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
419 |
} |
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
420 |
} |
38535
4a25025e0b0d
8156101: JShell SPI: Provide a pluggable execution control SPI
rfield
parents:
diff
changeset
|
421 |
|
4a25025e0b0d
8156101: JShell SPI: Provide a pluggable execution control SPI
rfield
parents:
diff
changeset
|
422 |
/** |
39807
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
423 |
* A 'normal' user exception occurred. |
38535
4a25025e0b0d
8156101: JShell SPI: Provide a pluggable execution control SPI
rfield
parents:
diff
changeset
|
424 |
*/ |
39807
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
425 |
public static class UserException extends RunException { |
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
426 |
|
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
427 |
private static final long serialVersionUID = 1L; |
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
428 |
|
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
429 |
private final String causeExceptionClass; |
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
430 |
|
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
431 |
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
|
432 |
super(message); |
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
433 |
this.causeExceptionClass = causeExceptionClass; |
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
434 |
this.setStackTrace(stackElements); |
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
435 |
} |
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
436 |
|
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
437 |
/** |
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
438 |
* 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
|
439 |
* @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
|
440 |
*/ |
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
441 |
public String causeExceptionClass() { |
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
442 |
return causeExceptionClass; |
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
443 |
} |
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
444 |
} |
38535
4a25025e0b0d
8156101: JShell SPI: Provide a pluggable execution control SPI
rfield
parents:
diff
changeset
|
445 |
|
4a25025e0b0d
8156101: JShell SPI: Provide a pluggable execution control SPI
rfield
parents:
diff
changeset
|
446 |
/** |
39807
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
447 |
* 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
|
448 |
* references has been encountered. |
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
449 |
* <p> |
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
450 |
* 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
|
451 |
* (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
|
452 |
* code. Also, contrast this with |
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
453 |
* {@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
|
454 |
* 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
|
455 |
* main API. |
38535
4a25025e0b0d
8156101: JShell SPI: Provide a pluggable execution control SPI
rfield
parents:
diff
changeset
|
456 |
*/ |
39807
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
457 |
public static class ResolutionException extends RunException { |
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
458 |
|
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
459 |
private static final long serialVersionUID = 1L; |
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
460 |
|
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
461 |
private final int id; |
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
462 |
|
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
463 |
/** |
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
464 |
* 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
|
465 |
* with unresolved references has been encountered. |
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
466 |
* |
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
467 |
* @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
|
468 |
* @param stackElements the stack trace |
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
469 |
*/ |
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
470 |
public ResolutionException(int id, StackTraceElement[] stackElements) { |
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
471 |
super("resolution exception: " + id); |
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
472 |
this.id = id; |
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
473 |
this.setStackTrace(stackElements); |
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
474 |
} |
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
475 |
|
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
476 |
/** |
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
477 |
* 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
|
478 |
* |
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
479 |
* @return the internal identifier |
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
480 |
*/ |
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
481 |
public int id() { |
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
482 |
return id; |
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
483 |
} |
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
484 |
} |
38535
4a25025e0b0d
8156101: JShell SPI: Provide a pluggable execution control SPI
rfield
parents:
diff
changeset
|
485 |
|
4a25025e0b0d
8156101: JShell SPI: Provide a pluggable execution control SPI
rfield
parents:
diff
changeset
|
486 |
/** |
39807
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
487 |
* An exception indicating that an |
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
488 |
* {@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
|
489 |
* (or theoretically a |
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
490 |
* {@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
|
491 |
* has been interrupted by a {@link ExecutionControl#stop() }. |
38535
4a25025e0b0d
8156101: JShell SPI: Provide a pluggable execution control SPI
rfield
parents:
diff
changeset
|
492 |
*/ |
39807
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
493 |
public static class StoppedException extends RunException { |
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
494 |
|
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
495 |
private static final long serialVersionUID = 1L; |
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
496 |
|
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
497 |
public StoppedException() { |
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
498 |
super("stopped by stop()"); |
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
499 |
} |
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
500 |
} |
ba0ff343d241
8160127: JShell API: extract abstract JDI and abstract streaming implementations of ExecutionControl
rfield
parents:
38535
diff
changeset
|
501 |
|
38535
4a25025e0b0d
8156101: JShell SPI: Provide a pluggable execution control SPI
rfield
parents:
diff
changeset
|
502 |
} |