问题描述
从可序列化的JavaDoc interface:
From second paragraph of JavaDoc of Serializable interface :
为什么在编译时检测不到此错误?
Why can't this error be detected at compile time ?
推荐答案
编译器旨在根据语言的要求检查代码,而不是单个库。该语言可以更改为添加执行额外检查的关键字或注释,并且库可以使用理论上的那些。
The compiler is designed to check the code based on the requirements of the language, not an individual library. The language could be changed to add a keyword or annotation which perform additional checks and the library could use those in theory.
有用的是,如果编译器可以运行库特定的检查代码以它可以加载注释的方式(这是目前纯粹的数据)这种方式额外的检查可以在编译时执行,而不知道任何单独的库的行为。
What would be useful is if the compiler could run library specific checking code in the way it can load annotations (which are currently purely data) This way additional checks could be performed at compile time without it knowing the behaviour of any individual library.
这篇关于为什么编译器不能在编译时检测到关于Serializable声明的这个错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!