In Java 8, this code prints
1
1
1
1
...
In Java 9-12, this prints
1
1
2
NaN
1
1
2
NaN
NaN
NaN
NaN
NaN
NaN
NaN
NaN
NaN
NaN
NaN
NaN
NaN
NaN
NaN
NaN
NaN
NaN
NaN
NaN
NaN
NaN
NaN
NaN
NaN
NaN
1
2
1
2
1
2
1
The test
function is somehow shared between contexts.
Any of these changes will result in the expected behavior:
- commenting out either
x = 1
oreval('');
- calling
print(++test.calls);
beforex = 1
; - omitting context in the calls to
engine.eval