-
Notifications
You must be signed in to change notification settings - Fork 14
make module init compliant with the jvm spec #194
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
Comments
Worth considering for 2.12.0 IMO. It will only blow up on Java 9, which we don't claim to support yet, but it would be good to at least have support for running code that we've compiled against JDK8 in JDK9. |
Agreed. |
@retronym see comment here scala/scala3#1441 (comment) that shows a counterexample to your solution and a possible fix. |
@DarkDimius Good catch. That is very subtle: we currently set the field after the module's super constructors are called but before the rest of the module's own constructor is called. Perhaps our safest bet for 2.12.x is to make the static In the future, should consider changing the |
Since this only blows up on bytecode version 53, which we won't generate for a while, I'd vote for doing nothing for 2.12. Removing the |
https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-5.html#jvms-5.5 The clinit method is called within an initialisation lock that takes care of publishing the field write to other threads |
But I wasn't aware of version 53, so agree this could be pushed back. |
I'm a little uneasy about punting on this because I couldn't find a public commitment to not close this loophole in old classfiles, but I'm more worried about breaking our initialization semantics on current Java. It's still not clear to me how doing a |
In our current state If you would call a module-class constructor using reflection, this would not be a safe publication, but this should be simply prohibited, ie constructor should check that current value of |
Ah, thanks for explaining! |
Details: scala/scala3#1441
Proposed fix: scala/scala@2.12.x...retronym:topic/module-init
The text was updated successfully, but these errors were encountered: