Reputation: 446
I am trying to port some code from Java to Kotlin and came across a line in Java as
CsrfConfigurer<HttpSecurity> csrfConfigurer = http.getConfigurer(CsrfConfigurer.class);
The method is from this class line 250
But when I translated it to Kotlin language
val csrfConfigurer: CsrfConfigurer<HttpSecurity> = http.getConfigurer(CsrfConfigurer::class.java)
Is this related to generics? How do I correct it?
Upvotes: 0
Views: 99
Reputation: 1384
Able to get this working with an explicit cast from the java class type to the class parameter type:
override fun configure(http: HttpSecurity) {
val csrfConfigurer: CsrfConfigurer<HttpSecurity> = http.getConfigurer(CsrfConfigurer::class.java as Class<CsrfConfigurer<HttpSecurity>>)
}
Upvotes: 2