final variables are not functioning well in jshell

不问归期 提交于 2019-11-29 07:12:14

While creating a final variable at the top-level is not supposed to be practiced. But I guess there is no hard way of restricting such usages.

From the documentation around JShell.eval

The modifiers public, protected, private, static, and final are not allowed on op-level declarations and are ignored with a warning.

Synchronized, native, abstract, and default top-level methods are not allowed and are errors.

If a previous definition of a declaration is overwritten then there will be an event showing its status changed to OVERWRITTEN, this will not occur for dropped, rejected, or already overwritten declarations.

The warning stated above is quite visible when you execute jshell in verbose mode as follows:

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!