Is there any way to disable mangling for functions...
# compiler
m
Is there any way to disable mangling for functions that consume inline classes? Spring Data cant deal with this.
e
https://kotlinlang.org/docs/inline-classes.html#calling-from-java-code but it's not really usable with inheritance (without further hacks), so hopefully that's not the case you're in
m
Oh, I forgot about
@JvmName
, TYSM!
Well, I get
'@JvmName' annotation is not applicable to this declaration
And here is my code:
Copy code
@Repository
interface WebhookRepository : JpaRepository<Webhook, WebhookId> {

    @JvmName("findWebhookByName")
    fun findWebhookByName(name: WebhookId): Optional<Webhook>
}
e
yes, because of the issue I linked
there isn't a good solution
m
Is there any?
e
you can
@Suppress
the error away, but you have to manually use the correct
@JvmName
on every overload (otherwise you get missing methods at runtime… this is why it's a compiler error)
m
I'm not implementing this interface, Spring does. I'll try what you suggested
e
if it's only implemented from the Java side then
Copy code
@Repository
interface WebhookRepository : JpaRepository<Webhook, WebhookId> {
    @Suppress("INAPPLICABLE_JVM_NAME")
    @JvmName("findWebhookByName")
    fun findWebhookByName(name: WebhookId): Optional<Webhook>
}
should be sufficient
if it's ever implemented in Kotlin you must remember to manually add
@Suppress("INAPPLICABLE_JVM_NAME") @JvmName("findWebhookByName")
to the override
m
It's implemented via codegen 🧌 by Spring Data
Well, it worked perfectly. Thank you again. I'll open an issue about it, maybe Spring Data team find a way to be tolerant to Kotlin's function mangling while method name parsing
e
if they're using APT for codegen then there's not much they can do about it - there's no way to represent the mangled names in the Java model
if they're doing it with proxies at runtime or similar, then yeah it could be doable
m
Yeah, they use cglib
126 Views