# FunctionImpl is deprecated

**URL:** <https://discuss.kotlinlang.org/t/functionimpl-is-deprecated/15063>\
**Category:** Language Design\
**Created:** [November 17, 2019, 3:27am UTC](https://discuss.kotlinlang.org/t/functionimpl-is-deprecated/15063 "2019-11-17T03:27:26Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![sannysinghs](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/sannysinghs/32/4094_2.png) [@sannysinghs](https://discuss.kotlinlang.org/u/sannysinghs)\
**Post date:** [November 17, 2019, 3:27am UTC](https://discuss.kotlinlang.org/t/functionimpl-is-deprecated/15063/1 "2019-11-17T03:27:27Z")

</div>

While checking kotlin lambda decompiled code in java, found out Function1.kt interface is implemented by `FunctionImpl` abstract class which is deprecated. If it is deprecated, which one i should look into for correct java implementation of Kotlin Lambda ?

Original Kotlin code

```auto
fun performDbOperation(operation: (db: DbInstance) -> Unit) {
        val dbInstance = DbInstance()
        dbInstance.open()
        operation.invoke(dbInstance)
        dbInstance.close()

    }

```

Decompiled java code

```
public final void performDbOperation(@NotNull Function1 operation) {
      Intrinsics.checkParameterIsNotNull(operation, "operation");
      DbInstance dbInstance = new DbInstance();
      dbInstance.open();
      operation.invoke(dbInstance);
      dbInstance.close();
   }

```

---

<div class="post-metadata">

**Author:** ![Wasabi375](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/wasabi375/32/4741_2.png) [@Wasabi375](https://discuss.kotlinlang.org/u/Wasabi375)\
**Post date:** [November 17, 2019, 3:57am UTC](https://discuss.kotlinlang.org/t/functionimpl-is-deprecated/15063/2 "2019-11-17T03:57:38Z")

</div>

I’m not sure what your question is? Do you want to know how to call `performDbOperation` from java?  
In that case you can use

```java
performDbOperation(new Function1<DbInstance, Unit>() {
    override public Unit invoke(DbInstance db){
        // TODO
        return Unit.INSTANCE;
    }
});

```

I’m pretty sure you can also use javas lambda syntax (can’t remember the syntax though, it’s been a while since I used java).

---

<div class="post-metadata">

**Author:** ![Wasabi375](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/wasabi375/32/4741_2.png) [@Wasabi375](https://discuss.kotlinlang.org/u/Wasabi375)\
**Post date:** [November 17, 2019, 4:03am UTC](https://discuss.kotlinlang.org/t/functionimpl-is-deprecated/15063/3 "2019-11-17T04:03:09Z")

</div>

Also `FunctionImpl` is something internal. Not sure what it was used for. I think it was used to provide lambdas with more than 22 parameters. If you want to see a decompiled version of a lambda implementation just decompile any kotlin code that passes a lambda to a function. Make sure the function is not inline though (otherwise it won’t work). The code should look somewhat like I posted above. There is probably some extra for capturing local variables but the essence is the same. Each lambda is compiled into a class implementing `FunctionX` with the lambda code in the `invoke` function.
