JShell (Java SE 10 & JDK 10 )
Evaluate the input String, including definition and/or execution, if applicable. The input is checked for errors, unless the errors can be deferred (as is the case with some unresolvedDependencies references), errors will abort evaluation.
The input should be
exactly one complete snippet of source code, that is, one expression,
statement, variable declaration, method declaration, class declaration,
or import.
To break arbitrary input into individual complete snippets, use
SourceCodeAnalysis.analyzeCompletion(String).
For imports, the import is added. Classes, interfaces. methods, and variables are defined. The initializer of variables, statements, and expressions are executed. The modifiers public, protected, private, static, and final are not allowed on op-level declarations and are ignored with a warning. Synchronized, native, abstract, and default top-level methods are not allowed and are errors. If a previous definition of a declaration is overwritten then there will be an event showing its status changed to OVERWRITTEN, this will not occur for dropped, rejected, or already overwritten declarations.
If execution environment is out of process, as is the default case, then
if the evaluated code
causes the execution environment to terminate, this JShell
instance will be closed but the calling process and VM remain valid.