兼容的 Java 实现可以不包含所有标准库吗?
我正在致力于用 JavaScript 编写 JVM 的实现,这意味着用 JavaScript 为标准库编写大量本机代码。然而,标准库中有大量的类仅由少数程序使用,并且尝试将需要本机实现的部分本地实现既乏味又没有多大回报。
实际上是否要求有效的 Java 实现包含所有标准库类的实现?或者我是否可以让核心 Java 库(例如 java.lang.* 及其引用的所有内容)工作,然后声称我有一个兼容的 Java 实现,该实现可能会为引用未实现功能的代码抛出VerifyErrors?
I'm working on writing an implementation of the JVM in JavaScript, which means writing a lot of native code for the standard libraries in JavaScript. However, there are a huge number of classes in the standard library that are used only by a small number of programs, and trying to get the parts that need a native implementation implemented natively is both tedious and not very rewarding.
Is there actually a requirement that a valid Java implementation contain implementations of all the standard library classes? Or could I just get the core Java libraries (say, java.lang.* and everything it references) working and then claim that I had a compliant Java implementation that might throw VerifyErrors for code that references unimplemented features?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
实际上,在通过合规性测试套件(Oracle 并未发布该测试套件)之前,您不能声称自己拥有符合该标准的 Java 实现。所以你最好忘记这一点。
所以基本上你可以支持任何你想要的东西,记住开发人员不太可能使用在功能上有任意差距的东西。将自己限制在标准 API 的众所周知的子集(例如 Java ME 配置文件)可能是个好主意。
Actually, you won't be allowed to claim you have a Java implementation compliant to the standard until it's passed the compliance test suite - which Oracle does not publish. So you might as well forget about that.
So basically you can support whatever you want, keeping in mind that developers are unlikely to use something that has arbitrary gaps in functionality. It might be a good idea to restrict yourself to a well-known subset of the Standard API like a Java ME profile.