java-repl
java-repl copied to clipboard
Anything returning a Stream breaks REPL
It seems that returning a stream into one of the resX variables breaks the REPL.
The following breaks JavaREPL reliably:
Object[] o1 = new Object[1];
o1[0] = "hello"
o1
Object[] o2 = new Object[2];
o2[0] = "world";
o2[1] = "foo"
List<Object[]> l = new ArrayList<>()
l.add(o1)
l.add(o2)
l.stream()
From this point forward, every single command will output the following:
ERROR: package java.util.stream.ReferencePipeline does not exist
public java.util.stream.ReferencePipeline.Head res14 = valueOf("res14");
However, streams themselves seem to be okay. The following works flawlessly:
Object[] o1 = new Object[1];
o1[0] = "hello"
o1
Object[] o2 = new Object[2];
o2[0] = "world";
o2[1] = "foo"
List<Object[]> l = new ArrayList<>()
l.add(o1)
l.add(o2)
l.stream().map(java.util.Arrays::toString).collect(Collectors.toList())
I am using Java 1.8.0_11
Observed the same behaviour
java> 1
java.lang.Integer res2 = 1
java> Arrays.asList(1,2,3).stream().parallel();
java.util.stream.ReferencePipeline.Head res3 = java.util.stream.ReferencePipeline$Head@6b0839b6
java> 1
ERROR: not a statement
1;
^
ERROR: package java.util.stream.ReferencePipeline does not exist
public java.util.stream.ReferencePipeline.Head res3 = valueOf("res3");
On my machine, the stream is returned when invoked at the first time and fails afterwards
java> list = new ArrayList<Integer>()
java.util.ArrayList list = []
java> list.stream()
java.util.stream.ReferencePipeline.Head res1 = java.util.stream.ReferencePipeline$Head@5e76dc2c
java> list.stream()
ERROR: package java.util.stream.ReferencePipeline does not exist
public java.util.stream.ReferencePipeline.Head res1 = valueOf("res1");
^
@Shufeng01 After calling stream() for the first time, execute any other command and it should display the same error even though it has nothing to do with the stream. Check what @mishadoff does by just entering "1".