Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
JavaにおけるNull非許容性
Search
Yuichi.Sakuraba
February 27, 2025
Technology
2
3.7k
JavaにおけるNull非許容性
2025.02.28 Server-Side Kotlin Meetup 発表資料
Yuichi.Sakuraba
February 27, 2025
Tweet
Share
More Decks by Yuichi.Sakuraba
See All by Yuichi.Sakuraba
Lazy Constant - finalフィールドの遅延初期化
skrb
0
1.3k
Language Update: Java
skrb
2
390
Java 30周年記念! Javaの30年をふりかえる
skrb
4
3.5k
あなたはJVMの気持ちを理解できるか?
skrb
5
29k
で、ValhallaのValue Classってどうなったの?
skrb
2
13k
Javaにおける関数型プログラミンへの取り組み
skrb
7
640
今こそ、ラムダ式を考える - なぜあなたはラムダ式を苦手と感じるのか
skrb
6
26k
今こそ、ラムダ式を考える - ラムダ式はどうやって動くのか
skrb
7
11k
Project Amberで変わる Javaのプログラミングスタイル
skrb
3
1.3k
Other Decks in Technology
See All in Technology
Strands AgentsとNova 2 SonicでS2Sを実践してみた
yama3133
1
1.9k
ESXi のAIOps だ!2025冬
unnowataru
0
390
New Relic 1 年生の振り返りと Cloud Cost Intelligence について #NRUG
play_inc
0
240
AI との良い付き合い方を僕らは誰も知らない
asei
0
270
普段使ってるClaude Skillsの紹介(by Notebooklm)
zerebom
8
2.3k
アラフォーおじさん、はじめてre:Inventに行く / A 40-Something Guy’s First re:Invent Adventure
kaminashi
0
160
テストセンター受験、オンライン受験、どっちなんだい?
yama3133
0
180
意外と知らない状態遷移テストの世界
nihonbuson
PRO
1
270
通勤手当申請チェックエージェント開発のリアル
whisaiyo
3
480
AI時代のワークフロー設計〜Durable Functions / Step Functions / Strands Agents を添えて〜
yakumo
3
2.3k
AgentCore BrowserとClaude Codeスキルを活用した 『初手AI』を実現する業務自動化AIエージェント基盤
ruzia
7
1.6k
Oracle Database@Google Cloud:サービス概要のご紹介
oracle4engineer
PRO
1
770
Featured
See All Featured
Taking LLMs out of the black box: A practical guide to human-in-the-loop distillation
inesmontani
PRO
3
2k
Highjacked: Video Game Concept Design
rkendrick25
PRO
0
250
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
122
21k
Effective software design: The role of men in debugging patriarchy in IT @ Voxxed Days AMS
baasie
0
170
sira's awesome portfolio website redesign presentation
elsirapls
0
91
Site-Speed That Sticks
csswizardry
13
1k
Mozcon NYC 2025: Stop Losing SEO Traffic
samtorres
0
98
Ethics towards AI in product and experience design
skipperchong
1
140
The Cult of Friendly URLs
andyhume
79
6.7k
Bridging the Design Gap: How Collaborative Modelling removes blockers to flow between stakeholders and teams @FastFlow conf
baasie
0
410
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
49
3.2k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
367
27k
Transcript
JavaにおけるNull非許容性 櫻庭 祐一
OpenJDK における新機能導入プロセス JEP: JDK Enhance Proposal Draft JEP 1st Preview
JEP n th Preview JEP Standard JEP 最低 2 回 差し戻しあり 本日のトピックは この段階 今後、 変更される可能性大
これまでの null に対する Java の取り組み null 参照型における 参照先がない状態 処理結果がない エラーなどを表す
本来の意味 副次的な意味 型アノテーション @NonNull List<@NonNull String> texts = ... Optional Optional<String> o = Optional.ofNullable(...); @NonNull が標準になっていないなど、 取り組みが成功しているとは言いがたい ...
Java の大きな流れ 重厚長大 長寿命 可変 オブジェクト 軽量 短寿命 不変 オブジェクト
ラムダ式 (Java 8) 処理とデータの分離 Record (Java 16) Sealed (Java 17) 代数的データ型 パターンマッチング (Java 16 ~ ) 型による処理の分岐 Value Class (Java ??) 値オブジェクト
Value Class 例) record Point(int x, int y) {} Point[]
Point x y Point x y Point x y Heap Point[] x y x y x y Heap value record Point(int x, int y) {} Value Class 化 ヒープ平坦化 参照をたどる必要なし オブジェクトヘッダーなし キャッシュミス低減
Value Class と Null 非許容型 Value Class によるヒープ平坦化 null があると余分なフラグやチェックが必要
最適化の効率が薄れる Null 非許容型の導入へ
Null 非許容型 / Null 許容型 JEP Draft: Null-Restricted Value Class
Types JEP Draft: Null-Restricted and Nullable Types https://openjdk.org/jeps/8316779 https://openjdk.org/jeps/8303099 String! Null 非許容型 (Null-Restricted Type) String? Null 許容型 (Nullable Type) ワイドニング変換 オブジェクト初期化順序の変更 配列初期化構文 ジェネリクス型パラメータへの適用 et al.
オブジェクト初期化順序の変更 class Foo { ... } class Bar extends Foo
{ Baz baz; Bar(Baz baz) { super(); this.baz = baz; } } スーパークラスのコンストラクタは 常にコンストラクタの先頭でコール このためフィールドが未初期化状態にある class Foo { ... } class Bar extends Foo { Baz baz; Bar(Baz baz) { this.baz = baz; super(); } } スーパークラスのコンストラクタを フィールド初期化後にコール可能
Conclusion 軽量不変オブジェクトへの流れ JVM 効率化としての Value Class と Null 非許容 Value
Class でなくても Null 非許容は使用可能 決まっていないことが多いが、 期待して待ちましょう