简体   繁体   English

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

[英]java compiler's target version “jsr14” with JDK7/8

Can anybody tell me the jsr14 target option of javac will be still available with JDK7/8? 任何人都可以告诉我javacjsr14目标选项仍然可用于JDK7 / 8吗?

Say, 说,

$ javac -source 1.5 -target jsr14 Hello.java

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. 我们在OSGi中大量使用-jsr14,因为它允许我们在API中使用泛型但仍然部署在1.4环境中,这些环境在嵌入式环境中仍然很流行。 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. 不幸的是,它们使 JDK 7不能向后兼容Java 6和5.Javac 1.7忽略了JAR文件中实际存在的通用信息。 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. 猜猜Oracle真的不再关心嵌入式市场了。

We will likely now have to ship two JARs, one for the embedded and one for JDK 7. Sucks. 我们现在可能需要发布两个JAR,一个用于嵌入式,一个用于JDK 7.糟透了。

This is the bug report we filed: http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=7078419 这是我们提交的错误报告: http//bugs.sun.com/bugdatabase/view_bug.do?bug_id=7078419

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. 最新的OpenJDK源代码包( openjdk-7-ea-src-b130-18_feb_2011.zip )仍包含源代码中的标志( langtools/src/share/classes/com/sun/tools/javac/jvm/Target.java ) ,但从未得到过支持,所以依靠它是一个坏主意。

Why do you need it? 你为什么需要它?

That flag has been abandoned since the beta stages of 1.5. 该标志自1.5的beta阶段以来已被放弃。 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. 仅包含允许1.5 beta编译器在泛型规范未最终确定时默认绕过泛型检查/解析。 Once 1.5 was released, that flag became meaningless. 一旦1.5被释放,那面旗帜变得毫无意义。 New compiler versions may not give errors on encountering it but will most likely silently ignore it. 新的编译器版本在遇到它时可能不会出错,但很可能会默默地忽略它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM