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

Java 15について軽く/ Java 15 breaf introduction

Naoki Kishida
September 18, 2020

Java 15について軽く/ Java 15 breaf introduction

2020/9/18に開催されたJavaコミュ@福岡オンライン飲み会での登壇資料です

Naoki Kishida

September 18, 2020
Tweet

More Decks by Naoki Kishida

Other Decks in Programming

Transcript

  1. Java 15 • 2020/9/15リリース • non-LTS • 次は17(Sept.2021) • 14のJEP

    • 新規は4つ • 更新6 • 機能削除4 http://openjdk.java.net/projects/jdk/15/ 新規 新規 新規 新規
  2. JEP • 言語仕様 • Sealed Classes(Preview) • Text Blocks(Standard) •

    Pattern Matching for instanceof (Second Preview) • Records(Second Prevew) • API • Foreign Memory Access (Second Incubator) • Hidden Classes • Reinplement the Legacy DatagramSocket API • Edwards-Curve Digital Signature Algorithm • Remove the Nashorn JS Engine • JVM • Disable and Deprecate Biased Locking • ZGC(Production) • Shenandoah(Production) • Deprecate RMI Activation • OpenJDK • Remove Solaris and SPARK Ports • Tool • remove RMI stub compiler
  3. 現状では使い道なし • 本当は次のように書けるといい String getName(Shape s) { if (s instanceof

    Circle) { return "円"; } else if (s instanceof Rectangle) { return "四角"; } else if (s instanceof Square) { return "正方形"; } }
  4. 定義 public record Rec(String name, int count) {} public class

    Rec extends Record { private final String name; private final int count; Rec(String name, int count) { this.name = name; this.count = count; } String name() { return name; } String count() { return count; } // toString, equals, hashCode }
  5. Pattern Matching for instanceof(2nd Preview) • Kotlinのスマートキャストのような機能 Object o =

    "test"; if (o instanceof String s) { System.out.println(s.length()); } Object o = "test"; if (o instanceof String) { String s = (String) o; System.out.println(s.length()); }