--- old/src/jdk.jshell/share/classes/jdk/jshell/Eval.java 2016-07-15 00:13:44.358667028 -0700 +++ new/src/jdk.jshell/share/classes/jdk/jshell/Eval.java 2016-07-15 00:13:44.270664800 -0700 @@ -61,6 +61,14 @@ import jdk.jshell.TreeDissector.ExpressionInfo; import jdk.jshell.Wrap.Range; import jdk.jshell.Snippet.Status; +import jdk.jshell.spi.ExecutionControl.ClassBytecodes; +import jdk.jshell.spi.ExecutionControl.ClassInstallException; +import jdk.jshell.spi.ExecutionControl.EngineTerminationException; +import jdk.jshell.spi.ExecutionControl.InternalException; +import jdk.jshell.spi.ExecutionControl.NotImplementedException; +import jdk.jshell.spi.ExecutionControl.ResolutionException; +import jdk.jshell.spi.ExecutionControl.RunException; +import jdk.jshell.spi.ExecutionControl.UserException; import static java.util.stream.Collectors.toList; import static java.util.stream.Collectors.toSet; import static java.util.Collections.singletonList; @@ -541,15 +549,21 @@ if (si.status().isDefined()) { if (si.isExecutable()) { try { - value = state.executionControl().invoke(si.classFullName(), DOIT_METHOD_NAME); + value = state.executionControl().invoke(si.classFullName(), DOIT_METHOD_NAME); value = si.subKind().hasValue() ? expunge(value) : ""; - } catch (EvalException ex) { + } catch (ResolutionException ex) { + DeclarationSnippet sn = (DeclarationSnippet) state.maps.getSnippetDeadOrAlive(ex.id()); + exception = new UnresolvedReferenceException(sn, ex.getStackTrace()); + } catch (UserException ex) { exception = translateExecutionException(ex); - } catch (JShellException ex) { - // UnresolvedReferenceException - exception = ex; + } catch (RunException ex) { + // StopException - no-op + } catch (InternalException ex) { + state.debug(ex, "invoke"); + } catch (EngineTerminationException ex) { + state.closeDown(); } } else if (si.subKind() == SubKind.VAR_DECLARATION_SUBKIND) { switch (((VarSnippet) si).typeName()) { @@ -700,15 +714,25 @@ /** * If there are classes to load, loads by calling the execution engine. - * @param classnames names of the classes to load. + * @param classbytecoes names of the classes to load. */ - private void load(Collection classnames) { - if (!classnames.isEmpty()) { - state.executionControl().load(classnames); + private void load(Collection classbytecoes) { + if (!classbytecoes.isEmpty()) { + ClassBytecodes[] cbcs = classbytecoes.toArray(new ClassBytecodes[classbytecoes.size()]); + try { + state.executionControl().load(cbcs); + state.classTracker.markLoaded(cbcs); + } catch (ClassInstallException ex) { + state.classTracker.markLoaded(cbcs, ex.installed()); + } catch (NotImplementedException ex) { + state.debug(ex, "Seriously?!? load not implemented"); + } catch (EngineTerminationException ex) { + state.closeDown(); + } } } - private EvalException translateExecutionException(EvalException ex) { + private EvalException translateExecutionException(UserException ex) { StackTraceElement[] raw = ex.getStackTrace(); int last = raw.length; do { @@ -739,7 +763,7 @@ if (msg.equals("")) { msg = null; } - return new EvalException(msg, ex.getExceptionClassName(), elems); + return new EvalException(msg, ex.causeExceptionClass(), elems); } private boolean isWrap(StackTraceElement ste) {