# HG changeset patch # User rfield # Date 1460137917 25200 # Node ID 71210037624f02a0a3990bfc3735d3a2cf1b273d # Parent ff77b7986967934d78b81c6c375174e3307cb6ca 8130450: JShell: events are not generated for repeated source 8139835: JShell API: Snippet.id() doc -- specify: no meaning, dynamic Reviewed-by: jlahoda diff -r ff77b7986967 -r 71210037624f langtools/src/jdk.jshell/share/classes/jdk/jshell/Eval.java --- a/langtools/src/jdk.jshell/share/classes/jdk/jshell/Eval.java Fri Apr 08 11:52:46 2016 +0200 +++ b/langtools/src/jdk.jshell/share/classes/jdk/jshell/Eval.java Fri Apr 08 10:51:57 2016 -0700 @@ -449,13 +449,6 @@ private List declare(Snippet si, DiagList generatedDiagnostics) { Unit c = new Unit(state, si, null, generatedDiagnostics); - - // Ignores duplicates - //TODO: remove, modify, or move to edit - if (c.isRedundant()) { - return Collections.emptyList(); - } - Set ins = new LinkedHashSet<>(); ins.add(c); Set outs = compileAndLoad(ins); diff -r ff77b7986967 -r 71210037624f langtools/src/jdk.jshell/share/classes/jdk/jshell/Snippet.java --- a/langtools/src/jdk.jshell/share/classes/jdk/jshell/Snippet.java Fri Apr 08 11:52:46 2016 +0200 +++ b/langtools/src/jdk.jshell/share/classes/jdk/jshell/Snippet.java Fri Apr 08 10:51:57 2016 -0700 @@ -524,7 +524,9 @@ /** * The unique identifier for the snippet. No two active snippets will have - * the same id(). + * the same id(). Value of id has no prescribed meaning. The details of + * how the id is generated and the mechanism to change it is documented in + * {@link JShell.Builder#idGenerator()}. * @return the snippet id string. */ public String id() { diff -r ff77b7986967 -r 71210037624f langtools/src/jdk.jshell/share/classes/jdk/jshell/Unit.java --- a/langtools/src/jdk.jshell/share/classes/jdk/jshell/Unit.java Fri Apr 08 11:52:46 2016 +0200 +++ b/langtools/src/jdk.jshell/share/classes/jdk/jshell/Unit.java Fri Apr 08 10:51:57 2016 -0700 @@ -140,12 +140,6 @@ return isNew; } - boolean isRedundant() { - return !isNew && !isDependency() && !si.isExecutable() && - prevStatus.isDefined && - siOld.source().equals(si.source()); - } - void initialize(Collection working) { isAttemptingCorral = false; dependenciesNeeded = false; diff -r ff77b7986967 -r 71210037624f langtools/test/jdk/jshell/SimpleRegressionTest.java --- a/langtools/test/jdk/jshell/SimpleRegressionTest.java Fri Apr 08 11:52:46 2016 +0200 +++ b/langtools/test/jdk/jshell/SimpleRegressionTest.java Fri Apr 08 10:51:57 2016 -0700 @@ -22,7 +22,7 @@ */ /* - * @test + * @test 8130450 * @summary simple regression test * @build KullaTesting TestingInputStream * @run testng SimpleRegressionTest @@ -39,6 +39,7 @@ import org.testng.annotations.Test; import static org.testng.Assert.assertEquals; +import static jdk.jshell.Snippet.Status.OVERWRITTEN; import static jdk.jshell.Snippet.SubKind.TEMP_VAR_EXPRESSION_SUBKIND; import static jdk.jshell.Snippet.Status.VALID; @@ -98,4 +99,16 @@ VarSnippet sne = varKey(assertEval("n(5)", added(VALID))); assertEquals(sne.typeName(), "Integer"); } + + // 8130450 + public void testDuplicate() { + Snippet snm = methodKey(assertEval("void mm() {}", added(VALID))); + assertEval("void mm() {}", + ste(MAIN_SNIPPET, VALID, VALID, false, null), + ste(snm, VALID, OVERWRITTEN, false, MAIN_SNIPPET)); + Snippet snv = varKey(assertEval("boolean b;", added(VALID))); + assertEval("boolean b;", + ste(MAIN_SNIPPET, VALID, VALID, false, null), + ste(snv, VALID, OVERWRITTEN, false, MAIN_SNIPPET)); + } }