简体   繁体   English

EJB规范和Java版本 - 向后兼容性

[英]EJB specifications and Java versions - backwards compatibility

This is my understanding of relationship between the EJB spec and Java versions 这是我对EJB规范和Java版本之间关系的理解

  • EJB 2.0 was part of J2EE 1.3 platform, which was on top J2SE 1.3 or JDK 1.3.x EJB 2.0是J2EE 1.3平台的一部分,它位于顶级J2SE 1.3或JDK 1.3.x之上
  • EJB 2.1 was part of J2EE 1.4 platform, which was on top of J2SE 1.4 or JDK 1.4.x EJB 2.1是J2EE 1.4平台的一部分,它位于J2SE 1.4或JDK 1.4.x之上

The EJB 2.1 specification requires backward compatibility for EJB 2.0, so containers supporting EJB 2.1 and running in JDK 1.4.x will be able to run EJB 2.0 beans as well. EJB 2.1规范要求EJB 2.0具有向后兼容性,因此支持EJB 2.1并在JDK 1.4.x中运行的容器也能够运行EJB 2.0 bean。

  • EJB 3.0 is part of Java EE 5 platform, which required Java SE 5 (JDK 5) for annotations etc EJB 3.0是Java EE 5平台的一部分,它需要Java SE 5(JDK 5)来进行注释等

The EJB 3 spec requires backward compatibility for earlier version of the specifications. EJB 3规范要求对早期版本的规范进行向后兼容。

My question is this. 我的问题是这个。 If I upgrade the java code for the implementation of the EJB 2.0 beans to compile against a later version of Java (say Java 5), can I still keep the same version of the EJB spec or do I need to migrate this as well. 如果我升级用于实现EJB 2.0 bean的java代码以针对更高版本的Java(比如Java 5)进行编译,我是否仍然可以保留相同版本的EJB规范,或者我是否也需要迁移它。

You shouldn't even have to "upgrade" the Java code, since I think older code can only be incompatible at source level due to identifiers that collide with newly introduced keywords, but that's not a problem at the bytecode level. 您甚至不必“升级”Java代码,因为我认为旧代码只能在源代码级别由于与新引入的关键字冲突的标识符而不兼容,但这在字节码级别不是问题。

So your old Java 1.3/EJB 2.0 EARs should still run unchanged on a Java 5/EJB 3 appserver, and you could even do bugfixes in code and compile it with -target 1.3 on a modern JDK without having to fix the colliding identifiers (of course you then also cannot use the new source-level features). 因此,您的旧Java 1.3 / EJB 2.0 EAR应该仍然在Java 5 / EJB 3应用程序服务器上保持不变,您甚至可以在代码中进行错误修正,并在现代JDK上使用-target 1.3进行编译,而无需修复碰撞标识符(当然你也不能使用新的源级功能)。

This table shows several incompatibilities at the source (build-time) level between ejb 2.0, 2.1 and 3.0 versions, although binary (run-time) compatibility is supported for all releases, ie you can run your code on the new ejb versions without the need to recompile. 显示了ejb 2.0,2.1和3.0版本之间源(构建时)级别的几个不兼容性,尽管所有版本都支持二进制(运行时)兼容性,即您可以在新的ejb版本上运行代码而无需需要重新编译。

在此输入图像描述

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

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