test/langtools/jdk/jshell/VariablesTest.java
changeset 52775 d488477865c0
parent 52282 003c062e16ea
--- a/test/langtools/jdk/jshell/VariablesTest.java	Thu Nov 29 06:34:46 2018 -0800
+++ b/test/langtools/jdk/jshell/VariablesTest.java	Thu Nov 29 17:45:29 2018 -0800
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @bug 8144903 8177466 8191842 8211694
+ * @bug 8144903 8177466 8191842 8211694 8213725
  * @summary Tests for EvaluationState.variables
  * @library /tools/lib
  * @modules jdk.compiler/com.sun.tools.javac.api
@@ -492,6 +492,21 @@
         assertVarDeclRedefNoInit("String", "s", "\"hi\"", "null");
     }
 
+    public void badPkgVarDecl() {
+        Compiler compiler = new Compiler();
+        Path nopkgdirpath = Paths.get("cp", "xyz");
+        compiler.compile(nopkgdirpath,
+                "public class TestZ { public static int V = 0; }\n");
+        assertDeclareFail("import static xyz.TestZ.V;",
+                        "compiler.err.cant.access");
+
+
+        VarSnippet v1 = varKey(assertEval("var v = xyz.TestZ.V;", IGNORE_VALUE, null,
+                DiagCheck.DIAG_ERROR, DiagCheck.DIAG_OK, added(RECOVERABLE_NOT_DEFINED)));
+        assertVariableDeclSnippet(v1, "v", "java.lang.Object", RECOVERABLE_NOT_DEFINED, SubKind.VAR_DECLARATION_WITH_INITIALIZER_SUBKIND, 0, 1);
+        assertEval("1+1", "2");
+    }
+
     private void assertVarDeclRedefNoInit(String typeName, String name, String value, String dvalue) {
         assertVarDeclRedefNoInit(typeName, name, value, value, dvalue);
     }