Valeriy K.
Valeriy K.

Reputation: 2904

Local final class <no name provided> issue for throwable: Class<out Throwable> in Kotlin

I have some problems when trying to migrate my java methods to project with kotlin. I have a method with next signature:

public static RetryTemplate getRetryTemplate(long initialInterval, int maxAttempts, Class<? extends Throwable> throwable) { .... }

or in Kotlin:

fun getRetryTemplate(initialInterval: Long, maxAttempts: Int, throwable: Class<out Throwable>): RetryTemplate? {

When I'm trying to call this method in Kotlin code I get a compiler issue - Local final class no name provided (see screenshot)

RetryUtils.getRetryTemplate(5000, 3, Exception.class)

enter image description here

How to fix it?

Upvotes: 1

Views: 2107

Answers (1)

Valeriy K.
Valeriy K.

Reputation: 2904

It is required to use Exception::class.java

why Intellij not recommended this solution?

Upvotes: 2

Related Questions