1

We are migrating our projects to Java 17 from Java 8. Each one of those projects uses plenty of library / starters belonging to the same organization built with Java 8.

I know Java is backward-compatible, but is there any gain from building those library also in Java 17 (i.e. performance, memory usage)?

In other words, using a library compiled with a Java x-1 in a project executed on JVM belonging to Java x does it affect the project performance?

Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197
Katy
  • 1,023
  • 7
  • 19
  • 1
    I don't think performance would be the issue. Deprecated packages (e.g., javax) would be a bigger problem. You won't be able to compile without revising the JDK8 code. – duffymo Jun 08 '22 at 14:13
  • @duffymo thanks for your reply. All dependencies were revised. We don't use deprecated code (such as RMI etc.) We have very tiny upgrade of the the spring-boot version and spring cloud and several maven plugin (surefire, failsafe etc..). That's all. But yeah I agree upgrading needs revising. – Katy Jun 08 '22 at 14:18
  • 4
    Any improvements in performance and memory that are part of the JDK17 upgrade would accrue to your recompiled libraries. The only way to know how code affects performance is profiling it and seeing where the time is being spent. You should be doing that regardless of JDK version you use. – duffymo Jun 08 '22 at 14:20
  • 5
    There are some limited potential performance benefits. For example, there have been some optimizations to string concatenation (e.g. [JDK-8076758](https://bugs.openjdk.org/browse/JDK-8076758)) which you won't get without recompiling. Almost certainly not worth worrying about, but it's not nothing. Most performance optimizations exist within the runtime - Java's bytecode remains relatively close to the source - so you'll get them regardless of which bytecode version classes are compiled to target. – Michael Jun 08 '22 at 14:22
  • Fair enough Thanks @Mickael ! – Katy Jun 08 '22 at 14:27
  • 3
    More about String concatenation already mentioned by @Michael in this video, [String Concatenation - JEP Café #7, Delegating concatenation to some other code](https://www.youtube.com/watch?v=w56RUzBLaRE&list=PLX8CzqL3ArzV4BpOzLanxd4bZr46x5e87&index=4&t=295s) – usuario Jun 08 '22 at 14:33
  • 3
    Also inner classes/ nested classes do not need synthetic helper methods for accessing private members of the outer class or vice versa. This may reduce code size and in some rare cases even improve performance. – Holger Jun 08 '22 at 18:52

0 Answers0