Using Java exception names


#1

Some time ago, for a TestNG test dealing with exception handling, I had the annotation:

  Test(expectedExceptions=arrayOf(javaClass<StackOverflowError>()))


which worked fine. However this now fails at compile time:

  Type inference failed. Expected type mismatch: found: kotlin.Array<java.lang.Class<java.lang.StackOverflowError>> required: kotlin.Array<kotlin.reflect.KClass<*>>

I clearly missed notification of a change, can anyone enlighten me?


#2

It's working fine for me, although when I used

@Test(expectedExceptions = arrayOf(RuntimeException::class))
I'm using 1230.

#3

Lucky you ;-) I always got the "Type inference failed." no matter what I tried in the way of rebuilding.

Fortunately though, your prompt that I should be using:

  Test(expectedExceptions = arrayOf(RuntimeException::class))

made everything work. This is with IntelliJ IDEA 14.1.4 and Kotlin 0.12.655.

Given that the new way works, I suspect I no longer care than the old way is problematic :slight_smile:

Thanks Cédric for that most useful interjection.  


#4

Might be due to the fact you're using 655 and not 1230?