java编译器的目标版本“jsr14”与JDK7/8

发布于 2024-09-30 02:00:42 字数 154 浏览 3 评论 0原文

谁能告诉我 javacjsr14 目标选项在 JDK7/8 中仍然可用?

说,

$ javac -source 1.5 -target jsr14 Hello.java

Can anybody tell me the jsr14 target option of javac will be still available with JDK7/8?

Say,

$ javac -source 1.5 -target jsr14 Hello.java

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

翻身的咸鱼 2024-10-07 02:00:42

我们在 OSGi 中大量使用 -jsr14,因为它允许我们在 API 中使用泛型,但仍然部署在 1.4 环境上,这在嵌入式中仍然很流行。不幸的是,他们 JDK 7 不向后兼容 Java 6 和 5。Javac 1.7 忽略了 JAR 文件中实际存在的通用信息。幸运的是,运行时没有问题,因为无论如何都会忽略此信息。这并不是什么没有记录的功能......

不幸的是,前面的人通常很少尊重那些不能更新到最新和最好的人。我猜Oracle真的不再关心嵌入式市场了。

我们现在可能必须发布两个 JAR,一个用于嵌入式,一个用于 JDK 7。这很糟糕。

这是我们提交的错误报告:https://bugs.java.com/bugdatabase/ view_bug?bug_id=7078419

We are heavily using -jsr14 in OSGi because it allows us to use generics in our API but still deploy on 1.4 environments, which are still popular in embedded. Unfortunately, they made JDK 7 not backward compatible with Java 6 and 5. Javac 1.7 ignores the generic information that is actually present in the JAR files. There is fortunately no problem at run-time as this info is ignored anyway. And it is not as if this was some undocumented feature ...

Unfortunately, people at the front often have very little regard for the people that cannot just update to the latest and the greatest. Guess Oracle really does not care about the embedded markets anymore.

We will likely now have to ship two JARs, one for the embedded and one for JDK 7. Sucks.

This is the bug report we filed: https://bugs.java.com/bugdatabase/view_bug?bug_id=7078419

温柔一刀 2024-10-07 02:00:42

最新的 OpenJDK 源包 (openjdk-7-ea-src-b130-18_feb_2011.zip) 仍然在源代码 (langtools/src/share/classes/com/sun/ tools/javac/jvm/Target.java),但它从未被支持,所以依赖它是一个坏主意。

为什么需要它?

The latest OpenJDK source bundle (openjdk-7-ea-src-b130-18_feb_2011.zip) still contains the flag in the source (langtools/src/share/classes/com/sun/tools/javac/jvm/Target.java), but it has never been supported, so relying on it is a bad idea.

Why do you need it?

树深时见影 2024-10-07 02:00:42

自 1.5 测试阶段以来,该标志已被废弃。
包含它只是为了允许 1.5 beta 编译器默认绕过泛型检查/解析,而泛型规范尚未最终确定。
1.5 版本发布后,该标志就变得毫无意义。新的编译器版本可能不会在遇到它时给出错误,但很可能会默默地忽略它。

That flag has been abandoned since the beta stages of 1.5.
It was only included to allow the 1.5 beta compiler to bypass generics checking/parsing by default while the generics specification wasn't finalised.
Once 1.5 was released, that flag became meaningless. New compiler versions may not give errors on encountering it but will most likely silently ignore it.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文