What does ```java.lang.NoSuchMethodError: 'void Common_main$Strategy.<init>(java.lang.Boolean,...
v
What does
Copy code
java.lang.NoSuchMethodError: 'void Common_main$Strategy.<init>(java.lang.Boolean, Common_main$Matrix, int, kotlin.jvm.internal.DefaultConstructorMarker)'
want to tell me? Obviously, it compiled fine, but now it does not run? o_O The called constructor is
Copy code
data class Strategy(
    val failFast: Boolean? = false,
    val matrix: Matrix? = Matrix()
) { ... }
And it is called like
Copy code
Strategy()
The class decompiled to Java shows the constructor it is complaining about. Hmmm
Copy code
$ javap -p -c Common_main\$Strategy.class | grep DefaultConstructorMarker | grep Strategy
  public Common_main$Strategy(Common_main, java.lang.Boolean, Common_main$Matrix, int, kotlin.jvm.internal.DefaultConstructorMarker);
$ javap -p -c Branches_and_prs_main\$2.class | grep DefaultConstructorMarker | grep Strategy
      72: invokespecial #72                 // Method Common_main$Strategy."<init>":(Ljava/lang/Boolean;LCommon_main$Matrix;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
πŸ˜•
i
Looks like a bug in the evaluator to me. Could you, please, file an issue in YT?
v
I wanted to. But I first have to reproduce. I was in a rush and juggled the code until it worked like I needed it and then was not able to instantly reproduce it.
No, unfortunately I'm not able to reproduce right now and local history of the files is not available anymore. 😞 I could create an issue, but withot reproducer it will probably not help much.
Oh, now I got it again. Will try to boil it down.
Great, boiled it down to
foo.main.kts
Copy code
@file:Import("bar.main.kts")

println(Foo())
and
bar.main.kts
Copy code
class Foo(
    val bar: Nothing? = baz
) {
    companion object
}

val Foo.Companion.baz
    get() = null
=>
Copy code
java.lang.NoSuchMethodError: 'void Bar_main$Foo.<init>(java.lang.Void, int, kotlin.jvm.internal.DefaultConstructorMarker)'
	at Foo_main.<init>(foo.main.kts:3)
πŸŽ‰
i
Thank you very much!
πŸ‘Œ 1
v
Argh, all the effort just get it closed as a duplicate of an issue you reported 11 months ago. πŸ™ˆ πŸ˜„
i
I'm sorry. But it is always helps to have a second repro, so thank your anyway!
v
Yeah, don't worry. πŸ™‚ I just always hate getting things closed as duplicate. Either means I was too lazy to search first or my search-fu failed on me. And they probably do not count to the "you get a free all products pack" license issues. πŸ˜„
r
I think I have a similar issue… I tried to run an old script but suddenly it does not work
Copy code
java.lang.NoSuchMethodError: 'void <http://org.slf4j.Logger.info|org.slf4j.Logger.info>(java.lang.String, java.lang.Throwable)'
It's very weird, and also this script worked before. Something broke in an update to Kotlin. I wonder if and how I can roll it back
In my case I'm referencing slf4j from like a 4-libs dependency chain so I don't think I can make a reproducer easily
I don't know if it's the same issue. The one linked says it affects Kotlin 1.7.0. In my case, I have the error using Kotlin 1.8.20 but not 1.8.0. I used sdkman to install different versions of kotlin (Homebrew does not have past versions)
v
My issue was / is against 1.8.21
r
Did you try rolling back to an earlier version of Kotlin (if you can)?
v
No, I adapted my code to not trigger the bug πŸ™‚
r
Well I can't adapt my code to not use
<http://log.info|log.info>
πŸ˜„
v
I didn't imply you could πŸ˜„
170 Views