In jshell-11, why does a redeclared reference variable that resets to null still have a type?

后端 未结 2 1067
渐次进展
渐次进展 2021-02-19 19:22

When redeclaring Integer \'a\' in line 33, why does jshell show the reference variable as an instance of Integer (refer to lines 38 & 39)? After the redeclaration, line 34 s

2条回答
  •  情深已故
    2021-02-19 20:22

    The problem is that, though it says it is set to null, it actually isn't. See added comments in bug for more detail.

    I've changed the bug title to: JShell: Redeclared variable should be reset

    I'll attempt to fix in JDK 12.

    The second issue is not a bug, Java does not allow instanceof operators that cannot be true -- behavior matches javac exactly.

提交回复
热议问题