Is converting a sealed class to an interface a bin...
# library-development
d
Is converting a sealed class to an interface a binary compatible change? I’m leaning toward “effectively yes other than some reflection problems” but not confident at all.
a
No it is not. It should not break compatibility for descendants, but it surely will for the class itself.
d
In what sense? Can you give an example of a call that would work for the sealed class and not work for the interface (when the consumer is not recompiled)?
a
Their byte-code representation is different. There is surely difference on the reflection level. The general usage should be the same
z
I think if you're sealed class has any concrete methods, the bytecode to call them would be incompatible, especially if you don't use
@JvmDefaults
on your interface (but maybe even then).
d
Good point on the concrete functions, the case I was thinking of happens to have none.
e
It is
invokevirtual
vs
invokeinterface
at the bytecode level
2
d
Ahhh never knew those were different! Thanks!