Sealed Interfaces and Sealed Classes Improvements
HTML-код
- Опубликовано: 18 сен 2024
- Join us for the Kotlin 1.5 Online Event! 👉 kotl.in/youtub...
The event will feature a live Q&A session with the Kotlin team.
🗓 May 25, 2021 16:00 - 17:30 CEST
This video introduces the new sealed interfaces functionality in #Kotlin #1.5.0 and other improvements for sealed classes. It also touches on the topic of sealed classes support in the latest JVM versions, and how Kotlin will make use of it.
Find all the news for this release in this blog post kotl.in/1.5.0
Subscribe to our Twitter - / kotlin
This video is very nice and informative, and the speaker explains the information very well!
Can you please have different videos explaining , what is actually present in 1.5.0 and what will be done later?
Check out the 1.5.0 playlist on our channel.
What is the reason behind "permittedSubclasses" being available at runtime? Why does the JVM have to perform runtime checks to ensure that sealed classes / interfaces are not extended beyond their permissions? From my understanding, all of this could be checked at compile-time
I imagine it's to be able to make exhaustive 'is' checks by comparing the class to each element in the array. Mainly for objects created dynamically at runtime that the compiler wouldn't have access to
I think it used in Reflection 😺
There's probably a forwards compatibility story here too. Adding a new subclass to sealed class is a breaking change.
Also there can be 3rd party subclasses loaded by service loaders dynamically
In case of sealed interfaces, JVM has to protect implementing another such interfaces using Proxies. So runtime checks are necessary.
Как же ей трудно изъясняться на английском)
At least 2 people that dislike strong typing watched this video
Ага мы обновились и пришлось откатиться из-за kotkin-datetime :(
She musses terms up. There is no notion of library in Java nor Kotlin; compilation unit is just a .java file. This makes unclear what sealed interface declaration restrictions are.