且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

为什么编译器不能在编译时检测到关于Serializable声明的这个错误?

更新时间:2023-09-24 15:34:40

编译器旨在根据语言的要求检查代码,而不是单个库。该语言可以更改为添加执行额外检查的关键字或注释,并且库可以使用理论上的那些。

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.