Constants in Amber
summary
Adds a new constant pool entry, ConstantDynamic (tag 17), that lets a bootstrap method return any constant so ldc or bootstrap static args can represent values previously impossible (int.class, enums, method handles, vhandles, etc.); implements a special bootstrap arity-two lazy resolution mode to defer resolution until use; enhances javac with compiler intrinsics for ldc/invokedynamic and a "constable"/trackable-constant API and annotation so expressions fold into constant pool entries. Prototype lives in the Amber repo and is implemented end-to-end, but needs careful immutability and security checks.
AI-written summary · about
chapters (19)
- 0:00Intro
- 0:52Goals
- 1:53Runtime code
- 2:34What can reference constant values?
- 7:25What about?
- 8:21Just use static final fields?
- 12:12Bootstrap method invocation
- 14:03New signature forms of bootstrap methods
- 15:23Invocation with BootstrapCallInfo
- 16:08Constraints
- 18:30Typed bootstrap methods?
- 20:37Runtime and language code
- 21:06Motivation
- 28:49More work for the compiler
- 30:50Exposing LDC
- 32:41Exposing indy
- 35:15Indy in the source code!!
- 37:48Right, but what about code generation?
- 38:49Summary
related talks
38mBelow the Fold, Adventures in Constancy
41mCONSTANT_Dynamic
01h 00mAmber, Loom, Valhalla
43mHow Amber is Driving Java’s Evolution
01h 00mJava Language Futures - All Aboard Project Amber
26mJava Language Futures
01h 02mJava Project Amber - Not Just a Rare Fossil
47mJava Next - From Amber to Loom, from Panama to Valhalla
