提交 8299e92a 编写于 作者: R rfield

8188072: JShell: NPE in SourceCodeAnalysis.completionSuggestions()

Reviewed-by: jlahoda
上级 1259be97
/*
* 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.
* <p>
* 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);
......
......@@ -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);
}
......
/*
* 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();
}
......
......@@ -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");
});
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册