I’m trying to build something like this:
interface GraphQLError {
fun getMessage(): String
}
class MyOwnException(s: String?) : RuntimeException(s), GraphQLError
However, I’m getting 2 errors:
Class 'MyOwnException' is not abstract and does not implement abstract member public abstract fun getMessage(): String defined in com.arcnor.test.GraphQLError
---
Inherited platform declarations clash: The following declarations have the same JVM signature (getMessage()Ljava/lang/String;): fun <get-message>(): String? defined in com.arcnor.test.MyOwnException fun getMessage(): String defined in com.arcnor.test.MyOwnException
I don’t understand why I’m getting a clash? RuntimeException
already defines getMessage(): String
, which should be used for this definition?
In any case, I’m really getting this error from the graphql Java library, that contains a similar definition to my GraphQLError
interface there, but defined in Java, but it fails both with the original and my simple file up there.
Finally, even if I try to implement this myself (override fun getMessage()...
) I get the following error:
Kotlin: Accidental override: The following declarations have the same JVM signature (getMessage()Ljava/lang/String;):
fun <get-message>(): String? defined in com.arcnor.test.MyOwnException
fun getMessage(): String defined in com.arcnor.test.MyOwnException
Also, it seems some other people had the same questions here (kotlin - "Accidental override: The following declarations have the same JVM signature" when implementing Java interface - Stack Overflow) and here (GraphQLError in Kotlin is cause an Accidental Override · Issue #1022 · graphql-java/graphql-java · GitHub)