src/jdk.jshell/share/classes/jdk/jshell/Eval.java

Print this page

        

*** 59,68 **** --- 59,76 ---- import jdk.jshell.TaskFactory.CompileTask; import jdk.jshell.TaskFactory.ParseTask; 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; import static jdk.internal.jshell.debug.InternalDebugControl.DBG_GEN; import static jdk.jshell.Util.DOIT_METHOD_NAME;
*** 543,557 **** try { value = state.executionControl().invoke(si.classFullName(), DOIT_METHOD_NAME); value = si.subKind().hasValue() ? expunge(value) : ""; ! } catch (EvalException ex) { exception = translateExecutionException(ex); ! } catch (JShellException ex) { ! // UnresolvedReferenceException ! exception = ex; } } else if (si.subKind() == SubKind.VAR_DECLARATION_SUBKIND) { switch (((VarSnippet) si).typeName()) { case "byte": case "short": --- 551,571 ---- try { value = state.executionControl().invoke(si.classFullName(), DOIT_METHOD_NAME); value = si.subKind().hasValue() ? expunge(value) : ""; ! } catch (ResolutionException ex) { ! DeclarationSnippet sn = (DeclarationSnippet) state.maps.getSnippetDeadOrAlive(ex.id()); ! exception = new UnresolvedReferenceException(sn, ex.getStackTrace()); ! } catch (UserException ex) { exception = translateExecutionException(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()) { case "byte": case "short":
*** 698,716 **** } } /** * If there are classes to load, loads by calling the execution engine. ! * @param classnames names of the classes to load. */ ! private void load(Collection<String> classnames) { ! if (!classnames.isEmpty()) { ! state.executionControl().load(classnames); } } ! private EvalException translateExecutionException(EvalException ex) { StackTraceElement[] raw = ex.getStackTrace(); int last = raw.length; do { if (last == 0) { last = raw.length - 1; --- 712,740 ---- } } /** * If there are classes to load, loads by calling the execution engine. ! * @param classbytecoes names of the classes to load. */ ! private void load(Collection<ClassBytecodes> 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(UserException ex) { StackTraceElement[] raw = ex.getStackTrace(); int last = raw.length; do { if (last == 0) { last = raw.length - 1;
*** 737,747 **** } String msg = ex.getMessage(); if (msg.equals("<none>")) { msg = null; } ! return new EvalException(msg, ex.getExceptionClassName(), elems); } private boolean isWrap(StackTraceElement ste) { return PREFIX_PATTERN.matcher(ste.getClassName()).find(); } --- 761,771 ---- } String msg = ex.getMessage(); if (msg.equals("<none>")) { msg = null; } ! return new EvalException(msg, ex.causeExceptionClass(), elems); } private boolean isWrap(StackTraceElement ste) { return PREFIX_PATTERN.matcher(ste.getClassName()).find(); }