Skip to content
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

Export Java Symbols compiles, but fails at runtime with NoClassDefFoundError. #12249

Closed
agilesteel opened this issue Apr 28, 2021 · 2 comments
Closed
Assignees

Comments

@agilesteel
Copy link

Compiler version

3.0.0-RC3 (also fails in the earlier versions)

Minimized code

export java.util.UUID

println(UUID.randomUUID())

Output

[error] (run-main-0) java.lang.NoClassDefFoundError: java/util/UUID$
[error] java.lang.NoClassDefFoundError: java/util/UUID$
[error]         at dev.insideyou.delete3me.Main$package$.UUID(Main.scala:4)
[error]         at dev.insideyou.delete3me.Main$.<clinit>(Main.scala:9)
[error]         at dev.insideyou.delete3me.Main.main(Main.scala)
[error]         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[error]         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[error]         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[error]         at java.lang.reflect.Method.invoke(Method.java:498)
[error] Caused by: java.lang.ClassNotFoundException: java.util.UUID$
[error]         at java.net.URLClassLoader.findClass(URLClassLoader.java:382)

Expectation

I either expect it NOT to compile in the first place or even better actually work.

@bishabosha bishabosha self-assigned this Apr 28, 2021
@rtyley
Copy link

rtyley commented May 16, 2021

I wonder if this is related to scala/bug#12396, where I got a NoClassDefFoundError calling a method on a Java library from Scala 3 - reported there before realising that it seems that's only for Scala 2 bugs.

@agilesteel
Copy link
Author

I guess this "fixes" it, but any chance this could be improved in the future? It would be cool if all the static members were exported into a Scala UUID object as in:

export java.util.UUID

could be equivalent to:

type UUID = java.util.UUID
object UUID:
  inline def randomUUID(): UUID =
    java.util.UUID.randomUUID()
    
  // followed by other members

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants