In compiled Scala, what is the bitmap$0 field?
I 开发者_如何学JAVAhave noticed some of my Scala classes contain a field with the name bitmap$0
of type int
. What is this?
That's where the initialization states for lazy val
s are stored. When you access a lazy val
(or a nested object
, which is equivalent), the compiler uses the bitmap field to determine whether it's already been evaluated.
When lazy vals are initialized, this field is also used for synchronization when the value is initialized.
精彩评论