Why are exceptions from JDK type aliased?


Why are type aliases for JDK types like IllegalArgumentException provided by Kotlin? The name is the same, there is no type parameter set – so what is the benefit of these aliases?


There are a few benefits as far as I can tell. One is that kotlin.* is one of the automatically imported packages, therefor giving you access to those exceptions without importing them. The other reason I can think of is multi-platform. Having the type alias allows mapping the exceptions to the JVM version and still allowing the use of them on JS or Native.


I agree with the second reason.

As to the imports - according to the documentation package ‘java.lang’, which contains most of the exception classes, is imported by default


Woops your right. Forgot about that :blush: