Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does Spring Version 4.3.20 work with Java 11? [duplicate]

I am confused when it comes to the supported java-versions of spring 4.3.20. Updating a Spring 4.3.20 project to Java 11 worked without any hiccups what so ever. All my tests work fine, the webapp starts up and all the features of Spring that require bytecode-magic like @Cacheable work. How is this even possible? From what I understand I should have to update to Spring 5+. I checked the language level in my maven settings and bytecode version of the generated .class-files and they indeed use major version: 55.

What am I missing?

I build with Java 11 and launch my local tomcat with Java 11. I double checked all my settings and used visualvm to verify that tomcat indeed runs with Java 11.

Heres the output of javap:

enter image description here

like image 224
roookeee Avatar asked Mar 04 '23 12:03

roookeee


2 Answers

Spring 5.1 supports Java 11, earlier versions do not. See Spring Framework Versions:

JDK Version Range

  • Spring Framework 5.1.x: JDK 8-12
  • Spring Framework 5.0.x: JDK 8-10
  • Spring Framework 4.3.x: JDK 6-8

and What's New in Spring Framework 5.x:

What's New in Version 5.1

General Core Revision

  • Infrastructure:
    • Warning-free support for JDK 11 on the classpath and the module path.

That 4.3.x works on Java 11 might just mean that you have been lucky up to now (not using things that are not compatible with Java 11). Also, Java is pretty good in backwards compatibility, even with the things removed or intentional backwards incompatible changes since Java 9, it is entirely possible that the real broken things in Spring are very small and obscure.

That said, I would not use a set of libraries as vast as Spring with Java 11 if the authors say that Java compatibility is only guaranteed in a later version than you use. If you want to use Spring with Java 11, upgrade to Spring 5.1.

like image 99
Mark Rotteveel Avatar answered Mar 14 '23 21:03

Mark Rotteveel


Remember: tests can only prove the presence of bugs, not their absence.

According to some comments on their release blog, 4.3.20 is in deed "not compatible" with Java 11.

On the other hand: spring is a huge framework. So the simple answer might be: it works for, as long as you don't run into areas that will not work.

And keep in mind: any JDK of version N can run bytecode for bytecode that has older versions N-x.

like image 34
GhostCat Avatar answered Mar 14 '23 19:03

GhostCat