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
840
Java 25に至る道
skrb
3
310
Lazy Constant - finalフィールドの遅延初期化
skrb
0
4.3k
Language Update: Java
skrb
2
480
Java 30周年記念! Javaの30年をふりかえる
skrb
4
3.9k
あなたはJVMの気持ちを理解できるか?
skrb
6
34k
で、ValhallaのValue Classってどうなったの?
skrb
2
16k
Javaにおける関数型プログラミンへの取り組み
skrb
7
730
今こそ、ラムダ式を考える - なぜあなたはラムダ式を苦手と感じるのか
skrb
6
28k
Other Decks in Technology
See All in Technology
攻撃者がいなくてもAIエージェントはインシデントを起こす
nomizone
0
210
最適な自走を最小限の支援で — M&Aで拡大する組織で少人数SREが挑んだ1年 / SRE NEXT 2026
genda
0
710
依頼文化をやめる日 EM視点で語るPlatform EngineeringとInclusive SRE / Discussing Platform Engineering and Inclusive SRE from an EM's Perspective
shin1988
4
4.8k
最近評価が難しくなった
maroon8021
0
260
GuardrailからGovernanceへ~AIエージェント運用の次の課題~
sbspsy
1
240
CSに"SLO"は要らない、経営層に"99.9%"は伝わらない - SREを全社に"翻訳"する3原則
cscengineer
PRO
1
4.1k
Baseline対応のDOMの型定義を作った
uhyo
3
720
Road to SRE NEXTの今までとこれから
hiroyaonoe
0
260
テスト設計の本質を改めて考えてみる~生成AIを活用する時代だからこそ、作ったテストの説明性を高めよう~
yamasaki696
1
410
環境凍結という Toil を倒す -セルフサービス型 Ephemeral テスト環境の 設計と実践
shirouz
1
1.9k
Claude Codeとハーネスについて考えてみる
oikon48
18
9k
オブザーバビリティ、本当に活用できてる? 〜API連携×生成AIで成熟度を自動評価〜
dmmsre
1
2.5k
Featured
See All Featured
Designing for Performance
lara
611
70k
The Language of Interfaces
destraynor
162
27k
Have SEOs Ruined the Internet? - User Awareness of SEO in 2025
akashhashmi
0
390
How People are Using Generative and Agentic AI to Supercharge Their Products, Projects, Services and Value Streams Today
helenjbeal
1
230
Measuring Dark Social's Impact On Conversion and Attribution
stephenakadiri
2
230
How to build an LLM SEO readiness audit: a practical framework
nmsamuel
1
800
Ten Tips & Tricks for a 🌱 transition
stuffmc
0
150
A Soul's Torment
seathinner
6
3k
The Anti-SEO Checklist Checklist. Pubcon Cyber Week
ryanjones
0
180
Reflections from 52 weeks, 52 projects
jeffersonlam
356
21k
Un-Boring Meetings
codingconduct
0
340
Site-Speed That Sticks
csswizardry
13
1.2k
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 非許容は使用可能 決まっていないことが多いが、 期待して待ちましょう