Upgrade to Pro — share decks privately, control downloads, hide ads and more …

JConf Peru 2024 - Systematically migrate to new...

JConf Peru 2024 - Systematically migrate to newer Java version: benefits, challenges and the future

Mihaela Gheorghe-Roman
Software Architect at Systematic

In this presentation, Mihaela will provide invaluable insights from a real application experience.

Join her in this session and embark on a journey for moving away from Java 8 in a very large monolith application: upgrading to a newer Java and to newer dependencies while also adopting a microservice architecture.

Migrating all Java modules without impacting the bussiness is challenging. However, recent Java versions have several language feature enhancements, security and performance improvements that will be beneficial for developers, stakeholders and end-users.

Find out the reasons that constituted the foundation of starting this journey, the advantages of this migration, what were the top challenges that appeared and how to overcome them!

Carlos Zela Bueno

December 09, 2024
Tweet

More Decks by Carlos Zela Bueno

Other Decks in Programming

Transcript

  1. Systematically migrate to newer Java version: benefits, challenges and the

    future © 2024 Systematic Mihaela Gheorghe-Roman, PhD. Software Architect
  2. Why upgrade? © 2024 Systematic Language-level enhancement Security fixes Extended

    APIs and Libraries Performance improvements Ability to update other infrastructure components
  3. Why upgrade? © 2024 Systematic WildFly 29 ▪ No longer

    compatible with JDK 8 ▪ Minimum required version JDK 11 Spring Framework 6 ▪ No longer compatible with JDK 8 ▪ Minimum required version is JDK 17
  4. Benefits: JDK 8 -> JDK 17 © 2024 Systematic Multi-release

    Jars (JEP238) ▪ simultaneously contain implementations compatible with different JDK versions
  5. Benefits: JDK 8 -> JDK 17 © 2024 Systematic Switch

    expression (JEP 361) ▪ A case expression can contain multiple values ▪ New restricted identifier yield to be used for code blocks ▪ Switch can be used on Enums ▪ Switch expressions must be exhausted
  6. Benefits: JDK 8 -> JDK 17 © 2024 Systematic Pattern

    matching for instanceof (JEP305, JEP394)
  7. Benefits: JDK 8 -> JDK 17 © 2024 Systematic Pattern

    matching for instanceof (JEP305, JEP394) ▪ tests the parameter and assigns it to a binding variable of the proper type
  8. Benefits: JDK 8 -> JDK 17 © 2024 Systematic Pattern

    matching for switch (JEP406) ▪ Flexibility when defining conditions for switch cases ▪ Type Pattern
  9. Benefits: JDK 8 -> JDK 17 © 2024 Systematic Pattern

    matching for switch (JEP406) ▪ Flexibility when defining conditions for switch cases ▪ Type Pattern ▪ Guarded Pattern
  10. Benefits: JDK 8 -> JDK 17 © 2024 Systematic Pattern

    matching for switch (JEP406) ▪ Flexibility when defining conditions for switch cases ▪ Type Pattern ▪ Guarded Pattern ▪ Parenthesis Pattern
  11. Benefits: JDK 8 -> JDK 17 © 2024 Systematic Text

    Blocks (JEP378) ▪ Multiline text ▪ HTML, SQL code ▪ License statements
  12. Benefits: JDK 8 -> JDK 17 © 2024 Systematic Text

    Blocks (JEP378) ▪ Multiline text ▪ HTML, SQL code ▪ License statements
  13. Benefits: JDK 8 -> JDK 17 © 2024 Systematic New

    API for Stream (JDK-8180352) ▪ Stream.toList() ▪ easier to convert a stream into a list ▪ returned list is unmodifiable
  14. Benefits: JDK 8 -> JDK 17 © 2024 Systematic New

    API for String (JEP326) ▪ indent() ▪ add or remove white spaces from the beginning of the line to adjust indentation for each string line
  15. Benefits: JDK 8 -> JDK 17 © 2024 Systematic New

    API for String (JEP326) ▪ transform() ▪ call a function on the given string
  16. Benefits: JDK 8 -> JDK 17 © 2024 Systematic New

    API for Arrays (JDK-8044082) ▪ mismatch() ▪ returns first mismatch between two arrays
  17. Benefits: JDK 8 -> JDK 17 © 2024 Systematic Local

    Variable Type Inference (JEP286) ▪ define a variable using var, without specifying the type ▪ compiler infers the type of the variable using the value provided
  18. Benefits: JDK 8 -> JDK 17 © 2024 Systematic Records

    (JEP395) ▪ Immutable ▪ Final ▪ Data holder classes ▪ Typed tuples ▪ Multiple return values ▪ DTOs (but not JPA entities!)
  19. Benefits: JDK 8 -> JDK 17 © 2024 Systematic Sealed

    classes and interfaces (JEP409) ▪ Fine-grained inheritance control ▪ Define permitted subtypes for classes and interfaces ▪ A class that extends a sealed class must have: ▪ Final: it cannot be sub-classed further ▪ Sealed: child classes need to be declared with permits ▪ Non-sealed: end the parent-child hierarchy
  20. Challenges © 2024 Systematic Nashorn removal in JDK 15 (JEP372)

    ▪ Collaborative Text Editor ▪ Implementation of ECMAScript which makes it hard to maintain ▪ Alternatives: GraalVM, Nashorn moved to OpenJDK
  21. Challenges © 2024 Systematic Lombok ▪ JEP 396: Strongly Encapsulate

    JDK Internals by Default ▪ Lombok can no longer use the JDK internals ▪ Update Lombok to version 1.8.22
  22. Challenges © 2024 Systematic Mockito ▪ Upgrade from 1.x to

    4.x ▪ Update and re-write of several unit tests ▪ Replace org.mockito.ArgumentMatchers anyVararg() with any() ▪ Replace org.mockito.ArgumentMatchers anyListOf(java.lang.Class) with anyList() ▪ Replace org.mockito.Mockito verifyZeroInteractions(..) with verifyNoInteractions() ▪ Reorder org.mockito.MockedStatic verify(Mode, Verification) with verify(Verification, Mode) ▪ Change type org.mockito.configuration.AnnotationEngine to org.mockito.plugins.AnnotationEngine ▪ Matcher anyInt() does not match long anymore, needs anyLong()
  23. Challenges © 2024 Systematic Java EE modules Java EE 8

    Jakarta EE Replacement Java Architecture for XML Binding (JAXB) Jakarta XML Binding JavaBeans Activation Framework (JAF) Jakarta Activation Java API for XML-Based Web Services (JAX-WS) Jakarta XML Web Services Java API for RESTful Web Services (JAX- RS) Jakarta RESTful Web Services
  24. Challenges © 2024 Systematic Deprecated language functionalities ▪ java.lang.Class.newInstance() –

    replaced with Class.getDeclaredConstructor().newInstance() ▪ Constructors of primitive wrapper classes (new Integer – replaced with Integer.valueOf(x) ▪ Locale constructors (replaced with Locale.of() or Locale.forLanguageTag() or Locale.Builder)
  25. Future © 2024 Systematic Java 21 ▪ Virtual threads ▪

    Sequenced collections ▪ Record patterns ▪ Structured concurrency (Preview) ▪ Scoped values (Preview) ▪ String templates (Preview) ▪ Unnamed Variables (Preview)
  26. Conclusions © 2024 Systematic Upgrade from Java 8 takes time

    Java 8 is unmaintained Performance improvements New features