Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is java byte-code always forward compatible?

I understand that the byte code generated by version JDK X is guaranteed to work on JVM Y, provided Y >= X.

Does this hold good for all versions of JDK/JVM? i.e Is it fair to expect class files generated by JDK 1 to work on JVM 11?

Referred to JVM specs, JDK 8 compatibility guide and Java 11 JSR Could not find a precise answer there.

like image 846
Sarvesh Avatar asked Mar 23 '18 08:03

Sarvesh


Video Answer


1 Answers

The bytecode itself should work in future versions. Until now this holds true but nobody knows if this will be true for all future.

What changes, and can break your program, are changes in the API. Deprecated APIs may vanish in the future and then your program will not work anymore and may throw a java.lang.NoSuchMethodError when referencing such a method.

like image 116
Uwe Plonus Avatar answered Sep 18 '22 12:09

Uwe Plonus