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

后端 未结 2 1068
渐次进展
渐次进展 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:21

    I've raised it as a bug and it's been accepted.

    https://bugs.openjdk.java.net/browse/JDK-8211694

    Good spot.

    0 讨论(0)
  • 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.

    0 讨论(0)
提交回复
热议问题