sbt / sbt

sbt, the interactive build tool
https://scala-sbt.org
Apache License 2.0
4.76k stars 931 forks source link

Error message in log when compiling: BufferStrategyPaintManager$ #7561

Open OndrejSpanel opened 1 month ago

OndrejSpanel commented 1 month ago

steps

I was unable to create a small repro yet.

When I compile my application (sbt 1.10.0, Scala 3.4.1) and there are some errors, following exception is shown:

exception caught when loading module class BufferStrategyPaintManager$: java.lang.AssertionError: assertion failed: failure to resolve inner class:eIncremental 3s
externalName = javax.swing.RepaintManager$PaintManager,
outerName = javax.swing.RepaintManager,
innerName = PaintManager
owner.fullName = javax.swing.RepaintManager
while parsing C:\Users\Ondra\.sbt\1.0\java9-rt-ext-eclipse_adoptium_21_0_3\rt.jar(javax/swing/BufferStrategyPaintManager.class)

problem

I have no idea what the error is, or if it is an error at all.

expectation

If the exception is not relevant for me, do not show it.

notes

The classes mentioned in the warning are not referenced directly in my project. They are used in JogAmp library I use, but I am not sure if this is relevant. Using Swing or having JogAmp a dependency is not enough to reproduce the issue.

Originally reported as https://youtrack.jetbrains.com/issue/SCL-22558

eed3si9n commented 1 month ago

@OndrejSpanel Even without the full reproduction, could you generally describe what is happening? Can it happen with typing compile into sbt shell? Could you also copy-paste full stack trace to Gist, if it's available? From the error message, it seems like the error is coming from Scala 3, not sbt: https://github.com/scala/scala3/blob/06ffc8c02aa9a152765f88b49e44d8c759f1284a/compiler/src/dotty/tools/dotc/core/classfile/ClassfileParser.scala#L1271-L1277

OndrejSpanel commented 1 month ago

Yes, it happens with compile, when using Java 17 or 21 and when there are errors in my code.

Exception is shown just below [info] compiling and above any errors coming from my project. If there are no errors, no exception is shown. Also, not all errors cause it to appear, but I have one which reproduced it anytime so far.

the error is coming from Scala 3, not sbt:

That may well be, but the thing it is reporting the _java9-rt-ext-eclipse_adoptium_21_03\rt.jar is some stuff SBT is generating, is it not?

Could you also copy-paste full stack trace to Gist, if it's available?

Luckily it is easy to reproduce in my project.

I was able to attach the debugger to sbt and here is the callstack: https://gist.github.com/OndrejSpanel/df207819ccc5cfe845356e357f964db4

The top is:

assertFailed:8, Scala3RunTime$ (scala.runtime)
classSymbol:1277, ClassfileParser$innerClasses$ (dotty.tools.dotc.core.classfile)
classNameToSymbol:320, ClassfileParser (dotty.tools.dotc.core.classfile)
getClassSymbol:1365, ClassfileParser (dotty.tools.dotc.core.classfile)
getClassSymbol:1326, ClassfileParser$ConstantPool (dotty.tools.dotc.core.classfile)
getSuperClass:176, ClassfileParser$AbstractConstantPool (dotty.tools.dotc.core.classfile)
parseParents$1:380, ClassfileParser (dotty.tools.dotc.core.classfile)
parseClass:395, ClassfileParser (dotty.tools.dotc.core.classfile)
eed3si9n commented 1 month ago

the java9-rt-ext-eclipse_adoptium_21_0_3\rt.jar is some stuff SBT is generating, is it not?

Yea, but it's just a copy of rt.jar so we can pass it to scalac. If you could reproduce it just by using command line Scala 3 that might be more definite, but if the stacktrace comes from the compiler, it's usually a compiler or compiler bridge issue.

OndrejSpanel commented 1 month ago

OK. Now what? I guess as it is now it is not in a good shape to be reported as Scala 3 issue. Do you have any advice on minimizing this? The project is quite large, how can I find what parts are likely to be necessary?

eed3si9n commented 1 month ago

My recommendation is to report it as-is esp with the stacktrace.