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

Calling AOP annotated method with Kotlin Coroutines and parameter with private constructor causes IllegalAccessException in 6.1.5 #32541

Closed
xcq1 opened this issue Mar 27, 2024 · 2 comments
Assignees
Labels
status: duplicate A duplicate of another issue theme: kotlin An issue related to Kotlin support

Comments

@xcq1
Copy link

xcq1 commented Mar 27, 2024

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.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Mar 27, 2024
@sbrannen sbrannen added the theme: kotlin An issue related to Kotlin support label Mar 27, 2024
@sbrannen
Copy link
Member

@sdeleuze sdeleuze self-assigned this Mar 27, 2024
@sdeleuze
Copy link
Contributor

Looks like indeed a duplicate.

@sdeleuze sdeleuze closed this as not planned Won't fix, can't repro, duplicate, stale Mar 27, 2024
@sdeleuze sdeleuze added status: duplicate A duplicate of another issue and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Mar 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: duplicate A duplicate of another issue theme: kotlin An issue related to Kotlin support
Projects
None yet
Development

No branches or pull requests

4 participants