Community
Participate
Working Groups
One of the following JUnit tests fail: class A { boolean called = false; void callOnce(int i) { if (called) { throw new IllegalArgumentException(); } else { called = true; } } } @Test public void fine() { IntStream.of(1, 2, 3).forEach(i -> new A().callOnce(i)); } @Test public void error() { IntStream.of(1, 2, 3).forEach(new A()::callOnce); } Fine and error can be changed to one another using Ctrl + 1 and Convert to lambda expression or Convert to method reference, but the semantics of the two are not identical. Fine creates a new A for each forEach, while error reuses the same instance of A for each forEach.
It should be handled with bug 499863. *** This bug has been marked as a duplicate of bug 499863 ***