Closed jakoss closed 1 year ago
At the moment it is still expected to call io.mcarle.konvert.api.Konverter.get<pl.test.data.weather.impl.WeatherMapper>().asOffsetDateTime(source = weather.time)
instead of this.asOffsetDateTime(source = weather.time)
. That will change in future, but for now OK.
Could you test if adding your classloader manually helps:
fun main() {
Konverter.addClassLoader(WeatherMapper::class.java.classLoader)
val result = Konverter.get<WeatherMapper>().asOffsetDateTime(LocalDateTime.now())
println(result)
}
This works:
Konverter.addClassLoader(WeatherMapper::class.java.classLoader!!)
val result = Konverter.get<WeatherMapper>()
val test = result.fromDto(weather.currentWeather)
val converted = weatherMapper.toDto(test)
println(converted)
Maybe this has something to do with android system class loader?
@jakoss I looked into that again and changed it a bit to always use the class loader of the requested interface class. It should work now. If not, please reopen again!
@mcarleio i still have the same error, but i think that just might be a simple error :D I think you are not using the classloader array you created:
...my fault, I fixed it... Thanks for the feedback :+1:
I have that for a test:
Generated code looks like this:
And when i try to call
toDto
i have exception:Seems like instead of doing
this.asOffsetDateTime
the generated code tries to lookup the mapper which is not registered yet