From 3ff9cf19e274e9ac02751e00e01a84a21a86de07 Mon Sep 17 00:00:00 2001 From: Shinya Yoshida Date: Sun, 29 May 2016 23:46:49 +0900 Subject: [PATCH] 8141415: JShell: wrap erroneous with one-liner comment-outed imports Reviewed-by: rfield --- .../jdk.jshell/share/classes/jdk/jshell/ImportSnippet.java | 2 +- langtools/test/jdk/jshell/ImportTest.java | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/langtools/src/jdk.jshell/share/classes/jdk/jshell/ImportSnippet.java b/langtools/src/jdk.jshell/share/classes/jdk/jshell/ImportSnippet.java index d906b39d8c2..bf2ec5e22ae 100644 --- a/langtools/src/jdk.jshell/share/classes/jdk/jshell/ImportSnippet.java +++ b/langtools/src/jdk.jshell/share/classes/jdk/jshell/ImportSnippet.java @@ -101,6 +101,6 @@ public class ImportSnippet extends PersistentSnippet { @Override String importLine(JShell state) { - return source(); + return guts().wrapped(); } } diff --git a/langtools/test/jdk/jshell/ImportTest.java b/langtools/test/jdk/jshell/ImportTest.java index 66e1a5f44ea..d5b03c47f41 100644 --- a/langtools/test/jdk/jshell/ImportTest.java +++ b/langtools/test/jdk/jshell/ImportTest.java @@ -23,6 +23,7 @@ /* * @test + * @bug 8141415 * @summary Test imports * @modules jdk.compiler/com.sun.tools.javac.api * jdk.compiler/com.sun.tools.javac.main @@ -162,4 +163,9 @@ public class ImportTest extends KullaTesting { assertEval("field;", "\"A\""); assertEval("method();", "\"A\""); } + + public void testImportWithComment() { + assertImportKeyMatch("import java.util.List;//comment", "List", SINGLE_TYPE_IMPORT_SUBKIND, added(VALID)); + assertEval("List l = null;"); + } }