@Target([AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY])
annotation classJvmDefaultSpecifies that a JVM default method should be generated for
non-abstract Kotlin interface member.Usages of this annotation require an explicit compilation argument to
be specified: either-Xjvm-default=enableor
-Xjvm-default=compatibility.with
-Xjvm-default=enable, only default method in interface is generated for each@JvmDefaultmethod. In this mode, annotating an
existing method with@JvmDefaultcan break binary compatibility,
because it will effectively remove the method from theDefaultImpls
class.with
-Xjvm-default=compatibility, in addition to the default interface
method, a compatibility accessor is generated in the
DefaultImplsclass, that calls the default interface method via a
synthetic accessor. In this mode, annotating an existing method with
@JvmDefaultis binary compatible, but results in more methods in
bytecode.Removing this annotation from an interface member is a binary
incompatible change in both modes.Generation of default methods is only possible with JVM target
bytecode version 1.8 (-jvm-target 1.8) or higher.
@JvmDefaultmethods are excluded from interface delegation.
https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.jvm/-jvm-default/index.html
if you use gradle then add this parameter to gradle script
https://kotlinlang.org/docs/reference/using-gradle.html
for example add this to gradle:
kotlinOptions {
freeCompilerArgs = ['-Xjvm-default=compatibility']
}
otherwise if you use Kotlinc command line compiler add -Xjvm-default=compatibility after your command in command line