8130450: JShell: events are not generated for repeated source

8139835: JShell API: Snippet.id() doc -- specify: no meaning, dynamic

Reviewed-by: jlahoda
This commit is contained in:
Robert Field 2016-04-08 10:51:57 -07:00
parent 00bcf17e91
commit 39df1f1336
4 changed files with 17 additions and 15 deletions

View File

@ -449,13 +449,6 @@ class Eval {
private List<SnippetEvent> 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<Unit> ins = new LinkedHashSet<>();
ins.add(c);
Set<Unit> outs = compileAndLoad(ins);

View File

@ -524,7 +524,9 @@ public abstract class Snippet {
/**
* 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() {

View File

@ -140,12 +140,6 @@ final class Unit {
return isNew;
}
boolean isRedundant() {
return !isNew && !isDependency() && !si.isExecutable() &&
prevStatus.isDefined &&
siOld.source().equals(si.source());
}
void initialize(Collection<Unit> working) {
isAttemptingCorral = false;
dependenciesNeeded = false;

View File

@ -22,7 +22,7 @@
*/
/*
* @test
* @test 8130450
* @summary simple regression test
* @build KullaTesting TestingInputStream
* @run testng SimpleRegressionTest
@ -39,6 +39,7 @@ import jdk.jshell.SnippetEvent;
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 @@ public class SimpleRegressionTest extends KullaTesting {
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));
}
}