-
Notifications
You must be signed in to change notification settings - Fork 1.1k
scala_legacy crash caused by any jar in classpath with empty Class-Path: attribute #22461
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
TIL
I haven't tried shebang yet. I always resist starting a compilation server. It took so many years to deprecate fsc.
Worth noting that an empty attribute is not per spec:
https://docs.oracle.com/en/java/javase/23/docs/specs/jar/jar.html#class-path-attribute |
@snips - thanks for pointing out |
@som-snytt
A copy or symlink of the script with
Unfortunately, that's not a viable option, because the script is then treated by It also runs as expected if an explicit call to #!/usr/bin/env -S scala-cli run --server=false -S 3.6.3 --jvm 23 --classpath emptyClassPath.jar
LegacyBug.main(args)
object LegacyBug {
def main(args: Array[String]): Unit = {
printf("hello legacy!\n")
}
} However, the added call to The
|
@philwalk I'm aware that you do interesting scripting on Windows, which is not my niche; I'm on a Windows box but never leave WSL. FSR The shebang also WFM. I see Edit: there are different options for the distro scripts, so I didn't see Edit: the dotty build has changed at some point, so I don't even know how to test anything except scalaQ. |
It may well be a Windows-only problem. I didn't see it in Which jdk version should I be trying to test against? I'm seeing a few test failures with
The
|
jdk 17 is in CI, and for a recent PR, I switched to 17. I forgot to write: I agree that things should just work robustly. (Without caveats for systems or how it was run.) |
Just FYI, while this is a valid bug resulting in a crash, |
@Gedochao - I agree we shouldn't put much effort into legacy tools. My preferred migration path, if it were possible, would be to be able to treat a file with |
@philwalk I'm guessing that this part will stop being an issue after VirtusLab/scala-cli#3473 gets resolved (and we already have a fix in VirtusLab/scala-cli#3479, that's almost ready to merge at the time I'm writing this comment). Please raise issues in the Scala CLI tracker if you run into any further problems while migrating. |
Yes, this turned out better than I had hoped! |
I've rearranged the labels as this issue can be reproduced without the runners and it was just one of many possible reproductions |
Backport "Fix for scala#22461 Empty ClassPath attribute in one or more classpath jars causes crash" to 3.3 LTS
Compiler version
Minimized code
Can be reproduced by a jar with empty
Class-Path:
attribute.If the jar has an empty
Class-Path:
attribute in the MANIFEST, it crashes.If it has no
Class-Path:
attribute, or a non-emptyClass-Path:
attribute, no problem.Output
Expectation
Should not crash.
The following script verifies that scala3-3.3.1 has no problem with the jar file.
An empty string is a legal
classpath
entry, interpreted by thejvm
as the current working directory, although it might have been created by accident. The following entry inbuild.sbt
can produce a problem jar:Here's a script to create a problem jar named
emptyClassPath.jar
in the current directory:The text was updated successfully, but these errors were encountered: