8141415: JShell: wrap erroneous with one-liner comment-outed imports
Reviewed-by: rfield
--- a/langtools/src/jdk.jshell/share/classes/jdk/jshell/ImportSnippet.java Fri May 27 19:45:57 2016 -0400
+++ b/langtools/src/jdk.jshell/share/classes/jdk/jshell/ImportSnippet.java Sun May 29 23:46:49 2016 +0900
@@ -101,6 +101,6 @@
@Override
String importLine(JShell state) {
- return source();
+ return guts().wrapped();
}
}
--- a/langtools/test/jdk/jshell/ImportTest.java Fri May 27 19:45:57 2016 -0400
+++ b/langtools/test/jdk/jshell/ImportTest.java Sun May 29 23:46:49 2016 +0900
@@ -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 @@
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;");
+ }
}