Java Interface method integer , kotlin implement it ,but java new this impl class fail


#1

java interface JA.java:

 interface JA
 {
    void a(integer code)
}

kotlin implement JA, JAImpl.kt:

abstract class JAImpl: JA
 {
   override fun a(code: Int){
       hookA(code)
   }
   
   abstract fun hookCode(code: Int)
}

but when new JAImpl in java class.
it must to implement ’ void a(integer code )’ and ‘hookCode’ . but in kotlin class only need implement ‘hookCode’

  new JAImpl(){

    @override
    void a(integer code){}

    @override
    void hookCode(int code){}

  }
object: JAImpl(){
  override fun hookCode(code: Int)
}

how to fix this ? i don’t want override ‘a’ method in java . but IDE tip must to implement, i think the “integer” is key.


#2

kotlin bug here: https://youtrack.jetbrains.com/issue/KT-20784


#3

Oh, yes. I’ve once met such problem when cooperating with another programmer writing Java.
The “default method” in interface written in Kotlin is also been requested to rewrite the method body while implementing in Java (even the Kotlin is targeted to Java 8).
It seems that only when you write the method body in Java, that you can implement (or extend) the interface (abstract class) without rewriting. All the “default methods” written in Kotlin are invisble in Java.


#4

yes.
But. how to fix by kotlin? i do not want rewrite this by java to fix this problem.
So. ‘kotlin not 100% support java’ ?


#5

Even Java does not 100% support Java, if you consider compiler bugs can exist there, too.