JEP 502 introduces the StableValue api (previously known as ComputableConstant). The api can be used to create constants with delayed (at-most-once) initialisation. The unique selling point of this api is that the JIT will trust the values for constant folding. At a glance, this api seems like the perfect compilation target for Scala’s lazy vals. I can imagine two benefits over the current compilation strategy: Simpler generated code; the whole ‘checking whether a lazy value is already in...