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

error while loading .class file in nightly scalac #20361

Open
timothyklim opened this issue May 8, 2024 · 12 comments
Open

error while loading .class file in nightly scalac #20361

timothyklim opened this issue May 8, 2024 · 12 comments
Assignees
Labels
compat:java itype:bug regression This worked in a previous version but doesn't anymore

Comments

@timothyklim
Copy link

Compiler version

Problem started from 3.5.0-RC1-bin-20240501-e6bc130-NIGHTLY version and still present in latest nightly build. As a workaround I'm using 3.5.0-RC1-bin-20240429-e2c456f-NIGHTLY version.

Minimized code

[Error] error while loading ArrayBlockingQueueWithShutdown$Itr,
[Error]   class file org/jitsi/utils/concurrent/ArrayBlockingQueueWithShutdown$Itr.class is broken (version 52.0),
[Error]   please check the JDK compatibility of your Scala version (3.5.0-RC1-bin-20240501-e6bc130-NIGHTLY),
[Error]   reading aborted with class java.util.NoSuchElementException:
[Error]   key not found: E
[Error] error while loading PacketQueue$HandlerAdapter,
[Error]   class file org/jitsi/utils/queue/PacketQueue$HandlerAdapter.class is broken (version 52.0),
[Error]   please check the JDK compatibility of your Scala version (3.5.0-RC1-bin-20240501-e6bc130-NIGHTLY),
[Error]   reading aborted with class java.util.NoSuchElementException:
[Error]   key not found: T
[Error] error while loading ResettableLazy$lazyHolder$1,
[Error]   class file org/jitsi/utils/ResettableLazy$lazyHolder$1.class is broken (version 61.0),
[Error]   please check the JDK compatibility of your Scala version (3.5.0-RC1-bin-20240501-e6bc130-NIGHTLY),
[Error]   reading aborted with class java.util.NoSuchElementException:
[Error]   key not found: T
[Error] error while loading DelegatesKt$observableWhenChanged$$inlined$observableWhenChanged$1,
[Error]   class file org/jitsi/utils/DelegatesKt$observableWhenChanged$$inlined$observableWhenChanged$1.class is broken (version 61.0),
[Error]   please check the JDK compatibility of your Scala version (3.5.0-RC1-bin-20240501-e6bc130-NIGHTLY),
[Error]   reading aborted with class java.util.NoSuchElementException:
[Error]   key not found: T
[Error] error while loading DelegatesKt$observableWhenChanged$$inlined$observable$1,
[Error]   class file org/jitsi/utils/DelegatesKt$observableWhenChanged$$inlined$observable$1.class is broken (version 61.0),
[Error]   please check the JDK compatibility of your Scala version (3.5.0-RC1-bin-20240501-e6bc130-NIGHTLY),
[Error]   reading aborted with class java.util.NoSuchElementException:
[Error]   key not found: T
[Error] error while loading ResettableLazy$reset$1,
[Error]   class file org/jitsi/utils/ResettableLazy$reset$1.class is broken (version 61.0),
[Error]   please check the JDK compatibility of your Scala version (3.5.0-RC1-bin-20240501-e6bc130-NIGHTLY),
[Error]   reading aborted with class java.util.NoSuchElementException:
[Error]   key not found: T
@timothyklim timothyklim added itype:bug stat:needs triage Every issue needs to have an "area" and "itype" label labels May 8, 2024
@Gedochao Gedochao added stat:needs info stat:needs minimization Needs a self contained minimization regression This worked in a previous version but doesn't anymore compat:java and removed stat:needs triage Every issue needs to have an "area" and "itype" label labels May 9, 2024
@Gedochao
Copy link

Gedochao commented May 9, 2024

@timothyklim can you provide a minimization? Just the error output isn't enough to go on here.
I'm guessing this is somehow reproducible with jitsi-utils?

@timothyklim
Copy link
Author

3.5.0-RC1-bin-20240429-e2c456f-NIGHTLY

Yes, please: https://github.com/timothyklim/scala3-issue-20361

@Gedochao
Copy link

We'll still need a minimization without dependencies (without depending on jitsi-utils).

Still, @timothyklim the reproduction you sent seems to include a custom jitsi-utils JAR, rather than the most recent version from maven (seems to be https://mvnrepository.com/artifact/org.jitsi/jitsi-utils/1.0-130-g1473517).
I can't seem to reproduce this with the version from maven.

The following seems to work correctly:

//> using scala 3.5.0-RC1-bin-20240501-e6bc130-NIGHTLY
//> using dep org.jitsi:jitsi-utils:1.0-130-g1473517
import org.jitsi.utils.*

@main def run(): Unit = println("test")

Any context for what you're using? It's hard to investigate with what's there.

@Gedochao
Copy link

Bonus question: what JVM is this supposed to be run on?

@timothyklim
Copy link
Author

I'm using my custom JDK 22 but tested with JDK 19 (19.0.2) from nixpkgs: nix run nixpkgs/release-23.11#sbt

@Gedochao
Copy link

What about jitsi-utils? what is the version that's being used in the repro repository?

@timothyklim

This comment was marked as outdated.

@timothyklim

This comment was marked as outdated.

@timothyklim
Copy link
Author

I pushed new commit with official version from maven: timothyklim/scala3-issue-20361@bd2d6d6 there no bazel, no custom patches, no jar in lib/, but the same error.

@timothyklim
Copy link
Author

If I remove scalac option -experimental then everything works but in my project I cannot remove this option because I'm using many experimental features from nightly such as saferExceptions

@timothyklim
Copy link
Author

We'll still need a minimization without dependencies (without depending on jitsi-utils).

Still, @timothyklim the reproduction you sent seems to include a custom jitsi-utils JAR, rather than the most recent version from maven (seems to be https://mvnrepository.com/artifact/org.jitsi/jitsi-utils/1.0-130-g1473517). I can't seem to reproduce this with the version from maven.

The following seems to work correctly:

//> using scala 3.5.0-RC1-bin-20240501-e6bc130-NIGHTLY
//> using dep org.jitsi:jitsi-utils:1.0-130-g1473517
import org.jitsi.utils.*

@main def run(): Unit = println("test")

Any context for what you're using? It's hard to investigate with what's there.

Did you pass -experimental flag to scala?

@Gedochao
Copy link

Did you pass -experimental flag to scala?

Yes.
Interesting. I can't replicate with Scala CLI, but I can with SBT.

This works:

//> using scala 3.5.0-RC1-bin-20240501-e6bc130-NIGHTLY
//> using dep org.jitsi:jitsi-utils:1.0-130-g1473517
//> using options -experimental

import org.jitsi.utils.*

@main def run(): Unit = println("test")

But with SBT, the same doesn't.
repro.scala:

import org.jitsi.utils.*

@main def run(): Unit = println("test")

build.sbt:

scalaVersion := "3.5.0-RC1-bin-20240501-e6bc130-NIGHTLY"
scalacOptions ++= Seq("-experimental")
libraryDependencies += "org.jitsi" % "jitsi-utils" % "1.0-130-g1473517"

output:

sbt:dest> run
[info] compiling 1 Scala source to /Users/pchabelski/IdeaProjects/scala-cli-tests/compiler-repro/dest/target/scala-3.5.0-RC1-bin-20240501-e6bc130-NIGHTLY/classes ...
exception caught when loading class module-info: java.lang.AssertionError: assertion failed: attempt to parse java.lang.Object from classfile
error while transforming package <empty> {
  final lazy module val repro$package: repro$package = new repro$package()
  final module class repro$package() extends Object() {
    this: repro$package.type =>
    @main def run(): Unit = println("test")
  }
  final class run() extends Object() {
    <static> def main(args: Array[String]): Unit =
      try run() catch 
        {
          case error @ _:scala.util.CommandLineParser.ParseError =>
            scala.util.CommandLineParser.showError(error)
        }
  }
}

  unhandled exception while running posttyper on /Users/pchabelski/IdeaProjects/scala-cli-tests/compiler-repro/dest/src/main/scala/repro.scala

  An unhandled exception was thrown in the compiler.
  Please file a crash report here:
  https://github.com/scala/scala3/issues/new/choose
  For non-enriched exceptions, compile with -Yno-enrich-error-messages.

     while compiling: /Users/pchabelski/IdeaProjects/scala-cli-tests/compiler-repro/dest/src/main/scala/repro.scala
        during phase: posttyper
                mode: Mode(ImplicitsEnabled)
     library version: version 2.13.12
    compiler version: version 3.5.0-RC1-bin-20240501-e6bc130-NIGHTLY-git-e6bc130
            settings: -bootclasspath /Users/pchabelski/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/scala-lang/scala3-library_3/3.5.0-RC1-bin-20240501-e6bc130-NIGHTLY/scala3-library_3-3.5.0-RC1-bin-20240501-e6bc130-NIGHTLY.jar:/Users/pchabelski/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/scala-lang/scala-library/2.13.12/scala-library-2.13.12.jar -classpath /Users/pchabelski/IdeaProjects/scala-cli-tests/compiler-repro/dest/target/scala-3.5.0-RC1-bin-20240501-e6bc130-NIGHTLY/classes:/Users/pchabelski/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/jitsi/jitsi-utils/1.0-130-g1473517/jitsi-utils-1.0-130-g1473517.jar:/Users/pchabelski/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/com/googlecode/json-simple/json-simple/1.1.1/json-simple-1.1.1.jar:/Users/pchabelski/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/net/java/dev/jna/jna/5.9.0/jna-5.9.0.jar:/Users/pchabelski/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/jetbrains/kotlin/kotlin-stdlib/1.9.10/kotlin-stdlib-1.9.10.jar:/Users/pchabelski/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/jetbrains/kotlin/kotlin-reflect/1.9.10/kotlin-reflect-1.9.10.jar:/Users/pchabelski/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/jetbrains/kotlin/kotlin-stdlib-common/1.9.10/kotlin-stdlib-common-1.9.10.jar:/Users/pchabelski/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/jetbrains/annotations/13.0/annotations-13.0.jar -d /Users/pchabelski/IdeaProjects/scala-cli-tests/compiler-repro/dest/target/scala-3.5.0-RC1-bin-20240501-e6bc130-NIGHTLY/classes -experimental true

[error] ## Exception when compiling 1 sources to /Users/pchabelski/IdeaProjects/scala-cli-tests/compiler-repro/dest/target/scala-3.5.0-RC1-bin-20240501-e6bc130-NIGHTLY/classes
[error] java.lang.AssertionError: assertion failed: attempt to parse java.lang.Object from classfile
[error] scala.runtime.Scala3RunTime$.assertFailed(Scala3RunTime.scala:8)
[error] dotty.tools.dotc.core.classfile.ClassfileParser$AbstractConstantPool.getSuperClass(ClassfileParser.scala:175)
[error] dotty.tools.dotc.core.classfile.ClassfileParser.parseParents$1(ClassfileParser.scala:380)
[error] dotty.tools.dotc.core.classfile.ClassfileParser.parseClass(ClassfileParser.scala:395)
[error] dotty.tools.dotc.core.classfile.ClassfileParser.$anonfun$1(ClassfileParser.scala:302)
[error] dotty.tools.dotc.core.classfile.ClassfileParser.run(ClassfileParser.scala:297)
[error] dotty.tools.dotc.core.ClassfileLoader.doComplete(SymbolLoaders.scala:417)
[error] dotty.tools.dotc.core.SymbolLoader.complete(SymbolLoaders.scala:348)
[error] dotty.tools.dotc.core.SymDenotations$SymDenotation.completeFrom(SymDenotations.scala:175)
[error] dotty.tools.dotc.core.Denotations$Denotation.completeInfo$1(Denotations.scala:190)
[error] dotty.tools.dotc.core.Denotations$Denotation.info(Denotations.scala:192)
[error] dotty.tools.dotc.core.SymDenotations$SymDenotation.ensureCompleted(SymDenotations.scala:393)
[error] dotty.tools.dotc.core.SymDenotations$SymDenotation.annotations(SymDenotations.scala:231)
[error] dotty.tools.dotc.core.SymDenotations$SymDenotation.hasAnnotation(SymDenotations.scala:245)
[error] dotty.tools.dotc.core.SymUtils.isExperimental(SymUtils.scala:364)
[error] dotty.tools.dotc.typer.Checking$.isNonExperimentalTopLevelDefinition$1(Checking.scala:809)
[error] dotty.tools.dotc.typer.Checking$.nonExperimentalTopLevelDefs$1$$anonfun$1(Checking.scala:817)
[error] scala.collection.Iterator$$anon$10.nextCur(Iterator.scala:594)
[error] scala.collection.Iterator$$anon$10.hasNext(Iterator.scala:608)
[error] scala.collection.IterableOnceOps.foreach(IterableOnce.scala:576)
[error] scala.collection.IterableOnceOps.foreach$(IterableOnce.scala:574)
[error] scala.collection.AbstractIterator.foreach(Iterator.scala:1300)
[error] dotty.tools.dotc.typer.Checking$.markTopLevelDefsAsExperimental$1(Checking.scala:837)
[error] dotty.tools.dotc.typer.Checking$.checkAndAdaptExperimentalImports(Checking.scala:845)
[error] dotty.tools.dotc.transform.PostTyper$PostTyperTransformer.transformStats(PostTyper.scala:548)
[error] dotty.tools.dotc.ast.tpd$TreeMapWithPreciseStatContexts.transformStats(tpd.scala:1242)
[error] dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1613)
[error] dotty.tools.dotc.transform.MacroTransform$Transformer.transform(MacroTransform.scala:42)
[error] dotty.tools.dotc.transform.PostTyper$PostTyperTransformer.transform(PostTyper.scala:539)
[error] dotty.tools.dotc.transform.MacroTransform.run(MacroTransform.scala:20)
[error] dotty.tools.dotc.core.Phases$Phase.runOn$$anonfun$1(Phases.scala:380)
[error] scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
[error] scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
[error] scala.collection.immutable.List.foreach(List.scala:333)
[error] dotty.tools.dotc.core.Phases$Phase.runOn(Phases.scala:373)
[error] dotty.tools.dotc.Run.runPhases$1$$anonfun$1(Run.scala:343)
[error] scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
[error] scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
[error] scala.collection.ArrayOps$.foreach$extension(ArrayOps.scala:1323)
[error] dotty.tools.dotc.Run.runPhases$1(Run.scala:336)
[error] dotty.tools.dotc.Run.compileUnits$$anonfun$1(Run.scala:384)
[error] dotty.tools.dotc.Run.compileUnits$$anonfun$adapted$1(Run.scala:396)
[error] dotty.tools.dotc.util.Stats$.maybeMonitored(Stats.scala:69)
[error] dotty.tools.dotc.Run.compileUnits(Run.scala:396)
[error] dotty.tools.dotc.Run.compileSources(Run.scala:282)
[error] dotty.tools.dotc.Run.compile(Run.scala:267)
[error] dotty.tools.dotc.Driver.doCompile(Driver.scala:37)
[error] dotty.tools.xsbt.CompilerBridgeDriver.run(CompilerBridgeDriver.java:141)
[error] dotty.tools.xsbt.CompilerBridge.run(CompilerBridge.java:22)
[error] sbt.internal.inc.AnalyzingCompiler.compile(AnalyzingCompiler.scala:91)
[error] sbt.internal.inc.MixedAnalyzingCompiler.$anonfun$compile$7(MixedAnalyzingCompiler.scala:193)
[error] scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:23)
[error] sbt.internal.inc.MixedAnalyzingCompiler.timed(MixedAnalyzingCompiler.scala:248)
[error] sbt.internal.inc.MixedAnalyzingCompiler.$anonfun$compile$4(MixedAnalyzingCompiler.scala:183)
[error] sbt.internal.inc.MixedAnalyzingCompiler.$anonfun$compile$4$adapted(MixedAnalyzingCompiler.scala:163)
[error] sbt.internal.inc.JarUtils$.withPreviousJar(JarUtils.scala:239)
[error] sbt.internal.inc.MixedAnalyzingCompiler.compileScala$1(MixedAnalyzingCompiler.scala:163)
[error] sbt.internal.inc.MixedAnalyzingCompiler.compile(MixedAnalyzingCompiler.scala:211)
[error] sbt.internal.inc.IncrementalCompilerImpl.$anonfun$compileInternal$1(IncrementalCompilerImpl.scala:534)
[error] sbt.internal.inc.IncrementalCompilerImpl.$anonfun$compileInternal$1$adapted(IncrementalCompilerImpl.scala:534)
[error] sbt.internal.inc.Incremental$.$anonfun$apply$5(Incremental.scala:180)
[error] sbt.internal.inc.Incremental$.$anonfun$apply$5$adapted(Incremental.scala:178)
[error] sbt.internal.inc.Incremental$$anon$2.run(Incremental.scala:464)
[error] sbt.internal.inc.IncrementalCommon$CycleState.next(IncrementalCommon.scala:116)
[error] sbt.internal.inc.IncrementalCommon$$anon$1.next(IncrementalCommon.scala:56)
[error] sbt.internal.inc.IncrementalCommon$$anon$1.next(IncrementalCommon.scala:52)
[error] sbt.internal.inc.IncrementalCommon.cycle(IncrementalCommon.scala:263)
[error] sbt.internal.inc.Incremental$.$anonfun$incrementalCompile$8(Incremental.scala:419)
[error] sbt.internal.inc.Incremental$.withClassfileManager(Incremental.scala:506)
[error] sbt.internal.inc.Incremental$.incrementalCompile(Incremental.scala:406)
[error] sbt.internal.inc.Incremental$.apply(Incremental.scala:172)
[error] sbt.internal.inc.IncrementalCompilerImpl.compileInternal(IncrementalCompilerImpl.scala:534)
[error] sbt.internal.inc.IncrementalCompilerImpl.$anonfun$compileIncrementally$1(IncrementalCompilerImpl.scala:488)
[error] sbt.internal.inc.IncrementalCompilerImpl.handleCompilationError(IncrementalCompilerImpl.scala:332)
[error] sbt.internal.inc.IncrementalCompilerImpl.compileIncrementally(IncrementalCompilerImpl.scala:425)
[error] sbt.internal.inc.IncrementalCompilerImpl.compile(IncrementalCompilerImpl.scala:137)
[error] sbt.Defaults$.compileIncrementalTaskImpl(Defaults.scala:2371)
[error] sbt.Defaults$.$anonfun$compileIncrementalTask$2(Defaults.scala:2321)
[error] sbt.internal.server.BspCompileTask$.$anonfun$compute$1(BspCompileTask.scala:31)
[error] sbt.internal.io.Retry$.apply(Retry.scala:47)
[error] sbt.internal.io.Retry$.apply(Retry.scala:29)
[error] sbt.internal.io.Retry$.apply(Retry.scala:24)
[error] sbt.internal.server.BspCompileTask$.compute(BspCompileTask.scala:31)
[error] sbt.Defaults$.$anonfun$compileIncrementalTask$1(Defaults.scala:2319)
[error] scala.Function1.$anonfun$compose$1(Function1.scala:49)
[error] sbt.internal.util.$tilde$greater.$anonfun$$u2219$1(TypeFunctions.scala:63)
[error] sbt.std.Transform$$anon$4.work(Transform.scala:69)
[error] sbt.Execute.$anonfun$submit$2(Execute.scala:283)
[error] sbt.internal.util.ErrorHandling$.wideConvert(ErrorHandling.scala:24)
[error] sbt.Execute.work(Execute.scala:292)
[error] sbt.Execute.$anonfun$submit$1(Execute.scala:283)
[error] sbt.ConcurrentRestrictions$$anon$4.$anonfun$submitValid$1(ConcurrentRestrictions.scala:265)
[error] sbt.CompletionService$$anon$2.call(CompletionService.scala:65)
[error] java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
[error] java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539)
[error] java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
[error] java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
[error] java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
[error] java.base/java.lang.Thread.run(Thread.java:833)
[error]            
[error] stack trace is suppressed; run last Compile / compileIncremental for the full output
[error] (Compile / compileIncremental) java.lang.AssertionError: assertion failed: attempt to parse java.lang.Object from classfile
[error] Total time: 0 s, completed May 13, 2024, 2:00:32 PM

It's worth noting that removing the -experimental flag indeed makes the error go away.
This also doesn't happen on 3.4.1.

@Gedochao Gedochao removed stat:needs info stat:needs minimization Needs a self contained minimization labels May 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compat:java itype:bug regression This worked in a previous version but doesn't anymore
Projects
None yet
Development

No branches or pull requests

3 participants