Is Java bytecode compatible with different versions of Java?

前端 未结 3 1730
粉色の甜心
粉色の甜心 2021-01-21 08:30

If I compile an application using Java 5 code into bytecode, are the resulting .class files going to be able to run under Java 1.4?

If the latter can wo

3条回答
  •  失恋的感觉
    2021-01-21 09:26

    No they are not. .class files are forward compatible only.

    Java5 framework implies that your library is probably using generics or annotations that are incompatible with your 1.4 environment. You have to evaluate how much risk there is for you to run your 1.4 application under a 1.5 JVM to enable use of the frameworks you require.

    In general I've found moving to 1.5 to be mostly painless, but diligent testing is called-for.

提交回复
热议问题