New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Re-initialization of transient lazy val not working after de-serialization #10244
Comments
Imported From: https://issues.scala-lang.org/browse/SI-10244?orig=1 |
Benjamin Hagemeister (behag) said: |
The issue here is that the fix in #10075 marked the actual member as transient, but any transient fields need to have their associated bitmap marked as transient as well. To properly fix this, |
@adriaanm any thoughts? It looks to me like the code is trying to do the right thing, but it is not realizing that these values need to use the transient bitmap. This has just become a supermassive headache for me, so I'd love it if there were a fix (or at least a diagnosis that could lead somebody to fix it themselves). |
Thanks for the analysis! I'll see if I can fix this in 2.12.3 |
@adriaanm in case it's helpful, this is the line that seems to be trying to correctly decide between the two bitmaps: https://github.com/scala/scala/blob/2.12.x/src/compiler/scala/tools/nsc/transform/AccessorSynthesis.scala#L134 I did notice that there's a bit of stripping and re-adding of annotations in #5570, and wondered if maybe the transient information isn't present when this is called, but that's about as far as I got in tracking this down. |
Yep, the logic operates on the getters (which don't have the |
/cc @patriknw, as this bug affected akka cluster, based on my bytecode diffing (see PR for details) |
Accessing a transient lazy val from a trait after an object was de-serialized causes a
NullPointerException
if the lazy val was accessed before the object was serialized.One can reproduce this problem with the following classes:
If you create an instance of
BaseImpl
, serialize and de-serialize this instance callingcheck
works without problems.If you create an instance, call
check
, serialize and de-serialize this instance calling check causes aNullPointerException
.The text was updated successfully, but these errors were encountered: