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

Java 9 to 15 - A brief overview of changes to the language

Java 9 to 15 - A brief overview of changes to the language

Presentation with some of the changes that happened to the Java language after Java 8

1d2a6c7cfa9e96ecffe3c10a5018b1b8?s=128

Rodrigo Graciano

December 05, 2020
Tweet

Transcript

  1. @rodrigograciano Java 9 to Java 15: A brief review of

    recent changes to the language Rodrigo Graciano speakerdeck.com/graciano
  2. @rodrigograciano Did you know? uJava 8 released in March 2014

    u85% still uses 8 or older version * uAnyone using Java 9+ in PROD? u https://www.jetbrains.com/lp/devecosystem-2020/java/
  3. @rodrigograciano Release Schedule 8

  4. @rodrigograciano About me u Professional with 10+ years u Principal

    Software Engineer - NY u NYJavaSIG Leader u graciano.dev u Twitter: @rodrigograciano
  5. @rodrigograciano What we’ll see today? Main changes after Java 8

    Not all? 7 versions – Java 15 – September 2020 100+ JEP’s on Java 9 alone
  6. @rodrigograciano Java 9 9 September 2017 Initially scheduled to September

    2016 - delayed 3 years after Java 8 Huge number of changes – 100+
  7. @rodrigograciano Jigsaw - JPMS u Scheduled to Java 7 u

    11 Java Enhancement Proposals (JEP’s) u Aims to reduce packages size u Split the JDK in parts – Modules u More control over packages u Eliminates the “Jar Hell” u Main module (Root) is java.base u It’s Java – 100% backwards compatible 9
  8. @rodrigograciano Garbage First Collector - G1 u Default choice starting

    at Java 9 u Substitute Concurrent Mark Swap (CMS) – Stop the world u Smaller pause time u Memory is split in regions - 1-32MB u Goal is to have 2048 regions (Heap) 9
  9. @rodrigograciano Collections – Factory Methods u Reduce the “boilerplate” u

    Return Immutable collections u List<Integer> numbers = List.of(1,2,3); u Set<String> cities = Set.of(”New York City", ”Boston”); u Map<String, Integer> m2 = Map.ofEntries( Map.entry("A",1), Map.entry("B",2) ); 9
  10. @rodrigograciano JShell 9 u Easy to use u Useful to

    teach Java language u Read-Eval-Print-Loop
  11. @rodrigograciano Outros u Interfaces can now have private methods (static

    and non-static) u Reactive Streams API u Improvements to Optional, try-with resources, streams and Javadoc (HTML 5) u HTTP2 9
  12. @rodrigograciano Java 10 10 March 2018 First release using the

    new release cadency – Every 6 months Feature Release – It’s not LTS 12 JEP’s
  13. @rodrigograciano Local Variable Type Inference (var) u var is a

    variable type u Cannot be a class attribute u No relation with var/val from Scala/Kotlin u String name = “Rodrigo”; u var name = “Rodrigo”; u var myMap = new HashMap(); //Map<Object, Object>() u Must be initialized – var age; //Not valid u var var = “var”; 10
  14. @rodrigograciano Others u Experimental JIT Compiler – Graal Ahead-of-Time (AOT)

    u Parallel G1 GC to improve full GC performance u AppCDS to improve start-up time u New API’s to create collections u List.copyOf(), Set.copyOf(), and Map.copyOf() u Stream API can collect data in an immutable collection u toUnmodifiableList(), toUnmodifiableSet(), and toUnmodifiableMap() 10
  15. @rodrigograciano Java 11 11 September 2018 LTS – Next LTS

    will be Java 17 Java EE -> Jakarta EE Java EE source code was separated from the repository
  16. @rodrigograciano GC’s u Epsilon GC – no-op collector. Perfect for

    benchmarking u Z GC – Experimental low-latency uWorks with all sizes of heaps – From small to Terabytes uPause time must not exceed 10ms 11
  17. @rodrigograciano Outros 11 u Flight Recorder u Single file source

    code programs
  18. @rodrigograciano Java 12 12 March 2019 Feature Release Preview Features

    Small Release - 8 JEP's
  19. @rodrigograciano Switch Expressions 12

  20. @rodrigograciano Others u Shenandoah GC – Constant pause time -

    Experimental u Microbenchmark Suite - based on JMH u Default CDS Archives – Enhance JDK process to generate a CDS archive u Enhance to G1. Automatically return Java heap memory to the operating system when idle 12
  21. @rodrigograciano Java 13 13 September 2019 Feature Release Preview Features

    Just 5 JEP's
  22. @rodrigograciano Text Blocks 13 u Before Text Blocks u With

    Text Blocks
  23. @rodrigograciano Others u Switch Expression – 2nd preview u Improvements

    to ZGC u Dynamic CDS archives u Reimplement the Legacy Socket API 13
  24. @rodrigograciano Java 14 14 March 2020 Feature Release Preview and

    Final Features 16 JEP's
  25. @rodrigograciano Records 14

  26. @rodrigograciano Records (2) u Immutable u Reduce the boilerplate 14

  27. @rodrigograciano Records (3) 14

  28. @rodrigograciano Helpful NPE u Clearer NPE messages u Possible to

    know which object is null list.get(0).getName().trim(); u Where’s the null object? The list? Name? Cannot invoke "String.trim()" because the return value of "dev.graciano.Pessoa.getName()" is null 14
  29. @rodrigograciano Pattern Matching for instanceOf u Don’t need to explicitly

    cast after the instanceOf if (p instanceOf People people) { people.getName(); } 14
  30. @rodrigograciano Others u JFR Streaming u Switch Expression – Final

    version u Text Blocks – 2nd Preview u ZGC on Windows and MacOS u Remove Concurrent Market Sweep GC (CMS) 14
  31. @rodrigograciano Java 15 15 September 2020 Feature Release Preview and

    Final Features 14 JEP's
  32. @rodrigograciano Sealed Classes u Permits to control who can extends/implements

    a classe/interface public abstract sealed class Shape permits Circle, Square, Triangle {…} 15
  33. @rodrigograciano Others u ZGC and Shenandoah not experimental anymore u

    Text Blocks not a Preview Feature u Hidden classes u 2nd Preview of Records u 2nd Preview of Pattern Matching for instanceOf 15
  34. @rodrigograciano Java 16 16 March 2021 Feature Release 16 JEPS’s

    confirmadas – so far 1 JEP’s planned – so far
  35. @rodrigograciano What’s new? 16 u OpenJDK migrated from Mercurial to

    Git (GitHub) u Enhance the ZGC u Vector API u Final version of Records u Final version of Pattern Matching for instanceOf
  36. @rodrigograciano More from Java 10/11 import java.nio.charset.*; public class Unicode

    { public static void main(String... args) { System.out.print(”Have a \uD83C\uDF7A"); System.out.println(" or a \uD83E\uDD64 "); } } 10/11 Slide extracted from https://speakerdeck.com/boyarsky
  37. @rodrigograciano End ugraciano.dev uTwitter: @rodrigograciano