# Passing java class as parameter

**URL:** <https://discuss.kotlinlang.org/t/passing-java-class-as-parameter/1954>\
**Category:** Support\
**Created:** [September 4, 2016, 2:12pm UTC](https://discuss.kotlinlang.org/t/passing-java-class-as-parameter/1954 "2016-09-04T14:12:55Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![roman](https://avatars.discourse-cdn.com/v4/letter/r/ed8c4c/32.png) [@roman](https://discuss.kotlinlang.org/u/roman)\
**Post date:** [September 4, 2016, 2:12pm UTC](https://discuss.kotlinlang.org/t/passing-java-class-as-parameter/1954/1 "2016-09-04T14:12:55Z")

</div>

I’m trying to convert a portion of a java codebase to Kotlin. The core framework will still be java so I’m trying figure out how to call the java function from a Kotlin class.

The java interface for the function is:

`Integer get(Class<? extends SomeInterface> clazz);`

The way to call it in java would be:

`input.get(SomeClass.class)`

(SomeClass is an implementation of SomeInterface, both written in Java)

From Kotlin I would assume the call should look like

`input.get(SomeClass::class)`

but I am getting the error:

None of the following functions can be called with the arguments supplied.

- `get(Class<out SomeInterface!>! defined in...`

Am I incorrectly passing the class as a parameter?

Side Note: when I copy and paste the java code into a kotlin class in intellij it autoconverts it to:

`input.get(SomeClass::class.java) `

but I get “unresolved reference: java”

Thank you.

pom contains:

```
    <dependency>
        <groupId>org.jetbrains.kotlin</groupId>
        <artifactId>kotlin-stdlib</artifactId>
        <version>1.0.3</version>
    </dependency>
    <dependency>
        <groupId>org.jetbrains.kotlin</groupId>
        <artifactId>kotlin-reflect</artifactId>
        <version>1.0.3</version>
    </dependency>

```

---

<div class="post-metadata">

**Author:** ![pniederw1](https://avatars.discourse-cdn.com/v4/letter/p/0ea827/32.png) [@pniederw1](https://discuss.kotlinlang.org/u/pniederw1)\
**Post date:** [September 4, 2016, 6:15pm UTC](https://discuss.kotlinlang.org/t/passing-java-class-as-parameter/1954/2 "2016-09-04T18:15:38Z")

</div>

`SomeClass::class.java` is correct. The “unresolved reference” error sounds like a dependency issue with the `KClass.java` extension property defined in `kotlin-runtime` not being found. Perhaps the IntelliJ project is not set up correctly? In Maven, you should be getting `kotlin-runtime` through `kotlin-stdlib`.

---

<div class="post-metadata">

**Author:** ![molchanoviv](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/molchanoviv/32/1846_2.png) [@molchanoviv](https://discuss.kotlinlang.org/u/molchanoviv)\
**Post date:** [September 4, 2016, 6:28pm UTC](https://discuss.kotlinlang.org/t/passing-java-class-as-parameter/1954/3 "2016-09-04T18:28:30Z")

</div>

[https://kotlinlang.org/docs/reference/reflection.html](https://kotlinlang.org/docs/reference/reflection.html)

> On the Java platform, the runtime component required for using the reflection features is distributed as a separate JAR file (kotlin-reflect.jar). This is done to reduce the required size of the runtime library for applications that do not use reflection features. If you do use reflection, please make sure that the .jar file is added to the classpath of your project.

---

<div class="post-metadata">

**Author:** ![pniederw1](https://avatars.discourse-cdn.com/v4/letter/p/0ea827/32.png) [@pniederw1](https://discuss.kotlinlang.org/u/pniederw1)\
**Post date:** [September 4, 2016, 6:55pm UTC](https://discuss.kotlinlang.org/t/passing-java-class-as-parameter/1954/4 "2016-09-04T18:55:39Z")

</div>

`kotlin-reflect` isn’t required for `::class.java`.
