changeset 3449:095bd53bdd1e jdk-9+121

8141415: JShell: wrap erroneous with one-liner comment-outed imports Reviewed-by: rfield
author shinyafox
date Sun, 29 May 2016 23:46:49 +0900
parents 2fa4e0cc6e60
children aff67f2dcb79 bf5a081596fb
files src/jdk.jshell/share/classes/jdk/jshell/ImportSnippet.java test/jdk/jshell/ImportTest.java
diffstat 2 files changed, 7 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/jdk.jshell/share/classes/jdk/jshell/ImportSnippet.java	Fri May 27 19:45:57 2016 -0400
+++ b/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/test/jdk/jshell/ImportTest.java	Fri May 27 19:45:57 2016 -0400
+++ b/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;");
+    }
 }