-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Enum (extends java) => null in java, when scala looks at it before java #12637
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
Here's another variant of the same problem:
Output:
|
Any word on this? Any chance we can get this mentioned in the Enum docs? |
The problem also occurs if |
It seems that initializing classes in a specific order causes Here is the bytecode of
If
The execution of
Therefore, During the execution of On the other hand, if |
It also looks like the same problem occurred in #16391 . |
Confirm, this still exists in Scala 3.3.6. |
Uh oh!
There was an error while loading. Please reload this page.
Compiler version
Scala 3.0.0, OpenJDK 15.0.2, sbt 1.5.2,
Minimized code
TestenumS.scala
TestenumJ.java
Output
Expectation
It works as expected (Hello) only when line 3 is commented, i.e. when java sees the enum before scala.
As it compiles ok, so the null propagates to cause runtime errors elsewhere, it can takes a long time to find the cause
(especially when it looks ok called from scala)
The text was updated successfully, but these errors were encountered: