Skip to content

Kotlin value class - cannot access a member of class with modifiers "private static" #32604

Closed as not planned
@k3vonk

Description

Affects: 6.1.5


Value classes in Kotlin with private constructor hits the following exception:

java.lang.IllegalAccessException: class kotlin.reflect.jvm.internal.calls.CallerImpl$Method cannot access a member of class org.gajyoung.demosbwithvalueclass.FooId with modifiers "private static"
	at java.base/jdk.internal.reflect.Reflection.newIllegalAccessException(Reflection.java:392) ~[na:na]
	at java.base/java.lang.reflect.AccessibleObject.checkAccess(AccessibleObject.java:674) ~[na:na]
	at java.base/java.lang.reflect.Method.invoke(Method.java:560) ~[na:an]

I've reproduced the issue in a WebMVC where the value class is a required request header: https://github.com/k3vonk/springboot-3.2.4-with-value-class

This issue does not occur in Spring Boot 3.2.3 which uses spring framework 6.1.4. You can switch the versions in the above example, and the get request will pass without an exception.

Metadata

Assignees

Labels

status: duplicateA duplicate of another issuetheme: kotlinAn issue related to Kotlin support

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions