Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
JEP 526: Lazy Constants
Search
Aya Ebata
March 24, 2026
Technology
75
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
JEP 526: Lazy Constants
2026/03/24 JJUGナイトセミナー「Java 26 リリース記念イベント」
Aya Ebata
March 24, 2026
More Decks by Aya Ebata
See All by Aya Ebata
Flutterハンズオン 5
aya_ebata
0
110
JEP 480: Structured Concurrency
aya_ebata
0
300
Flutterハンズオン 4
aya_ebata
0
180
Flutterハンズオン 3
aya_ebata
0
110
Flutterハンズオン 2
aya_ebata
0
120
Flutterハンズオン 1
aya_ebata
0
150
あたらしい もじれつの かきかた
aya_ebata
0
150
社内勉強会vol.3@ごーふぁー荘
aya_ebata
0
810
社内勉強会vol.2@ごーふぁー荘
aya_ebata
1
820
Other Decks in Technology
See All in Technology
AIに賢く動いてもらうためのコンテキスト〜Snowflake女子会 vol.8
snowwmn0824
0
160
【技術的負債conf】事業成長に伴う技術的負債の説明責任とAIによるモニタリング、認知的負債について
i35_267
3
2k
What the customer really needed
kawaguti
PRO
3
220
ADKで始める業務改善 - AIエージェント開発時の考えと設計
harappa80
2
260
リアーキテクチャ後の障害ゼロを目指したShadow Testingの取り組み
nihonbuson
PRO
1
170
エージェントはローカル、検証はMicroVM — Lambda MicroVMsでつくるServerless CI
fujioka6789
3
680
その Lambda、8分で 管理者権限まで奪われます
k1nakayama
7
3.5k
AIエージェントの一手は 誰も見ていない - Falco拡張OSS「Prempti」とeBPFで サーバーレス実行基盤を二層防御する
keitah
0
480
株式会社シーエーシー エンジニア向け会社紹介資料
cac
0
57k
SREは、MCPとAutopilotをこう使え!
kazumax55
3
950
2026_devsumi_ozono.pdf
o3
3
560
顧客に向き合う開発組織へ。リアーキテクチャとフィーチャーチーム化で挑む組織改革
safie
0
2.3k
Featured
See All Featured
StorybookのUI Testing Handbookを読んだ
zakiyama
31
6.9k
How STYLIGHT went responsive
nonsquared
100
6.3k
Visual Storytelling: How to be a Superhuman Communicator
reverentgeek
2
670
Principles of Awesome APIs and How to Build Them.
keavy
128
18k
技術選定の審美眼(2025年版) / Understanding the Spiral of Technologies 2025 edition
twada
PRO
120
120k
A better future with KSS
kneath
240
18k
Dominate Local Search Results - an insider guide to GBP, reviews, and Local SEO
greggifford
PRO
0
340
Design in an AI World
tapps
1
330
The #1 spot is gone: here's how to win anyway
tamaranovitovic
4
1.2k
The Invisible Side of Design
smashingmag
301
52k
Technical Leadership for Architectural Decision Making
baasie
3
580
Git: the NoSQL Database
bkeepers
PRO
432
67k
Transcript
JEP 526: Lazy Constants (Second Preview) 2026/03/24 JJUGナイトセミナー Java 26リリース記念イベント
えばた あや @aya_122
自己紹介 - 名前: えばた あや - 𝕏: @aya_122 - 好き:
ラーメン二郎 / いくら / ポケモン / たまごっち - お仕事: フリーランス - Flutter / Python / Go / React
今日話すこと JEP 526: Lazy Constants (Second Preview) https://openjdk.org/jeps/526
Lazy Constantsとは - 遅延して初期化をするためのAPI - 初期化のタイミングが柔軟になる - 変更不可能な値として使用できる - finalとして宣言した場合と同じパフォーマンスが可能になる
- プレビュー版
目的 - アプリケーションの状態を必要な時に初期化可能にする - アプリケーションの起動時間が短縮する - パフォーマンスを下げずに、遅延定数の生成と初期化を切り離す - マルチスレッドでも最大1回の初期化を保証する
今までのfinal - logger は OrderController のインスタンス作成時に初期化される - 処理によっては初期化に時間がかかる可能性がある - 他の
Controller からも同時に初期化される class OrderController { private final Logger logger = Logger.create(OrderController.class); ... }
今までの書き方で遅延初期化 class OrderController { private Logger logger = null; Logger
getLogger() { if (logger == null) { logger = Logger.create(OrderController.class); } return logger; } ... }
今までの書き方で遅延初期化 欠点 - getLogger() を経由しないと NullPointerException が発生する - マルチスレッドの場合、複数回 Logger.create()
が実行される可能性が ある - logger が絶対に変化しないと言い切れないので、最適化されない
Lazy constantsの書き方 - java.lang.LazyConstant にあるファクトリメソッドの of を使用する - 一度初期化すると変更不可能になる class
OrderController { private final LazyConstant<Logger> logger = LazyConstant.of(() -> Logger.create(OrderController.class)); ... }
Lazy constantsの書き方 - logger.get() を呼び出した時に logger が初期化されていなかったら LazyConstant.of() で指定した内容で初期化する class
OrderController { ... void submitOrder(User user, List<Product> products) { logger.get().info("order started"); ... logger.get().info("order submitted"); } }
Lazy constantsの書き方 - アプリケーション全体を通して初期化方法を再考することが可能になる - 例) 各 Controller の初期化など class
Application { static final LazyConstant<OrderController> ORDERS = LazyConstant.of(OrderController::new); public static OrderController orders() { return ORDERS.get(); } }
コレクションのLazy constants - List.ofLazy() - 例) プールサイズ分だけリストを用意して、必要になった時に 遅延初期化をする - Map.ofLazy()
- 例) スレッド名に紐付くマップを用意して、必要になった時に 遅延初期化をする
まとめ - LazyConstant.of() と get() を使用して書いていく - 初期化を遅延できる - アプリケーションの起動時間が短縮できる