-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
JDK9 blocker: stops supporting our scheme for MODULE$ initialization #1441
Comments
I have an idea how to fix this without breaking current behavior. |
@DarkDimius Is this what you had in mind? scala/scala@2.12.x...retronym:topic/module-init |
looks like it :+1 On 4 Aug 2016, at 12:13, Jason Zaugg wrote:
|
@retronym, there's one piece missing in your change. You need to move the body of constructor to the static initializer. Here's an example that demostrates the need: scala> class A { def foo = O.bar}; object O extends A {foo; def bar = println("bar")}
defined class A
defined object O
scala> O
bar
res1: O.type = O$@1593948d By the time user-defined body of constructor of objects starts execution, the |
From the bug report you linked, it looks like they want to enforce this check for older classfiles too:
Should someone comment on that bug report to let them know that doing this would break every existing Scala classfile? |
@smarter they are not enforcing this for old classfiles. I'm in contact with them. |
I believe that it's preferable to expose the null that to expose a partially initialised object. That's the status quo, no? |
@retronym current behavior publishes a partially initialized object that other classes can use(see the example above). If we prohibit this, it would mean that in the body of the object you cannot use anything that transitively uses the same object. I believe this is a very harsh restriction that is hard to maintain in big codebases. |
another example, that does not involve superclasses: scala> class CC { def foo = O.bar}; object O {new CC().foo; def bar = println(1)};
defined class CC
defined object O
scala> O
1
res7: O.type = O$@36ebc363 |
@smarter Is this issue still relevant, given |
Yes, the won't fix is about adding the check when the JVM load classfiles where the Java bytecode version corresponds to Java <= 8, but the issue remains for newer Java bytecode versions, we need to implement the same scheme that 2.13 has implemented: scala/scala#7270 |
This one depends on #9099 in order to construct trees. |
This is a port of the following PR from Scala 2: scala/scala#7270
This is a port of the following PR from Scala 2: scala/scala#7270
This is a port of the following PR from Scala 2: scala/scala#7270
This is a port of the following PR from Scala 2: scala/scala#7270
This is a port of the following PR from Scala 2: scala/scala#7270
This is a port of the following PR from Scala 2: scala/scala#7270
This is a port of the following PR from Scala 2: scala/scala#7270
This is a port of the following PR from Scala 2: scala/scala#7270
Fix #1441: init MODULE$ in <clinit>
https://bugs.openjdk.java.net/browse/JDK-8159215
the way we currently compile module classes, assigns the static final MODULE$ from the module class constructor
<init>
which is called by<clinit>
. This is prohibited by the spec and will be enforced by JDK9.If they enforce the restriction and we move the initializers to the only allowed place,
<clinit>
, following code will always throw NPE.Reported by Zoltán Majó. We have discussed the issue. The JDK product team seems have decided that this change is to stay. What it means, is that code compiled both by dotty and Scala cannot use bytecode version 53, unless we drop the
final
flag on allMODULE$
.PING @adriaanm, @lrytz, @retronym. I'll keep you informed on progress.
The text was updated successfully, but these errors were encountered: