Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In compiled Scala, what is the bitmap$0 field?

Tags:

scala

I have noticed some of my Scala classes contain a field with the name bitmap$0 of type int. What is this?

like image 211
Landon Kuhn Avatar asked Jul 29 '11 17:07

Landon Kuhn


2 Answers

That's where the initialization states for lazy vals 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.

like image 161
Alex Cruise Avatar answered Nov 09 '22 11:11

Alex Cruise


When lazy vals are initialized, this field is also used for synchronization when the value is initialized.

like image 35
kender Avatar answered Nov 09 '22 11:11

kender