AbstractMethodError on property access

Hi guys,

I’m getting a java.lang.AbstractMethodError when retrieving the value of a property from a Kotlin class. I have a class hierarchy like this:

class ClassA(...) : ClassB(...), InterfaceA {
...
}

abstract ClassB(...) : ClassD(...) {
...
}

abstract ClassD(...) {
   val ordinal = Counters.get().counter(this.javaClass)
}

interface InterfaceA {
   val ordinal: Int
}

So, InterfaceA declares the property “ordinal”, and my ClassA should have an implementation and value of this property inherited from ClassD. But when retrieving the value of “ordinal”, I get the AbstractMethodError.
I don’t understand why the implementation and value inherited from ClassD are not effective. And even if it isn’t and I’m missing something, this is probably something that should be caught by the compiler.

At the moment I am using a workaround by declaring the property in ClassD “open” and overriding it in ClassA using the same assignment as in ClassD.
Maybe somebody can enlighten me on what is going on?

Thanks and regards

1 Like

Hi guys,

I created a small demo of the issue, using the same class architecture, but unsurprisingly it works just fine in my simplified, minimal demo application. I would have been surprised if a fundamental thing like this was buggy in Kotlin.
This means there is something about my application that is leading to this error. But I wonder what it could be. I’m not using any fancy reflection or bytecode generating features, or hacky libraries like Lombok that could be causing this. It’s just plain Java and Kotlin code.

I will try to investigate further and post if I find the underlying issue.

1 Like

Could it be that some of the classes/interfaces are java and some are kotlin? I seem to remember having a similar problem a few weeks back, but can’t remember how I solved it. I think I ended up migrating some more classes to kotlin.

1 Like

Yes, that is correct. My project is mostly Java (the interface and base class providing the implementation), and I have started to implement new classes in Kotlin as a way to experiment with -and learn- the language.

Sorry for radio-silence, I was busy with diapers and shit.
Still haven’t solved the issue. At the moment I’m using the workaround described in the first post.

2 Likes

Hey, I know it’s been a while, any chance you encountered this through tests using Mockk?

No, no mocking going on. Just plain Java and Kotlin code.