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
920
Java 25に至る道
skrb
3
320
Lazy Constant - finalフィールドの遅延初期化
skrb
0
4.9k
Language Update: Java
skrb
2
510
Java 30周年記念! Javaの30年をふりかえる
skrb
4
4k
あなたはJVMの気持ちを理解できるか?
skrb
6
35k
で、ValhallaのValue Classってどうなったの?
skrb
2
16k
Javaにおける関数型プログラミンへの取り組み
skrb
7
750
今こそ、ラムダ式を考える - なぜあなたはラムダ式を苦手と感じるのか
skrb
6
28k
Other Decks in Technology
See All in Technology
tamachi.go 誕生の裏側
rymiyamoto
1
200
FDEの心得
noriakioji
5
6.4k
トークンマネジメントでAIにとって働きやすい環境を実現する
hikaruegashira
0
130
【GCC2026】大規模言語モデルを活用した内製検索サービスの社内展開や業務活用
bandainamcostudios
PRO
0
390
英語が話せなくてもKubeConスタッフに参加した話
yusuke427
1
1.1k
AIで変わるエンジニアの働き方(仮)
naoinaoi
0
290
DatadogのBits Chatが開発組織にもたらしたもの / What Bits Chat Has Brought Us
sms_tech
1
290
平文パスワードはログに“残り” ── 肝心の侵入は“痕跡すら残らない”
kuroneko13
0
110
Kiro Crew入門 - 常駐エージェントの仕組みと使いどころ / Intro to Kiro Crew
k_adachi_01
1
700
【GCC2026】鉄拳8でのVFX開発事例
bandainamcostudios
PRO
0
160
【書籍出版記念】 10周回って、エージェント開発は RAGがすべてだった。〜RAGの歴史と開発現場で見えた実践知〜
akiratameto
9
2.1k
What's new in Go 1.27?
ciarana
0
290
Featured
See All Featured
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
508
140k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
666
130k
The Invisible Side of Design
smashingmag
301
52k
Leadership Guide Workshop - DevTernity 2021
reverentgeek
1
340
From Legacy to Launchpad: Building Startup-Ready Communities
dugsong
0
300
What Being in a Rock Band Can Teach Us About Real World SEO
427marketing
0
1.1k
Applied NLP in the Age of Generative AI
inesmontani
PRO
4
2.4k
AI Search: Where Are We & What Can We Do About It?
aleyda
0
7.8k
A better future with KSS
kneath
240
18k
For a Future-Friendly Web
brad_frost
183
10k
Stewardship and Sustainability of Urban and Community Forests
pwiseman
0
480
Building Better People: How to give real-time feedback that sticks.
wjessup
370
20k
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 非許容は使用可能 決まっていないことが多いが、 期待して待ちましょう