# Using Java classes in Kotlin-style

**URL:** <https://discuss.kotlinlang.org/t/using-java-classes-in-kotlin-style/544>\
**Category:** Uncategorized\
**Created:** [July 7, 2014, 2:34pm UTC](https://discuss.kotlinlang.org/t/using-java-classes-in-kotlin-style/544 "2014-07-07T14:34:49Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![svatal](https://avatars.discourse-cdn.com/v4/letter/s/9d8465/32.png) [@svatal](https://discuss.kotlinlang.org/u/svatal)\
**Post date:** [July 7, 2014, 2:34pm UTC](https://discuss.kotlinlang.org/t/using-java-classes-in-kotlin-style/544/1 "2014-07-07T14:34:49Z")

</div>

Is there any simple way to use getters like properties? E.g. use _ **exception.message** _ instead of _**exception.getMessage()**_ ? Only way I can think of is creating intermediate kotlin class with _ **message** _ property, getter calling _**getMessage()**_ with custom _ **platformName** _ to avoid name clash. Which is a lot of code to get rid of 5 letters ..

---

<div class="post-metadata">

**Author:** ![abreslav](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/abreslav/32/8279_2.png) [@abreslav](https://discuss.kotlinlang.org/u/abreslav)\
**Post date:** [July 7, 2014, 3:43pm UTC](https://discuss.kotlinlang.org/t/using-java-classes-in-kotlin-style/544/2 "2014-07-07T15:43:49Z")

</div>

Currently this functionality is not supported. We will probably add it later

---

<div class="post-metadata">

**Author:** ![udalov](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/udalov/32/5679_2.png) [@udalov](https://discuss.kotlinlang.org/u/udalov)\
**Post date:** [July 7, 2014, 3:50pm UTC](https://discuss.kotlinlang.org/t/using-java-classes-in-kotlin-style/544/3 "2014-07-07T15:50:57Z")

</div>

Subscribe to this issue to receive notifications: [KT-400](http://youtrack.jetbrains.com/issue/KT-400)

---

<div class="post-metadata">

**Author:** ![svatal](https://avatars.discourse-cdn.com/v4/letter/s/9d8465/32.png) [@svatal](https://discuss.kotlinlang.org/u/svatal)\
**Post date:** [July 8, 2014, 8:44am UTC](https://discuss.kotlinlang.org/t/using-java-classes-in-kotlin-style/544/4 "2014-07-08T08:44:59Z")

</div>

With Andrey's reply from the mentioned bug, I has been able to create much shorter workaround: _**val Throwable.message : String &nbsp;&nbsp;get() = this.getMessage()!!**_ .. along with some namespaces/imports to be able to use it everywhere

Just to be sure - extension functions does not collide with ‘same JVM signature’ accidental override mentioned in M8?

---

<div class="post-metadata">

**Author:** ![evacchi](https://avatars.discourse-cdn.com/v4/letter/e/bc8723/32.png) [@evacchi](https://discuss.kotlinlang.org/u/evacchi)\
**Post date:** [July 23, 2014, 7:55pm UTC](https://discuss.kotlinlang.org/t/using-java-classes-in-kotlin-style/544/5 "2014-07-23T19:55:34Z")

</div>

I actually thought this was a feature. You see, Groovy has this feature, but sometimes it clashes with the fact that in Java some "getters" do not actually represent properties e.g. java.io.File#getCanonicalFile()

I can’t find a reference right now, but I do remember someone raising the issue

---

<div class="post-metadata">

**Author:** ![abreslav](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/abreslav/32/8279_2.png) [@abreslav](https://discuss.kotlinlang.org/u/abreslav)\
**Post date:** [July 24, 2014, 9:52am UTC](https://discuss.kotlinlang.org/t/using-java-classes-in-kotlin-style/544/6 "2014-07-24T09:52:03Z")

</div>

No, it will be fine.
