Can an anonymous object ever be non-final on the j...
# announcements
c
Can an anonymous object ever be non-final on the jvm?
d
Does it matter?
c
I wanted to use it in a test ... I implemented an interface like
object : TheInterface { ... }
. But for mockito it needs to be non-final, so I have to write a whole class in the code. It’s not horrible but could be neater 🙂
d
I guess you could try marking it as
open
but idk if that'll work.
c
It’s a syntax error 😄
d
You could maybe work around it using the
allopen
compiler plugin with custom annotation. But I am not sure if it works on anonymous objects
k
didn’t Mockito 2 lift this restriction via the MockMaker plugin?
or is this a special case?
t
Do you mean that you want to mock an anonymous class ? I'm curious about the use case. Why not mock the interface itself ?
c
I wanted to spy rather than mock actually ...
c
I’m pretty sure that it works if you enable the mockmaker plugin
c
Will check that out, thanks