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;"); + } }