# HG changeset patch # User rfield # Date 1471882331 25200 # Node ID 9e0e107c39ddd10aedbcea3cb3ec4a409a95bd7e # Parent 819fc588bd1954a8a58b811db8d67aac6c468cb1 8154374: JShell: setContextClassLoader() for remote Snippet class loader 8080347: jshell tool: /vars when the status is other than Active Reviewed-by: jlahoda diff -r 819fc588bd19 -r 9e0e107c39dd langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/JShellTool.java --- a/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/JShellTool.java Mon Aug 22 08:18:18 2016 -0700 +++ b/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/JShellTool.java Mon Aug 22 09:12:11 2016 -0700 @@ -1919,7 +1919,7 @@ { String val = state.status(vk) == Status.VALID ? state.varValue(vk) - : "jshell.msg.vars.not.active"; + : getResourceString("jshell.msg.vars.not.active"); hard(" %s %s = %s", vk.typeName(), vk.name(), val); }); return true; diff -r 819fc588bd19 -r 9e0e107c39dd langtools/src/jdk.jshell/share/classes/jdk/jshell/execution/DefaultLoaderDelegate.java --- a/langtools/src/jdk.jshell/share/classes/jdk/jshell/execution/DefaultLoaderDelegate.java Mon Aug 22 08:18:18 2016 -0700 +++ b/langtools/src/jdk.jshell/share/classes/jdk/jshell/execution/DefaultLoaderDelegate.java Mon Aug 22 09:12:11 2016 -0700 @@ -77,6 +77,7 @@ public DefaultLoaderDelegate() { this.loader = new RemoteClassLoader(); + Thread.currentThread().setContextClassLoader(loader); } @Override diff -r 819fc588bd19 -r 9e0e107c39dd langtools/test/jdk/jshell/SimpleRegressionTest.java --- a/langtools/test/jdk/jshell/SimpleRegressionTest.java Mon Aug 22 08:18:18 2016 -0700 +++ b/langtools/test/jdk/jshell/SimpleRegressionTest.java Mon Aug 22 09:12:11 2016 -0700 @@ -22,7 +22,7 @@ */ /* - * @test 8130450 8158906 + * @test 8130450 8158906 8154374 * @summary simple regression test * @build KullaTesting TestingInputStream * @run testng SimpleRegressionTest @@ -144,4 +144,9 @@ ste(MAIN_SNIPPET, VALID, VALID, false, null), ste(snv, VALID, OVERWRITTEN, false, MAIN_SNIPPET)); } + + public void testContextClassLoader() { + assertEval("class C {}"); + assertEval("C.class.getClassLoader() == Thread.currentThread().getContextClassLoader()", "true"); + } } diff -r 819fc588bd19 -r 9e0e107c39dd langtools/test/jdk/jshell/ToolBasicTest.java --- a/langtools/test/jdk/jshell/ToolBasicTest.java Mon Aug 22 08:18:18 2016 -0700 +++ b/langtools/test/jdk/jshell/ToolBasicTest.java Mon Aug 22 09:12:11 2016 -0700 @@ -23,7 +23,7 @@ /* * @test - * @bug 8143037 8142447 8144095 8140265 8144906 8146138 8147887 8147886 8148316 8148317 8143955 8157953 + * @bug 8143037 8142447 8144095 8140265 8144906 8146138 8147887 8147886 8148316 8148317 8143955 8157953 8080347 * @summary Tests for Basic tests for REPL tool * @modules jdk.compiler/com.sun.tools.javac.api * jdk.compiler/com.sun.tools.javac.main @@ -542,6 +542,13 @@ } } + public void testVarsWithNotActive() { + test( + a -> assertVariable(a, "Blath", "x"), + a -> assertCommandOutputContains(a, "/var -all", "(not-active)") + ); + } + public void testHistoryReference() { test(false, new String[]{"-nostartup"}, a -> assertCommand(a, "System.err.println(1)", "", "", null, "", "1\n"),