RFR: JDK-8189248: Jshell /open from file generate error when it tries to upcast to typed instance of other with type inferred from it
Jan Lahoda
jan.lahoda at oracle.com
Tue Dec 5 14:02:36 UTC 2017
Hi,
Consider these snippet sent (in this order) to jshell:
---
public class A<T> {
private class SomeClass {}
public Supplier<T> m() {
return new B<>(this);
}
}
---
(note this depends on the future snippet declaring class B)
---
public class B<T> implements Supplier<T> {
public B(A<T> a) {}
public T get() {return null;}
}
---
Eval.compileAndLoad will after a few rounds try to compile inputs like:
---
package REPL;
import java.util.function.Supplier;
import static REPL.$JShell$3.B;
class $JShell$2B {
public static class A<T>
...
}
---
package REPL;
import java.util.function.Supplier;
import static REPL.$JShell$2.A;
class $JShell$3 {
public static class B<T> implements Supplier<T>
...
}
----
Please note that "B" is using the old (pre-Unit.markForReplacement())
version of A from $JShell$2. While the new declaration is inside
$JShell$2B. I think this is because the classnames are updates only as
setWrap(s) run, so the wraps that run first may still see old classnames
for the latter snippets.
The proposal is to ensure the proper classnames are set before trying to
run:
ins.stream().forEach(u -> u.setWrap(ins, ins));
which creates the real wraps that are processed.
Bug: https://bugs.openjdk.java.net/browse/JDK-8189248
Webrev: http://cr.openjdk.java.net/~jlahoda/8189248/webrev.00/
How does it look?
Thanks,
Jan
More information about the kulla-dev
mailing list