https://kotlinlang.org logo
#announcements
Title
# announcements
x

Xavier F. Gouchet

12/04/2019, 11:00 AM
Hey folks, I know that Kotlin doesn't support checked exception in the language. But when calling a java method from a library, is there a way to at least get a warning in the IDE for java methods throwing checked java exceptions?
👍 1
s

Stephan Schroeder

12/04/2019, 11:19 AM
don’t think so. You should probably care equally much for “methods that used to be checked” and “methods that were unchecked all along”.
s

Sergei Dubrov [JB]

12/04/2019, 11:22 AM
It is a known Kotlin issue which is open for Language design. It is tracked here: https://youtrack.jetbrains.com/issue/KT-18276. https://youtrack.jetbrains.com/issue/KT-34519. Feel free to vote for the issues.)
x

Xavier F. Gouchet

12/04/2019, 12:20 PM
@Stephan Schroeder Dealing with unchecked exception is indeed part of our focus, but it'd be nice to at least have a warning when the exception is known to be thrown in the method signature. Problem with unchecked exception is that they're rarely documented, or thrown at a deeper level than what we can see from the libraries entry points.
Thanks @Sergei Dubrov [JB]
s

Stephan Schroeder

12/04/2019, 1:04 PM
hmm, I get why someone would want to opt into warnings, but I’m in team “I don’t want warnings as the default”, because that’s basically “checked exceptions light”. Complete, automated bytecode analysis should be able to give you a list of all exceptions that could be thrown in a specific method (at least for all classes that are available at compiletime). So maybe it’s available as 3rd-party-plugin??
x

Xavier F. Gouchet

12/04/2019, 1:06 PM
That would be nice to have indeed. My use case is that I'm building a library to be use by others, and I want to make sure their app won't crash because of an exception thrown via my library. I can easily know what excception I might thrown, but not what my (transitive) dependencies might throw