diff --git a/src/jdk.jshell/share/classes/jdk/internal/jshell/debug/InternalDebugControl.java b/src/jdk.jshell/share/classes/jdk/internal/jshell/debug/InternalDebugControl.java index a5854d89c0cdbe35f2f6d40b5bad933c640b23a6..48acdba965e89d6d0ef78284b90681c083afbe23 100644 --- a/src/jdk.jshell/share/classes/jdk/internal/jshell/debug/InternalDebugControl.java +++ b/src/jdk.jshell/share/classes/jdk/internal/jshell/debug/InternalDebugControl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -28,12 +28,11 @@ import java.util.HashMap; import java.util.Map; import jdk.jshell.JShell; -/** /** * This class is used to externally control output messages for debugging the * implementation of the JShell API. *

- * This is not part of the SPI, not API. + * This is not part of the SPI nor API. */ public class InternalDebugControl { @@ -141,7 +140,7 @@ public class InternalDebugControl { * @param ex the fatal Exception * @param where additional context */ - public static void debug(JShell state, PrintStream err, Exception ex, String where) { + public static void debug(JShell state, PrintStream err, Throwable ex, String where) { if (isDebugEnabled(state, 0xFFFFFFFF)) { err.printf("Fatal error: %s: %s\n", where, ex.getMessage()); ex.printStackTrace(err); diff --git a/src/jdk.jshell/share/classes/jdk/jshell/JShell.java b/src/jdk.jshell/share/classes/jdk/jshell/JShell.java index 99a9aac7618e1886fb13f6a8dd8894e7bab6fa43..bc7aa20f9906c752ac0db4898ee001c17ba5a32c 100644 --- a/src/jdk.jshell/share/classes/jdk/jshell/JShell.java +++ b/src/jdk.jshell/share/classes/jdk/jshell/JShell.java @@ -807,7 +807,7 @@ public class JShell implements AutoCloseable { InternalDebugControl.debug(this, err, flags, format, args); } - void debug(Exception ex, String where) { + void debug(Throwable ex, String where) { InternalDebugControl.debug(this, err, ex, where); } diff --git a/src/jdk.jshell/share/classes/jdk/jshell/SourceCodeAnalysisImpl.java b/src/jdk.jshell/share/classes/jdk/jshell/SourceCodeAnalysisImpl.java index 058a442a19667106a9d58c850857149af5092d82..5b7624e224005f19d8be707b423703d5ef341231 100644 --- a/src/jdk.jshell/share/classes/jdk/jshell/SourceCodeAnalysisImpl.java +++ b/src/jdk.jshell/share/classes/jdk/jshell/SourceCodeAnalysisImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -58,7 +58,6 @@ import com.sun.tools.javac.util.Names; import com.sun.tools.javac.util.Pair; import jdk.jshell.CompletenessAnalyzer.CaInfo; import jdk.jshell.TaskFactory.AnalyzeTask; -import jdk.jshell.TaskFactory.ParseTask; import java.util.ArrayList; import java.util.Collections; @@ -255,6 +254,9 @@ class SourceCodeAnalysisImpl extends SourceCodeAnalysis { suspendIndexing(); try { return completionSuggestionsImpl(code, cursor, anchor); + } catch (Throwable exc) { + proc.debug(exc, "Exception thrown in SourceCodeAnalysisImpl.completionSuggestions"); + return Collections.emptyList(); } finally { resumeIndexing(); } @@ -1148,6 +1150,9 @@ class SourceCodeAnalysisImpl extends SourceCodeAnalysis { suspendIndexing(); try { return documentationImpl(code, cursor, computeJavadoc); + } catch (Throwable exc) { + proc.debug(exc, "Exception thrown in SourceCodeAnalysisImpl.documentation"); + return Collections.emptyList(); } finally { resumeIndexing(); } diff --git a/test/langtools/jdk/jshell/ToolTabSnippetTest.java b/test/langtools/jdk/jshell/ToolTabSnippetTest.java index be916b6b6db09e37fc925bf302fb151731907690..ca30908db89728ba93d315430b668136ada0b7f4 100644 --- a/test/langtools/jdk/jshell/ToolTabSnippetTest.java +++ b/test/langtools/jdk/jshell/ToolTabSnippetTest.java @@ -23,7 +23,7 @@ /** * @test - * @bug 8177076 8185426 + * @bug 8177076 8185426 8188072 * @modules * jdk.compiler/com.sun.tools.javac.api * jdk.compiler/com.sun.tools.javac.main @@ -191,6 +191,10 @@ public class ToolTabSnippetTest extends UITesting { //no crash: inputSink.write("\u0003new Stringbuil\011"); waitOutput(out, "\u0005new Stringbuil\u0007"); + + //no crash: 8188072 + inputSink.write("\u0003for (int:\011"); + waitOutput(out, "\u0005for \\(int:\u0007"); }); }