8188072: JShell: NPE in SourceCodeAnalysis.completionSuggestions()
Reviewed-by: jlahoda
This commit is contained in:
parent
c30a1e7cc4
commit
022c618af9
@ -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.
|
||||
* <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);
|
||||
}
|
||||
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -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");
|
||||
});
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user