I’ve been searching on google and stackoverflow and even here for how to handle the error I’m running, but I haven’t found something that addresses the particular thing I’m running into.
I have a Spring Boot (1.5.X) application that I’m converting from Java to Kotlin. Prior to the migration I followed this tutorial in order to add GraphQL support to my service:
Build a GraphQL Server with Spring Boot | Pluralsight | Pluralsight
The issue comes when trying to convert the following Java class to Kotlin:
Java Version:
public class BookNotFoundException extends RuntimeException implements GraphQLError {
private Map<String, Object> extensions = new HashMap<>();
public BookNotFoundException(String message, Long invalidBookId) {
super(message);
extensions.put("invalidBookId", invalidBookId);
@Override
public List<SourceLocation> getLocations() {
return null;
@Override
public Map<String, Object> getExtensions() {
return extensions;
@Override
public ErrorType getErrorType() {
return ErrorType.DataFetchingException;
Kotlin version (converted via IntelliJ):
class BookNotFoundException(message: String, invalidBookId: Long?): RuntimeException(message), GraphQLError {
private val extensions = HashMap<String, Any>()
init {
extensions["invalidBookId"] = invalidBookId as Any
override fun getMessage(): String {
return super.message
override fun getLocations(): List<SourceLocation>? {
return null
override fun getExtensions(): Map<String, Any> {
return extensions
override fun getErrorType(): ErrorType {
return ErrorType.DataFetchingException
The GraphQLError interface is a third party interface from the graphql-java project.
When I try to implement the getMessage() method I get the following error:
Accidental override: The following declarations have the same JVM signature (getMessage()Ljava/lang/String;):
fun <get-message>(): String? defined in graphqlpoc.exception.BookNotFoundException
fun getMessage(): String defined in graphqlpoc.exception.BookNotFoundException
And if I don’t attempt to implement the getMessage() method I get the following error:
Class ‘BookNotFoundException’ is not abstract and does not implement abstract member public abstract fun getMessage(): String! defined in graphql.GraphQLError
Is there an easy way to get around this? Or should I simply keep the Exception class in Java?