javaClass and IntelliJ


#1

I’m starting now to lear Kotlin and was trying to get my environment set up with IntelliJ ultimate, with some bolierplate code for logging.

package X

import java.util.logging.Logger
import kotlin.jvm.javaClass

class Route(id:String) {
    val logger = Logger.getLogger(javaClass<String>())
    init {
        logger.info("Customer initialized with value $id")
   }
}

when I use the code above, the IDE highlights javaClass as missing it and gives the hint to add the import of kotlin.jvm.javaClass that I do but still without much success.

I am using the project with Maven, Java 8, Intellij 2017.1 and include

    <dependency>
        <groupId>org.jetbrains.kotlin</groupId>
        <artifactId>kotlin-stdlib-jre8</artifactId>
        <version>${kotlin.version}</version>
    </dependency>
    <dependency>
        <groupId>org.jetbrains.kotlin</groupId>
        <artifactId>kotlin-test</artifactId>
        <version>${kotlin.version}</version>
        <scope>test</scope>
    </dependency>

as per documentation. (without the javaClass, I can compile and run program ok)
Still the popup suggesting to import kotlin.jvm.javaClass still pops um and once I click it is dismissed but continuing with the error.

Any idea what is not correct ?
Thanks


#2

This code uses javaClass function, which was deprecated and removed long time ago (before 1.0).
You can use String::class.java instead.


#3

Thanks. Guess I could report that there is some glitch on the UI IDE as it proposes to add it and fails silently to do it.