com-lihaoyi / os-lib

OS-Lib is a simple, flexible, high-performance Scala interface to common OS filesystem and subprocess APIs
Other
672 stars 63 forks source link

ExceptionInInitializerError from os.list on Java 17 but not Java 19 #242

Closed vreuter closed 8 months ago

vreuter commented 8 months ago

Hi, not sure if this is a known issue or if it's even helpful to raise here, so apologies in advance. I hit an issue recently, with version 0.9.2 of os-lib built on Scala 3.3.0 and running with a JAR with Java 17 in a Nix shell. My issue was similar to #24 ; the proximal and ultimate exceptions were similar in my case to that issue even if the context was a bit different.

The offending line looked like this:

Alternative[List].separate(os.list(folder).toList.filter(...).map(...))

and gave this error:

Exception in thread "main" java.lang.ExceptionInInitializerError
    at os.list$stream$$anon$1.generate(ListOps.scala:35)
    at geny.Generator.foreach(Generator.scala:51)
    at geny.Generator.foreach$(Generator.scala:33)
    at os.list$stream$$anon$1.foreach(ListOps.scala:31)
    at geny.Generator.toBuffer(Generator.scala:127)
    at geny.Generator.toBuffer$(Generator.scala:33)
    at os.list$stream$$anon$1.toBuffer(ListOps.scala:31)
    at geny.Generator.toArray(Generator.scala:131)
    at geny.Generator.toArray$(Generator.scala:33)
    at os.list$stream$$anon$1.toArray(ListOps.scala:31)
    at os.list$.apply(ListOps.scala:19)
    at os.list$.apply(ListOps.scala:23)
    ...
Caused by: java.lang.IllegalArgumentException: requirement failed: ? is not an absolute path
    at scala.Predef$.require(Predef.scala:337)
    at os.Path.<init>(Path.scala:488)
    at os.Path$.apply(Path.scala:414)
    at os.package$.<clinit>(package.scala:29)
    ... 19 more

Switching the Nix shell to Java 19 solved this problem, so I'm curious if this is something already known, and/or if it's perhaps possible to have a fix for Java 17? For my project it's fine to switch to Java 19 for now, I just worry if in the future I have a lower upper bound on version or if others do already, if a similar sticking point would arise.

Regardless, thanks a lot @lihaoyi for an excellent library :)

lefou commented 8 months ago

This is already fixed and will be released as 0.9.3.

vreuter commented 8 months ago

Thanks a lot @lefou !