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

**URL:** <https://discuss.kotlinlang.org/t/java-interface-method-integer-kotlin-implement-it-but-java-new-this-impl-class-fail/5010>\
**Category:** Uncategorized\
**Created:** [October 16, 2017, 12:14pm UTC](https://discuss.kotlinlang.org/t/java-interface-method-integer-kotlin-implement-it-but-java-new-this-impl-class-fail/5010 "2017-10-16T12:14:06Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![liufsd](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/liufsd/32/1731_2.png) [@liufsd](https://discuss.kotlinlang.org/u/liufsd)\
**Post date:** [October 16, 2017, 12:14pm UTC](https://discuss.kotlinlang.org/t/java-interface-method-integer-kotlin-implement-it-but-java-new-this-impl-class-fail/5010/1 "2017-10-16T12:14:06Z")

</div>

java interface JA.java:

```auto
 interface JA
 {
    void a(integer code)
}

```

kotlin implement JA, JAImpl.kt:

```auto
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’

```java
  new JAImpl(){

    @override
    void a(integer code){}

    @override
    void hookCode(int code){}

  }

```

```kotlin
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.

---

<div class="post-metadata">

**Author:** ![liufsd](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/liufsd/32/1731_2.png) [@liufsd](https://discuss.kotlinlang.org/u/liufsd)\
**Post date:** [October 16, 2017, 1:46pm UTC](https://discuss.kotlinlang.org/t/java-interface-method-integer-kotlin-implement-it-but-java-new-this-impl-class-fail/5010/2 "2017-10-16T13:46:21Z")

</div>

kotlin bug here: [https://youtrack.jetbrains.com/issue/KT-20784](https://youtrack.jetbrains.com/issue/KT-20784)

---

<div class="post-metadata">

**Author:** ![zhengkeli](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/zhengkeli/32/3974_2.png) [@zhengkeli](https://discuss.kotlinlang.org/u/zhengkeli)\
**Post date:** [October 17, 2017, 2:19pm UTC](https://discuss.kotlinlang.org/t/java-interface-method-integer-kotlin-implement-it-but-java-new-this-impl-class-fail/5010/3 "2017-10-17T14:19:43Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![liufsd](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/liufsd/32/1731_2.png) [@liufsd](https://discuss.kotlinlang.org/u/liufsd)\
**Post date:** [October 17, 2017, 3:10pm UTC](https://discuss.kotlinlang.org/t/java-interface-method-integer-kotlin-implement-it-but-java-new-this-impl-class-fail/5010/4 "2017-10-17T15:10:30Z")

</div>

> [@zhengkeli](#):
>
> 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.

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’ ?

---

<div class="post-metadata">

**Author:** ![fatjoe79](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/fatjoe79/32/4221_2.png) [@fatjoe79](https://discuss.kotlinlang.org/u/fatjoe79)\
**Post date:** [October 18, 2017, 1:12pm UTC](https://discuss.kotlinlang.org/t/java-interface-method-integer-kotlin-implement-it-but-java-new-this-impl-class-fail/5010/5 "2017-10-18T13:12:01Z")

</div>

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