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
4k
2
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
JavaにおけるNull非許容性
2025.02.28 Server-Side Kotlin Meetup 発表資料
Yuichi.Sakuraba
February 27, 2025
More Decks by Yuichi.Sakuraba
See All by Yuichi.Sakuraba
Inside Stream API
skrb
1
890
Java 25に至る道
skrb
3
320
Lazy Constant - finalフィールドの遅延初期化
skrb
0
4.5k
Language Update: Java
skrb
2
500
Java 30周年記念! Javaの30年をふりかえる
skrb
4
3.9k
あなたはJVMの気持ちを理解できるか?
skrb
6
35k
で、ValhallaのValue Classってどうなったの?
skrb
2
16k
Javaにおける関数型プログラミンへの取り組み
skrb
7
740
今こそ、ラムダ式を考える - なぜあなたはラムダ式を苦手と感じるのか
skrb
6
28k
Other Decks in Technology
See All in Technology
Master Dataグループ紹介資料
sansan33
PRO
1
4.8k
【CEDEC2026】『ウマ娘 プリティーダービー』 英語版のキャラクターの方言や口調をローカライズするための創造的アプローチ
cygames
PRO
1
150
【CEDEC2026】専門性の高いデフォルメチームが挑んだ人材育成戦略 〜Cygames Academiaの企画から実施まで〜
cygames
PRO
0
120
【Google Cloud Next Tokyo'26】Gemini Enterprise と Oracle AI Database で実現する、業務データ活用を実現する AI エージェント実装
shisyu_gaku
0
190
認知負荷をGemini で溶かす — GKE 基盤「Orbit」における AI エージェントの実践
sansantech
PRO
1
220
システム監視入門
grimoh
5
810
検索技術知識0のエンジニアが広告検索システムを内製化して運用するまで
lycorptech_jp
PRO
0
210
AI ネイティブな組織に Gemini Enterprise Agent Platform がなぜ必要なのか
asei
1
160
AI驚き屋発見器
yama3133
2
400
今こそ聞きたいソフトウェア設計 ドメイン駆動設計再入門
masuda220
PRO
8
2.3k
新しい SLO が良い感じにハマっている話
z63d
4
2k
組織にどうSREを根付かせるか?〜IVRyの場合〜
abnoumaru
0
300
Featured
See All Featured
Google's AI Overviews - The New Search
badams
0
1.1k
How to Get Subject Matter Experts Bought In and Actively Contributing to SEO & PR Initiatives.
livdayseo
0
160
Measuring & Analyzing Core Web Vitals
bluesmoon
9
950
No one is an island. Learnings from fostering a developers community.
thoeni
21
3.8k
KATA
mclloyd
PRO
35
15k
Effective software design: The role of men in debugging patriarchy in IT @ Voxxed Days AMS
baasie
0
460
Applied NLP in the Age of Generative AI
inesmontani
PRO
4
2.4k
Docker and Python
trallard
47
4k
Building Experiences: Design Systems, User Experience, and Full Site Editing
marktimemedia
0
560
We Are The Robots
honzajavorek
0
290
Rails Girls Zürich Keynote
gr2m
96
14k
Java REST API Framework Comparison - PWX 2021
mraible
34
9.6k
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 非許容は使用可能 決まっていないことが多いが、 期待して待ちましょう