Who am I • Senior Serverside Engineer at LINE Corporation • Leader of HBase team for LINE Messenger Backend • Contributed to Java 8, 9 • Project Lambda Contributor • Project Kulla (jshell) Committer • JJUG Board member • Recent work • Modernize Java version for HBase/Hadoop • From Java 8 to Java 17 with new HBase/Hadoop version • Evaluate ZGC for HBase
440: Record Patterns 441: Pattern Matching for switch OK NG どこに書けるか • instanceof expr • Switch condition • Variable definition • Variable in for loop • Method definition どんな構造をdeconstructできるか • Type • Record • Object content • Primitive Type • Array • Collection • j.u.Optional どんな条件でmatchingできるか • Type • Record • Object content • Primitive Type • Enum value • Collections
440: Record Patterns 441: Pattern Matching for switch sealed interface Maybe permits Just, Nothing {} record Just(T value) implements Maybe {} record Nothing() implements Maybe {} Maybe> maybe = ...; switch (maybe) { case Just j -> // Pattern for Type in switch cond. String.valueOf(j.value()); case Nothing n -> "Nothing"; // Pattern for Type in switch cond. }
440: Record Patterns 441: Pattern Matching for switch sealed interface Maybe permits Just, Nothing {} record Just(T value) implements Maybe {} record Nothing() implements Maybe {} Maybe> maybe = ...; switch (maybe) { case Just(var s) -> // Pattern for Record in switch cond. String.valueOf(s); case Nothing() -> "Nothing"; // Pattern for Record in switch cond. }
440: Record Patterns 441: Pattern Matching for switch sealed interface Maybe permits Just, Nothing {} record Just(T value) implements Maybe {} record Nothing() implements Maybe {} Maybe> maybe = ...; switch (maybe) { case Just(var s) when s == null -> throw new NullPointerException(); case Just(var s) -> String.valueOf(s); case Nothing n -> "Nothing"; // Pattern for Type in switch cond. case null -> "null" }
440: Record Patterns 441: Pattern Matching for switch sealed interface Maybe permits Just, Nothing {} record Just(T value) implements Maybe {} record Nothing() implements Maybe {} Maybe> maybe = ...; switch (maybe) { // Pattern for Record matching Type in switch cond. case Just(String s) -> "String"; case Just(Integer n) -> "Integer"; case Just j -> "Other"; // Pattern for Type in switch cond. case Nothing n -> "Nothing"; // Pattern for Type in switch cond. }
440: Record Patterns 441: Pattern Matching for switch enum Action { SHRINK, EXPAND } Maybe action = ...; size += switch (action) { case Just(SHRINK) -> -10; // NG, cannot match with Enum value case Just(EXPAND) -> 10; // NG, cannot match with Enum value case Nothing() -> 0; }
440: Record Patterns 441: Pattern Matching for switch enum Action { SHRINK, EXPAND } Maybe action = ...; size += switch (action) { case Just(var a) when a == Action.SHRINK -> -10; case Just(var a) when a == Action.EXPAND -> 10; case Just j -> throw new ISE("Added new enum value to Action"); case Nothing() -> 0; }
451: Prepare to Disallow the Dynamic Loading of Agents • Attach APIを使ってJava Agentを動的にロードすると警告 • 将来的にはデフォルトでは禁止に • --javaagentで静的にロード:OK • 動的にロードする場合:-XX:+EnableDynamicAgentLoading • Java AgentをロードしないAttachAPIを使用するツール:影響を受けない • jcmd • jconsole • ... WARNING: A {Java,JVM TI} agent has been loaded dynamically (file:/u/bob/agent.jar) WARNING: If a serviceability tool is in use, please run with -XX:+EnableDynamicAgentLoading to hide this warning WARNING: If a serviceability tool is not in use, please run with -Djdk.instrument.traceUsage for more information WARNING: Dynamic loading of agents will be disallowed by default in a future release
449: Deprecate the Windows 32-bit x86 Port for Removal • Windows 10 • 32 bit arch.をサポートする最後のWindows • 2025/10/14サポート終了予定 • Windows 32-bit x86向けのJDKのサポートを将来終了するための準備
IO Event handler thread validate validate validate Application thread unpack response unpack response unpack response Application thread IO Event handler loop DB request + callback Run callback DB request + callback Run callback DB request + callback Run callback DB DB DB validate DB request + callback DB unpack response
Thread 2 Thread 3 validate DB access unpack response validate DB access Virtual Thread Thread 1 Java Thread = OS Thread Carrier Thread DB access 3s validate DB done? or yield() validate DB done? or yield() unpack response unpack response validate DB access unpack response validate DB done? or yield() DB done? or yield() unpack response unpack response
Platform ThreadとVirtual Thread CPU 1 CPU 2 CPU 3 CPU 4 Platform Thread Platform Thread Platform Thread Platform Thread OS OS Thread OS Thread OS Thread OS Thread Java Runtime Java application Carrier Threads ForkJoinPool Virtual Thread Virtual Thread