How to suppress warnings when i use java's class


#1

Hi ! I’m new here.

I’am using JPA in KOTLIN. In code below I have to use java.lang.Long

        @Suppress("I HATE THIS WARNING!!!")
        val count: Long = entityManager.createQuery(qlForCount, java.lang.Long::class.java)
                .setParameter("x", x)
                .setParameter("y", y)
                .setParameter("xd", xd)
                .setParameter("yd", yd)
                .singleResult
                .toLong()

I’d love to suppress the warning, but i do NOT kown correct name of @Suppress what i shoud use.

Is some doc can help ?

Thank you.


#2

I found it by IDEA.

jetbrains’s doc here.

        @Suppress("PLATFORM_CLASS_MAPPED_TO_KOTLIN")
        val count: kotlin.Long = entityManager.createQuery(qlForCount, java.lang.Long::class.java)
                .setParameter("x", x)
                .setParameter("y", y)
                .setParameter("xd", xd)
                .setParameter("yd", yd)
                .singleResult
                .toLong()

#3

You can use Long::class.javaObjectType instead of java.lang.Long::class.java, then you get no warnings.


#4

Thank you very much. Sir