-
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
Bad symbolic reference. A signature refers to JFunction1$mcZI$sp/T in package scala.runtime.java8 which is not available. #15562
Comments
@topazus do you consistently get this error when you run it in a fresh REPL session? I can recall getting similar errors in REPL but that has never been something I managed to reproduce later. |
@prolativ Yes, I got the error for plenty of times in the past few days. |
But does this happen always for this snippet val r=Iterator.from(20).takeWhile(_<69)
val r=Iterator.from(20).takeWhile(_<69).foreach(println) or just often but not 100% deterministically? scala-cli repl -S 3.1.3 --jvm 18 -O -deprecation Does the error occur also in this case? |
the above screenshot occured the error. Is this error caused by my operation of recreating immutable variable `val` with same name, or java environment variable?
ok, I will try this. |
use scala-cli, after evaluating several sample code, the same error still occured. detailed output, exactly copied from terminal, error in the very end
|
Digging deeper into that: does the problem occur if you don't use your globally installed Java version but rather force scala-cli to pull it for you or if you use an older version of JDK? E.g. if you use |
Same issue:
I restarted the repl and previously erroring code worked. Strange that it happens at all, certainly baffling, particularly for newcomers. |
I encountered the same error message when running the following code from the Scala 3 Book: val nums = List(1,2,3)
nums.filter(_ > 1) installation details: Ubuntu 22.04 on WSL (Windows 11), with Scala version 3.2.0 (installed with The odd thing is that after I followed the suggestion in this thread (running Please explain the root of the error, and why the "magical" command solved the issue |
And for people who were using WSL, did you install the JVM inside WSL or did you use the Windows version of the JVM? |
Linux (Fedora 35 at the time most likely). FWIW, the error hasn't cropped up again in any REPL session since -- now on scala 3.2.2-RC1/Java 19. |
Re-post as comment over here (Already mentioned in this thread). Scala code runner version 3.2.1 -- Copyright 2002-2022, LAMP/EPFLThe following error appears randomly[1], so I am not sure you actually will be able to reproduce it. Minimized codescala> val arreglo: Array[Int] = Array(1, 2, 3, 4, 3, 2, 1)
scala> arreglo.sortWith(_ < _)
scala> val (sorted1: Array[Int], sorted2: Array[Int]) = arreglo.sortWith(_ < _).splitAt(arreglo.length / 2) OutputBad symbolic reference. A signature
refers to JFunction2$mcZII$sp/T in package scala.runtime.java8 which is not available.
It may be completely missing from the current classpath, or the version on
the classpath might be incompatible with the version used when compiling the signature.
1 error found ExpectationNo error should be happening. Underlying System Info.The Scala REPL is running on top of Java 17 over a Windows Subsystem for Linux 2 (WSL2) installation. Welcome to Scala 3.2.1 (17.0.5, Java Java HotSpot(TM) 64-Bit Server VM).
Thanks. |
After hitting this bug I am able to reproduce it with java 8, 11, 17 and 20 and with scala 3.0.0 and 3.3.0 (using scala-cli 1.0.1). All installed with sdkman. This is in Ubuntu 22.04. It seem this bug is tied up to the REPL autocomplete somehow. To trigger it I evaluate the following expression:
But don't simply copy paste and execute it. I can trigger the bug by autocompleting the |
FWIW, I can confirm that this works as a way to reproduce this bug on macOS as well:
|
That's an excellent catch. Current plain REPL, completing as instructed:
|
It's reproducible for me as well using the tab-completion trick. And in my experience it fails every time — I tried it about 10 times in a row just now, 100% failure rate. (MacOS, JDK 17, Scala 3.3.0 and 3.4.0-RC1-bin-20230810-c90ad6b-NIGHTLY) Doesn't matter whether I launch with scala-cli or with the bundled A good next step an interested volunteer could take would be to try to turn it into a failing test case. |
OK, I finally managed to reproduce the issue myself too. To me it looks like the problem is somehow connected with the fact that the class loader used by the REPL is evaluated lazily, after the REPL gets its input for the first time. E.g. evaluating scala> println() before trying the completion based reproduction from above makes the problem not occur. |
A small rectification: |
Hello, I just got this same error in the Scala REPL with the example code from the Tour of Scala: val salaries = Seq(20_000, 70_000, 40_000)
val newSalaries = salaries.map(_ * 2) I'm on Windows 11. C:\Users\###>cs java --installed
adopt:1.8.0-292 installed at C:\Users\olega\AppData\Local\Coursier\cache\arc\https\github.com\AdoptOpenJDK\openjdk8-binaries\releases\download\jdk8u292-b10\OpenJDK8U-jdk_x64_windows_hotspot_8u292b10.zip\jdk8u292-b10
C:\Users\###>java -version
openjdk version "1.8.0_292"
OpenJDK Runtime Environment (AdoptOpenJDK)(build 1.8.0_292-b10)
OpenJDK 64-Bit Server VM (AdoptOpenJDK)(build 25.292-b10, mixed mode)
C:\Users\###>scala --version
Scala code runner version 3.3.0 -- Copyright 2002-2023, LAMP/EPFL I tried opening a fresh scala REPL and typed in the same commands, and the error didn't occur. Weird. |
Since the issue is visible on REPL, this is significantly impacting the developer experience. Can you please prioritize this? |
I can't reproduce this any what way...
@SethTisue Can you provide more detailed reproducible steps? |
@dwijnand try 3.3.x — I am still able to reproduce this every time on 3.3.2, but I'm not able to make it happen at all on 3.4.0 This is using Alfonso's repro steps: #15562 (comment) Note that the error doesn't occur after you hit tab — it happens after you complete all the steps fully, twice: type (or paste) up to |
I tried (several times) with:
and haven't been able to reproduce yet. I am on a MacBook Intel.
|
I could replicate a few times by doing these steps as suggested above: scala --jvm 18 -S 3.3.1 -deprecation
Welcome to Scala 3.3.1 (18.0.2, Java OpenJDK 64-Bit Server VM).
Type in expressions for evaluation. Or try :help.
scala> List(1, 2).filter(_ % 2 == 0).foreach(println)
2
scala> List(1, 2).filter(_ % 2 == 0).foreach(println)
Bad symbolic reference. A signature
refers to JFunction1$mcZI$sp/T in package scala.runtime.java8 which is not available.
It may be completely missing from the current classpath, or the version on
the classpath might be incompatible with the version used when compiling the signature.
1 error found
scala> make sure to paste its nondeterministic how many times to enter these steps in a single repl session |
(as I was also just saying on another ticket) it's not clear whether it's worth the effort to try to pinpoint which PR is responsible, or whether we should just wait until the next big wave of backports lands, and then test 3.3.x again to see if the problem went away. most fixes are being backported so that's grounds for optimism |
I can reproduce the issue with 3.3.1 (LTS), but not 3.4 inside a docker container docker pull openjdk
docker run -i -t openjdk /bin/bash
curl -fL https://github.com/coursier/coursier/releases/latest/download/cs-x86_64-pc-linux.gz | gzip -d > cs && chmod +x cs && ./cs setup
cd ~/.local/share/coursier/bin/ With scala-3.4 bash-4.4# scala
Welcome to Scala 3.4.0 (18.0.2.1, Java OpenJDK 64-Bit Server VM).
Type in expressions for evaluation. Or try :help.
scala> List(1, 2).filter(_ % 2 == 0).foreach(println)
2
scala> List(1, 2).filter(_ % 2 == 0).foreach(println)
2
scala> With scala-3.3.1
|
If it helps, this fails for me with Scala 3.3.1 and Java 11 on macOS 14.3 when I follow what @bishabosha wrote about pasting the code in:
|
So this doesn't crash in 3.4.x+ because of #19113. The sequence of events is this:
Asides from backporting #19113, so that we avoid forcing the tab completion message, which forces the import suggestions, which forces the erasure symbol to lose its lastDenot (i.e. the "avoid touching it so it doesn't break" approach) I'm not sure what the proper fix in or around Symbol#computeDenot and SingleDenotation#current should be... |
With that backport, i.e. even in 3.4.x, this fails: scala> List(1, 2).filter(_ % 2 == 0).foreach(println)
2
scala> val x = false + true; List(1, 2).filter(_ % 2 == 0).fore<TAB>ach(println)
-- [E008] Not Found Error: -----------------------------------------------------
1 |val x = false + true; List(1, 2).filter(_ % 2 == 0).foreach(println)
| ^^^^^^^
|value + is not a member of Boolean, but could be made available as an extension method.
|
|One of the following imports might make progress towards fixing the problem:
|
| import scala.math.Fractional.Implicits.infixFractionalOps
| import scala.math.Integral.Implicits.infixIntegralOps
| import scala.math.Numeric.Implicits.infixNumericOps
|
1 error found
scala> List(1, 2).filter(_ % 2 == 0).foreach(println)
Bad symbolic reference. A signature
refers to JFunction1$mcZI$sp/T in package scala.runtime.java8 which is not available.
It may be completely missing from the current classpath, or the version on
the classpath might be incompatible with the version used when compiling the signature.
1 error found |
@dwijnand Thanks for the insightful analysis. This looks like a really tough one.
What are the precise reasons for not updating back? Maybe we can find a way to change that? |
So, by Run 4, we lookup via Perhaps we need to find a place to call Symbol#drop or #dropAfter (or ClassDenotation#delete or Scope#unlink) when we encounter this truncated phases situation? Perhaps that would lead to |
I am still very unsure how to fix this.
Is there a way Or maybe we can have a special mode for import suggestions that does not destroy denotations? Nothing looks easy. It's a highly constrained system, and we did not anticipate this particular case. |
Reported again today at https://www.reddit.com/r/scala/comments/1az9hli/scala_installation_on_ubuntu_2204/ |
Compiler version
scala 3.1.3
If you're not sure what version you're using, run
print scalaVersion
from sbt(if you're running scalac manually, use
scalac -version
instead).Output
Sometimes, I run some example codes like the previous screenshot code. but in other times, it works fine.
Expectation
The text was updated successfully, but these errors were encountered: