Extend the java API with a method to unwrap Optional
:
fun <T> Optional<T>.unwrap(): T? = orElse(null)
Then use it like you wanted:
val msg: Something? = optional.unwrap() // the type is enforced
See https://kotlinlang.org/docs/reference/extensions.html for details.