# Java interoperability with Kotlin constructors

**URL:** <https://discuss.kotlinlang.org/t/java-interoperability-with-kotlin-constructors/9582>\
**Category:** Language Design\
**Created:** [September 26, 2018, 6:13pm UTC](https://discuss.kotlinlang.org/t/java-interoperability-with-kotlin-constructors/9582 "2018-09-26T18:13:45Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mparlee](https://avatars.discourse-cdn.com/v4/letter/m/258eb7/32.png) [@mparlee](https://discuss.kotlinlang.org/u/mparlee)\
**Post date:** [September 26, 2018, 6:13pm UTC](https://discuss.kotlinlang.org/t/java-interoperability-with-kotlin-constructors/9582/1 "2018-09-26T18:13:45Z")

</div>

Hi community,

Having recently started using Kotlin I’ve been enjoying named and optional constructor arguments. I’m finding that we get the benefits of a Builder Pattern with a significant reduction in code.

Unfortunately the Java end users of our API have to deal with a constructor that takes too many arguments. @JvmOverloads doesn’t really address the problem nicely. The standard Java approach to this problem would be to provide a Builder for the object.

Does there exist or has there been any thought to providing a constructor annotation that would generate a Builder to provide Java users with the same benefits as our native Kotlin constructor? eg. optional, named parameters in and an immutable object in return?

Thanks,  
Mike

---

<div class="post-metadata">

**Author:** ![tieskedh](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/tieskedh/32/2816_2.png) [@tieskedh](https://discuss.kotlinlang.org/u/tieskedh)\
**Post date:** [September 26, 2018, 6:19pm UTC](https://discuss.kotlinlang.org/t/java-interoperability-with-kotlin-constructors/9582/2 "2018-09-26T18:19:39Z")

</div>

> [@Generate Java-Style Builders for Interop](https://discuss.kotlinlang.org/t/generate-java-style-builders-for-interop/2422):
>
> We should be able to write Kotlin code that is reasonably usable from within Java. I think an excellent example of this is extension methods that are called from Java as static helpers with the receiver being the first argument. Kotlin should allow something similarly readable for builders. I’m well aware we don’t need builders in Kotlin because we can use optional arguments. For example: class Config( val domain: String, val port: Int = 443, val sslVerify: Boolean = true ) Allows…

But unfortunately, no answer yet
