Records Patterns, Performance and Serialization - JEP Café #8

Sdílet
Vložit
  • čas přidán 1. 08. 2024
  • This #JEPCafe discusses JEP 395: Records, released with JDK 16. We start with a short recap on what records are, then discuss the performances of the hash code computation with the `hashCode()` method, and the comparison of records using the `equals()` method. The performances are compared with the data objects offered by Kotlin and Lombok. We also cover record serialization and discuss patterns to serialize your legacy objects using records serialization (and get the security benefits of records serialization!).
    ⎯⎯⎯⎯⎯⎯ Chapters ⎯⎯⎯⎯⎯⎯
    0:00 Intro
    0:53 Carrying immutable state with records
    1:32 Writing a record with components
    2:47 Using constructors and accessors
    5:34 Examining the bytecode of the `equals()`, `hashCode()`, and `toString()` implementations
    7:12 Comparing the performances of `hashCode()` with Kotlin and Lombok
    8:02 Comparing the performances of `equals()` with Kotlin and Lombok
    10:20 Using Records as data transport objects
    11:47 Using `writeReplace()` to serialize records
    13:28 Using `readResolve()` to safely deserialize legacy objects
    15:04 Outro
    ⎯⎯⎯⎯⎯⎯ Resources ⎯⎯⎯⎯⎯⎯
    ◦ Dev.java ➱ dev.java/
    ◦ How to use JMH ➱ openjdk.java.net/projects/cod...
    ◦ JEP 395: Records ➱ openjdk.java.net/jeps/395
    ◦ The @Serial annotation ➱ docs.oracle.com/en/java/javas...
    ◦ JDK 17 ➱ openjdk.java.net/projects/jdk17
    ◦ OpenJDK ➱ openjdk.java.net/
    ◦ Oracle Java ➱ www.oracle.com/java/
    Categories: #Java #OpenJDK #JDK #JDK17 #Record #Serialization
  • Věda a technologie

Komentáře • 29

  • @cong0929
    @cong0929 Před 5 měsíci +1

    This is the very concise and easy-to-understandable explanation I've ever watched about Java Record.

  • @MakeItStik
    @MakeItStik Před 2 lety +6

    Hi Jose, please make a playlist on design patterns , design principles and how they are implemented in JDK. It would be really helpful for all of us. (in English) :)

  • @PabloSagoz
    @PabloSagoz Před 2 lety +11

    I’m really fan of records, pretty easy to work with them, excellent content, cheers ☕️

    • @JosePaumard
      @JosePaumard Před 2 lety +2

      Thanks, glad you liked it!

    • @Fider24
      @Fider24 Před 2 lety

      I am curios of using records for my DTOs but they have no setters. How do I handle my populator now if there are some fields I don't want to populate or are empty from the database?

  • @onebeartoe
    @onebeartoe Před 2 lety +4

    I like the format of this video!

  • @roxanamihaila4017
    @roxanamihaila4017 Před 2 lety

    Thank you Jose!! Always delightful to learn from you!!

  • @dd1.d
    @dd1.d Před 2 lety +1

    as always very useful and practical information. thank you

  • @ayanSaha13291
    @ayanSaha13291 Před rokem

    This was fantastic overview. Thanks a lot for the wonderful explanation.

  • @lukmanmudi5742
    @lukmanmudi5742 Před 2 lety +4

    Excellent talk as always. Thanks Jose 🤗

    • @java
      @java  Před 2 lety +2

      Glad you enjoyed it!

    • @JosePaumard
      @JosePaumard Před 2 lety +1

      Thanks!

    • @MakeItStik
      @MakeItStik Před 2 lety

      @@JosePaumard Hi Jose, please make a playlist on design patterns , design principles and how they are implemented in JDK. It would be really helpful for all of us. (in English) :)

  • @12345ms
    @12345ms Před 2 lety +1

    Excellent video, thank you so much for making and sharing this, @José Paumard

    • @java
      @java  Před 2 lety +1

      Glad you enjoyed it!

  • @rialpleya
    @rialpleya Před 2 lety

    What happpened to the section "Using records as data transfer objects"? It shows on the player bar regions, but it talks about serialization

  • @ameenasif
    @ameenasif Před 2 lety +1

    wow thia was the first time i saw a presentation time and content planned with sips of coffee , but its java so possible

  • @mustafailikkan7068
    @mustafailikkan7068 Před 2 lety +3

    Great video again, I love both JEP Cafe and Inside Java Newscast. By the way, where can we find those glass coffee cups for sale? I would definitely buy one.

  • @alexhali6003
    @alexhali6003 Před 2 lety +2

    Звук бы погромче. В остальном - отлично!
    The sound should be a little louder. The rest is excellent!

  • @Jankoekepannekoek
    @Jankoekepannekoek Před 2 lety +3

    0:42 why are Scala's case classes not mentioned? Scala has been around for longer than Kotlin.

    • @7starj
      @7starj Před 2 lety

      good question

  • @lgklein
    @lgklein Před 2 lety

    Just one, but the most important question.... Where the hell i buy this awesome mug?!!
    Your videos are excellent!

  • @beckerdo
    @beckerdo Před rokem

    Which earlier JEP Café talks about records? I like this video, but cannot find the earlier one.

    • @java
      @java  Před rokem +1

      We have a Playlist for that 😉
      czcams.com/play/PLX8CzqL3ArzV4BpOzLanxd4bZr46x5e87.html

    • @beckerdo
      @beckerdo Před rokem

      @@java Thank you. I see the first JEP 395 : Records discussion is a topic at the end of the first JEP Café #1.

  • @shanep2514
    @shanep2514 Před 2 lety +3

    I'm happy the use case for Lombok is going away. Lombok was never problem free.

  • @snitzer85
    @snitzer85 Před 2 lety

    old-fashioned

  • @pravinjain2834
    @pravinjain2834 Před 2 lety +2

    In the code at 4:48, the compareTo method needs to be replaced with
    @Override
    public int compareTo(Population other) {
    return Integer.compare(this.number, other.number);
    }