Affects: 6.1.5
I have a working Spring application using 6.1.4 (by means of Boot 3.2.3). When that version is bumped to 6.1.5 (via Boot 3.2.4), I suddenly see REST tests failing with
java.lang.IllegalAccessException: class kotlin.reflect.jvm.internal.calls.CallerImpl$Method cannot access a member of class <MyClass> with modifiers "private static"
at java.base/java.lang.reflect.AccessibleObject.checkAccess(AccessibleObject.java:674) ~[na:na]
at java.base/java.lang.reflect.Method.invoke(Method.java:568) ~[na:na]
at kotlin.reflect.jvm.internal.calls.CallerImpl$Method.callMethod(CallerImpl.kt:97) ~[kotlin-reflect-1.9.23.jar:1.9.23-release-779]
at kotlin.reflect.jvm.internal.calls.CallerImpl$Method$Static.call(CallerImpl.kt:106) ~[kotlin-reflect-1.9.23.jar:1.9.23-release-779]
at kotlin.reflect.jvm.internal.calls.ValueClassAwareCaller.call(ValueClassAwareCaller.kt:199) ~[kotlin-reflect-1.9.23.jar:1.9.23-release-779]
at kotlin.reflect.jvm.internal.KCallableImpl.call(KCallableImpl.kt:108) ~[kotlin-reflect-1.9.23.jar:1.9.23-release-779]
at org.springframework.core.CoroutinesUtils.lambda$invokeSuspendingFunction$2(CoroutinesUtils.java:132) ~[spring-core-6.1.5.jar:6.1.5]
at kotlin.coroutines.intrinsics.IntrinsicsKt__IntrinsicsJvmKt$createCoroutineUnintercepted$$inlined$createCoroutineFromSuspendFunction$IntrinsicsKt__IntrinsicsJvmKt$4.invokeSuspend(IntrinsicsJvm.kt:270) ~[kotlin-stdlib-1.9.23.jar:1.9.23-release-779]
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33) ~[kotlin-stdlib-1.9.23.jar:1.9.23-release-779]
at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:108) ~[kotlinx-coroutines-core-jvm-1.7.3.jar:na]
at kotlinx.coroutines.EventLoopImplBase.processNextEvent(EventLoop.common.kt:280) ~[kotlinx-coroutines-core-jvm-1.7.3.jar:na]
at kotlinx.coroutines.BlockingCoroutine.joinBlocking(Builders.kt:85) ~[kotlinx-coroutines-core-jvm-1.7.3.jar:na]
at kotlinx.coroutines.BuildersKt__BuildersKt.runBlocking(Builders.kt:59) ~[kotlinx-coroutines-core-jvm-1.7.3.jar:na]
at kotlinx.coroutines.BuildersKt.runBlocking(Unknown Source) ~[kotlinx-coroutines-core-jvm-1.7.3.jar:na]
at kotlinx.coroutines.BuildersKt__BuildersKt.runBlocking$default(Builders.kt:38) ~[kotlinx-coroutines-core-jvm-1.7.3.jar:na]
at kotlinx.coroutines.BuildersKt.runBlocking$default(Unknown Source) ~[kotlinx-coroutines-core-jvm-1.7.3.jar:na]
at <MyRESTController>$suspendImpl(<MyRESTController>.kt:23) ~[main/:na]
...
The class in question is a parameter of a method with an AOP annotation that is called from a REST controller and it is defined with a private constructor such as
@JvmInline
value class NonEmptyString private constructor(val nonBlankString: String) { /* ... */ }
The error itself is pretty meaningless, but from debugging I suspect the issue comes from CoroutinesUtils
where an attempt is made to call a primary constructor. I have found this maybe related issue: #32510, but I cannot tell (or did not find a snapshot to test) whether the solution there solves this behavior as well.
I have condensed the code to a minimal reproduction example: https://github.com/xcq1/spring-demo-kotlin-illegalaccess
If the application is launched and a request to http://localhost:8080/api/demo?string=test
is made, the exception is thrown.
The problem disappears when downgrading org.springframework.boot
to 3.2.3
.
Comment From: sbrannen
- potential duplicate of #32536
Comment From: sdeleuze
Looks like indeed a duplicate.