JShell behavior question: Variable re-declaration without initializer
Robert Field
robert.field at oracle.com
Mon Oct 22 17:01:23 UTC 2018
The current behavior of JShell is that redeclaring a variable without
initializer does not reset the value of the variable (even though the
value of the declaration lies) --
jshell> int x = 44
x ==> 44
jshell> int x
x ==> 0
jshell> x
x ==> 44
*Is there any reason to preserve this semantics? *
One significant effect would be that VAR_DECLARATION_SUBKIND becomes an
executable -- Snippet.isExecutable() returns true.
One major motivation for resetting it would be that sequences of
re-evaluated code behave consistently.
-Robert
More information about the kulla-dev
mailing list