8141415: JShell: wrap erroneous with one-liner comment-outed imports
authorshinyafox
Sun, 29 May 2016 23:46:49 +0900
changeset 38620 c95c5bc94fad
parent 38619 27c0007bb28d
child 38621 10445cbe36a7
8141415: JShell: wrap erroneous with one-liner comment-outed imports Reviewed-by: rfield
langtools/src/jdk.jshell/share/classes/jdk/jshell/ImportSnippet.java
langtools/test/jdk/jshell/ImportTest.java
--- 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;");
+    }
 }