-
Notifications
You must be signed in to change notification settings - Fork 38.8k
Closed as not planned
Closed as not planned
Copy link
Labels
in: webIssues in web modules (web, webmvc, webflux, websocket)Issues in web modules (web, webmvc, webflux, websocket)status: duplicateA duplicate of another issueA duplicate of another issuetheme: kotlinAn issue related to Kotlin supportAn issue related to Kotlin support
Description
Affects: Spring Framework 5.3.9, Spring Boot 2.5.4
Using a @JvmInline value class as a handler method argument fails with the following:
java.lang.IllegalArgumentException: object is not an instance of declaring class
My best guess is this happens because, say with the example below:
@JvmInline value class ProductId(val id: String)
@GetMapping("/product")
suspend fun getProduct(@RequestParam productId: ProductId) { ... }at runtime the getProduct parameter type when viewed from Java reflection is the wrapped value type (String) but when viewed from Kotlin reflection, the parameter is the wrapper value class (ProductId). The error is thrown when the function is invoked from kotlin reflection with String instance arguments (contributed by the RequestParam resolver) but the kotlin reflection API expects the ProductId instance (which it automatically unboxes, exception is thrown here)
frel, gzeskas, marzelwidmer, rgmz, FalkWoldmann and 4 more
Metadata
Metadata
Assignees
Labels
in: webIssues in web modules (web, webmvc, webflux, websocket)Issues in web modules (web, webmvc, webflux, websocket)status: duplicateA duplicate of another issueA duplicate of another issuetheme: kotlinAn issue related to Kotlin supportAn issue related to Kotlin support