{"id":401438,"date":"2024-06-29T15:51:25","date_gmt":"2024-06-29T15:51:25","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=401438"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=401438","title":{"rendered":"<span>Kotlin Null-Safety vs ClassLoader<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u041d\u0435\u0434\u0430\u0432\u043d\u043e \u044f \u043f\u0440\u043e\u0445\u043e\u0434\u0438\u043b \u0441\u043e\u0431\u0435\u0441\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0435 \u0438 \u043e\u0434\u043d\u0438\u043c \u0438\u0437 \u0432\u043e\u043f\u0440\u043e\u0441\u043e\u0432, \u0441\u0442\u0430\u043b \u0442\u0430\u043a\u043e\u0439 \u0437\u0430\u0433\u0430\u0434\u043e\u0447\u043d\u044b\u0439 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440: <br \/>&#171;\u0410 \u043a\u0430\u043a\u043e\u0435 \u0433\u043b\u0430\u0432\u043d\u043e\u0435 \u043f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u043e \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u0442\u0438\u043f\u043e\u0432 Kotlin \u043f\u0435\u0440\u0435\u0434 Java&#187;? <\/p>\n<p>\u0427\u0435\u0441\u0442\u043d\u043e \u0433\u043e\u0432\u043e\u0440\u044f, \u0432\u044b\u0434\u0435\u043b\u0438\u0442\u044c \u043a\u0430\u043a\u043e\u0435 \u043f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u043e \u0441\u0447\u0438\u0442\u0430\u043b\u043e\u0441\u044c \u0433\u043b\u0430\u0432\u043d\u044b\u043c, \u043e\u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c \u043d\u0435\u0440\u0430\u0437\u0440\u0435\u0448\u0438\u043c\u043e\u0439 \u0434\u043b\u044f \u043c\u0435\u043d\u044f \u0437\u0430\u0434\u0430\u0447\u0435\u0439: Nothing, \u043e\u0442\u0441\u0443\u0442\u0441\u0432\u0438\u0435 Wildcard \u0438 First-Class Functions \u0432\u043c\u0435\u0441\u0442\u043e Java-\u043a\u043e\u0441\u0442\u044b\u043b\u044f \u0441 Functional Interface (\u0438\u043c\u0435\u0435\u0442\u0441\u044f \u0432\u0432\u0438\u0434\u0443 8\u044f \u0432\u0435\u0440\u0441\u0438\u044f Java) \u043d\u0435 \u0437\u0430\u043d\u044f\u043b\u0438 \u043f\u0435\u0440\u0432\u044b\u0445 \u043c\u0435\u0441\u0442 \u0432 \u043b\u0438\u0447\u043d\u043e\u043c \u0442\u043e\u043f\u0435 \u0438\u043d\u0442\u0435\u0440\u0432\u044c\u044e\u0435\u0440\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u043d\u0435 \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0438\u043b\u0438 \u0443\u0433\u0430\u0434\u0430\u0442\u044c. <\/p>\n<p>\u041e\u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c \u0447\u0442\u043e \u0433\u043b\u0430\u0432\u043d\u043e\u0435 \u0432 Kotlin &#8212; \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043e\u0431\u044c\u044f\u0432\u0438\u0442\u044c Nullable Type \u0438 Null Safety \u043f\u043e\u0434\u0445\u043e\u0434 (\u0417\u0430\u043c\u0435\u0447\u0443, \u0447\u0442\u043e \u043f\u043e \u043c\u043e\u0435\u043c\u0443 \u043e\u043f\u044b\u0442\u0443 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0435 \u0438\u043b\u0438 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u0447\u043d\u044b\u0435 Optional \u0438\u043b\u0438 Maybe \u0440\u0435\u0448\u0430\u044e\u0442 \u044d\u0442\u0443 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443, \u0438 \u043f\u0438\u0448\u0443\u0442\u0441\u044f \u0437\u0430 10 \u043c\u0438\u043d\u0443\u0442 \u043d\u0430 Java 7. \u0410 \u0435\u0449\u0435 \u0435\u0441\u0442\u044c \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0438 Nullable, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0438\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c \u043f\u043e\u043b\u044f \u0432 \u0441ompile-time. \u041a\u043e\u0440\u043e\u0447\u0435, \u0435\u0441\u0442\u044c \u043c\u043d\u043e\u0433\u043e \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u0432 \u0437\u0430\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0434\u0435\u043b\u0430\u0442\u044c Null \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0432 plain Java. \u041d\u0443 \u0434\u0430 \u043b\u0430\u0434\u043d\u043e). <\/p>\n<p>\u041d\u043e \u0440\u0435\u0447\u044c \u043f\u043e\u0439\u0434\u0435\u0442 \u043d\u0435 \u043e \u0441\u0442\u0440\u0430\u043d\u043d\u044b\u0445 \u0432\u043e\u043f\u0440\u043e\u0441\u0430\u0445, \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0445 \u0441\u043e \u0432\u043a\u0443\u0441\u043e\u0432\u044b\u043c\u0438 \u043f\u0440\u0435\u0434\u043f\u043e\u0447\u0442\u0435\u043d\u0438\u044f\u043c\u0438 \u0438\u043d\u0442\u0435\u0440\u0432\u044c\u044e\u0435\u0440\u043e\u0432 \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0441\u0430\u0445\u0430\u0440\u0430. <br \/>\u0414\u0435\u043b\u043e \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e Null Safety \u0432 Kotlin \u043c\u043e\u0436\u043d\u043e \u0441\u043b\u043e\u043c\u0430\u0442\u044c, \u043f\u0440\u0438\u0442\u043e\u043c \u043d\u0435 \u0432\u044b\u0445\u043e\u0434\u044f \u0438\u0437 \u043f\u043e\u0434 \u0435\u0433\u043e \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0433\u043e \u043a\u0443\u043f\u043e\u043b\u0430 \u0432 \u0441\u0443\u0440\u043e\u0432\u044b\u0439 \u0434\u0438\u043a\u0438\u0439 \u043c\u0438\u0440 Java \u0438 Null-Referrences.<\/p>\n<p>\u041a\u0430\u043a? <\/p>\n<p><strong>Long story short:<\/strong> ClassLoader \u0432\u0435\u0434\u0435\u0442 \u0441\u0435\u0431\u044f \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u043f\u0440\u0438 \u043f\u043e\u043f\u044b\u0442\u043a\u0435 \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044c \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u043f\u043e\u043b\u044f \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u0432\u043d\u043e \u0441\u0441\u044b\u043b\u0430\u044e\u0449\u0438\u0435\u0441\u044f \u043d\u0430 \u043a\u043b\u0430\u0441\u0441\u044b \u0434\u0440\u0443\u0433-\u0434\u0440\u0443\u0433\u0430. <\/p>\n<p>\u041f\u043e\u0434 \u043a\u0430\u0442\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u043a\u043e\u0434\u0430 \u0438 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e\u0435 \u043e\u0431\u044a\u044f\u0441\u043d\u0435\u043d\u0438\u0435 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u043e\u043d \u043e\u0431\u043c\u0430\u043d\u044b\u0432\u0430\u0435\u0442 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u043d\u0430 Nullable. \u042f \u0438\u0441\u043a\u0440\u0435\u043d\u043d\u0435 \u043d\u0430\u0434\u0435\u044e\u0441\u044c \u0447\u0442\u043e \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u0437\u043d\u0430\u043d\u0438\u044f Java\/Kotlin \u0434\u043b\u044f \u0441\u0442\u0430\u0442\u044c\u0438 \u043d\u0435 \u043d\u0443\u0436\u043d\u044b &#8212; \u044f \u043e\u0431\u044a\u044f\u0441\u043d\u044e \u0432\u0441\u0435 \u0434\u0435\u0442\u0430\u043b\u0438 \u043d\u0430 \u0445\u043e\u0434\u0443, \u0438 \u0443\u043b\u043e\u0436\u0443 \u0440\u0430\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0435 \u0432 10 \u043c\u0438\u043d\u0443\u0442. <\/p>\n<p>\u041d\u0430\u0447\u043d\u0435\u043c.<\/p>\n<hr\/>\n<p>\u041d\u0435 \u0431\u0443\u0434\u0443 \u0442\u044f\u043d\u0443\u0442\u044c \u043a\u043e\u0442\u0430 \u0437\u0430 \u0445\u0432\u043e\u0441\u0442. \u0412\u043e\u0442 \u043a\u043e\u0434:<\/p>\n<pre><code class=\"kotlin\">class ClassToLoad1() {     val classToLoad2 = ClassToLoad1.classToLoad2      \/\/Creating single instance of object     companion object {         val classToLoad2 = ClassToLoad2()     } }  class ClassToLoad2() {     val classToLoad1 = ClassToLoad2.classToLoad1      companion object {         val classToLoad1 = ClassToLoad1()     } }   fun main() {     val check = ClassToLoad1()     val classToLoadRecurciveRef = check.classToLoad2.classToLoad1.classToLoad2     println(classToLoadRecurciveRef) \/\/null      classToLoadRecurciveRef.classToLoad1 \/\/Throws NPE }<\/code><\/pre>\n<p>\u041d\u0438 \u043e\u0434\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u0447\u043a\u0438 \u043a\u043e\u0434\u0430 \u043d\u0430 Java, \u043d\u0438 \u043e\u0434\u043d\u043e\u0433\u043e \u043f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u044f \u0438 NPE \u0432 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f.<\/p>\n<p>\u041f\u043e\u0447\u0435\u043c\u0443 \u0442\u0430\u043a? <\/p>\n<p>\u0420\u043e\u043a\u043e\u0432\u043e\u0435 \u0441\u0442\u0435\u0447\u0435\u043d\u0438\u0435 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u043e\u0431\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u0441\u0442\u0432: <br \/>\u0420\u0435\u043a\u0443\u0440\u0441\u0438\u0432\u043d\u0430\u044f \u0441\u0441\u044b\u043b\u043a\u0430, \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f, \u0438 \u043d\u0435 \u0441\u0430\u043c\u044b\u0439 \u044f\u0432\u043d\u044b\u0439 \u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u044f ClassLoader \u0432 JVM \u0432 \u0442\u0430\u043a\u0438\u0445 \u0441\u043b\u0443\u0447\u0430\u044fx. <\/p>\n<hr\/>\n<h2>\/\/\u0420\u0435\u043a\u0443\u0440\u0441\u0438\u0432\u043d\u044b\u0435 \u0441\u0441\u044b\u043b\u043a\u0438<\/h2>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043e\u0442\u0441\u0435\u0447\u0435\u043c \u043e\u0442 \u043d\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u0432\u0441\u0435, \u043a\u0440\u043e\u043c\u0435 \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u0432\u043d\u043e\u0439 \u0441\u0441\u044b\u043b\u043a\u0438 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u043d\u0430 \u0441\u0430\u043c\u0438\u0445 \u0441\u0435\u0431\u044f. <\/p>\n<p>\u0411\u0430\u0437\u043e\u0432\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 &#8212; \u044d\u0442\u043e \u043e\u0434\u0438\u043d \u043a\u043b\u0430\u0441\u0441, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0445\u043e\u0447\u0435\u0442 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0441\u0435\u0431\u044f \u0436\u0435 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0430. <\/p>\n<details class=\"spoiler\">\n<summary>\u0417\u0430\u0447\u0435\u043c \u0432\u043e\u043e\u0431\u0449\u0435 \u0442\u0430\u043a \u0434\u0435\u043b\u0430\u0442\u044c?<\/summary>\n<div class=\"spoiler__content\">\n<p>\u0421\u0430\u043c\u044b\u0439 \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u043d\u044b\u0439 \u043a\u0435\u0439\u0441, \u0433\u0434\u0435 \u0432\u044b \u0442\u0430\u043a\u0443\u044e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u0432\u0441\u0442\u0440\u0435\u0447\u0430\u043b\u0438 &#8212; \u044d\u0442\u043e Linked List (\u043a\u043e\u0442\u043e\u0440\u044b\u0439, \u043a\u0441\u0442\u0430\u0442\u0438, \u0442\u043e\u0436\u0435 \u043b\u044e\u0431\u044f\u0442 \u043d\u0430 \u0441\u043e\u0431\u0435\u0441\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u044f\u0445).<\/p>\n<p>\u041b\u044e\u0431\u0430\u044f \u0434\u0440\u0443\u0433\u0430\u044f \u0441\u0441\u044b\u043b\u043e\u0447\u043d\u0430\u044f \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u0434\u0430\u043d\u043d\u044b\u0445, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 Node \u0432 Tree, \u0442\u043e\u0436\u0435 \u0431\u0443\u0434\u0435\u0442 \u0441\u0441\u044b\u043b\u0430\u0442\u044c\u0441\u044f \u043d\u0430 \u0441\u0435\u0431\u044f \u0441\u0430\u043c\u0443. \u0418 \u0435\u0441\u043b\u0438 \u0432\u044b \u043e\u0447\u0435\u043d\u044c \u043b\u044e\u0431\u0438\u0442\u0435 \u043f\u0438\u0441\u0430\u0442\u044c \u0433\u0440\u0430\u0444\u044b, \u0432\u044b \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0441\u0442\u043e\u043b\u043a\u043d\u0435\u0442\u0435\u0441\u044c \u0441 \u0442\u0430\u043a\u0438\u043c \u043a\u043e\u0434\u043e\u043c \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e.<\/p>\n<\/div>\n<\/details>\n<pre><code class=\"kotlin\">class SelfClassLoad(val s: SelfClassLoad) \/\/ warning: Constructor has non-null self reference parameter <\/code><\/pre>\n<p>\u041e\u0433\u043e, \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u043f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u0435!<br \/>\u0418 \u043e\u043d\u043e \u0435\u0441\u0442\u044c \u043f\u043e \u0432\u043f\u043e\u043b\u043d\u0435 \u043f\u043e\u043d\u044f\u0442\u043d\u043e\u0439 \u043f\u0440\u0438\u0447\u0438\u043d\u0435 &#8212; \u0432\u044b \u043d\u0435 \u0441\u043c\u043e\u0436\u0435\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u043e\u0442 \u043a\u043b\u0430\u0441\u0441:<\/p>\n<pre><code class=\"kotlin\">class SelfClassLoad(val s: SelfClassLoad) \/\/ warning: Constructor has non-null self reference parameter  fun main() {     SelfClassLoad(         SelfClassLoad(             SelfClassLoad(                 SelfClassLoad(                     SelfClassLoad(                     \/\/No value passed for parameter 's'                     )                 )             )         )     ) }<\/code><\/pre>\n<p>\u0418\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0442\u0430\u043a-\u0436\u0435 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u043f\u0440\u0438\u043c\u0435\u0440: <\/p>\n<pre><code class=\"kotlin\">class SelfClassLoad(){     val s = SelfClassLoad() }  fun main() {     SelfClassLoad() \/\/Stackoverflow error } <\/code><\/pre>\n<p>\u041f\u043e \u043f\u043e\u043d\u044f\u0442\u043d\u044b\u043c \u043f\u0440\u0438\u0447\u0438\u043d\u0430\u043c, \u043c\u044b \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u043c StackOverflow &#8212; \u0431\u0435\u0441\u043a\u043e\u043d\u0435\u0447\u043d\u0430\u044f \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0441\u0435\u0431\u044f \u043a \u0434\u043e\u0431\u0440\u0443 \u043d\u0435 \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442. <\/p>\n<p>\u041d\u043e \u0431\u0443\u0434\u0435\u0442 \u043b\u0438 \u0443 \u043d\u0430\u0441 \u043f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u0435, \u0435\u0441\u043b\u0438 \u043c\u044b \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u0432\u043d\u0443\u044e \u0441\u0432\u044f\u0437\u043a\u0443 \u0438\u0437 \u0434\u0432\u0443\u0445 \u043a\u043b\u0430\u0441\u0441\u043e\u0432? <\/p>\n<pre><code class=\"kotlin\">class SelfClassLoad1(val s2: SelfClassLoad2) class SelfClassLoad2(val s1: SelfClassLoad1) \/\/No warnings<\/code><\/pre>\n<p>\u0422\u0430\u043a\u043e\u0439 \u043a\u0435\u0439\u0441 warning \u0443\u0436\u0435 \u043d\u0435 \u0432\u044b\u0434\u0430\u0435\u0442. <\/p>\n<details class=\"spoiler\">\n<summary>Issue \u043d\u0430 \u044d\u0442\u0443 \u0442\u0435\u043c\u0443 \u0443\u0436\u0435 \u0441\u043e\u0437\u0434\u0430\u043d: <\/summary>\n<div class=\"spoiler__content\">\n<p><a href=\"https:\/\/youtrack.jetbrains.com\/issue\/KTIJ-14263\" rel=\"noopener noreferrer nofollow\">https:\/\/youtrack.jetbrains.com\/issue\/KTIJ-14263<\/a><\/p>\n<\/div>\n<\/details>\n<p>\u0418 \u044d\u0442\u043e \u043f\u0435\u0440\u0432\u0430\u044f \u0441\u0442\u0443\u043f\u0435\u043d\u044c\u043a\u0430 \u043d\u0430 \u043f\u0443\u0442\u0438 \u043a \u043d\u0430\u0448\u0435\u043c\u0443 NPE.<\/p>\n<hr\/>\n<h2>\/\/\u0421\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f<\/h2>\n<p>\u0427\u0442\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0432 Kotlin \u043a\u043e\u0433\u0434\u0430 \u0432\u044b \u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0435 Companion Object? <\/p>\n<p>\u0415\u0441\u043b\u0438 \u0432\u044b \u043f\u044b\u0442\u0430\u043b\u0438\u0441\u044c \u0432\u044b\u0437\u0432\u0430\u0442\u044c \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0439 \u043a\u043e\u0434 \u0438\u0437 Java &#8212; \u0442\u043e \u0432\u044b \u0437\u043d\u0430\u0435\u0442\u0435 \u043e \u0442\u043e\u043c, \u0447\u0442\u043e \u0432 \u0432\u0430\u0448\u0435\u043c \u043a\u043b\u0430\u0441\u0441\u0435 \u0431\u0443\u0434\u0435\u0442 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u044c\u0441\u044f \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0431\u044a\u0435\u043a\u0442-\u043a\u043e\u043c\u043f\u0430\u043d\u044c\u043e\u043d. <\/p>\n<p>\u0415\u0441\u043b\u0438 \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0442\u044c \u0442\u0440\u0430\u043d\u0441\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c Kotlin \u0432 Java, \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0441\u044f \u0447\u0442\u043e-\u0442\u043e \u043f\u043e\u0434\u043e\u0431\u043d\u043e\u0435: <\/p>\n<pre><code class=\"java\">public final class ClassToLoad1 {     @NotNull     private static final ClassToLoad2 classToLoad2;     @NotNull     public static final Companion Companion; \/\/Here, it's \"static\"      @NotNull     public final ClassToLoad2 getClassToLoad2() {         return this.classToLoad2$1;     }      static {         Companion = new Companion(null);         classToLoad2 = new ClassToLoad2();      }      public static final class Companion {         @NotNull         public final ClassToLoad2 getClassToLoad2() {             return classToLoad2;         }          private Companion() {         }          public Companion(DefaultConstructorMarker $constructor_marker) {             this();         }     } } <\/code><\/pre>\n<p>\u041e\u043f\u044b\u0442\u043d\u044b\u0435 Java \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438 \u0443\u0436\u0435 \u043f\u043e\u043d\u044f\u043b\u0438 \u043a \u0447\u0435\u043c\u0443 \u0432\u0441\u0435 \u0438\u0434\u0435\u0442, (\u0435\u0441\u043b\u0438 \u043a\u043e\u043d\u0435\u0447\u043d\u043e \u043d\u0435 \u043f\u043e\u043d\u044f\u043b\u0438 \u0441 \u0441\u0430\u043c\u043e\u0433\u043e \u043d\u0430\u0447\u0430\u043b\u0430), \u0430 \u0434\u043b\u044f \u0448\u0438\u0440\u043e\u043a\u043e\u0439 \u0430\u0443\u0434\u0438\u0442\u043e\u0440\u0438\u0438 \u043e\u0441\u0442\u0430\u0432\u043b\u044e \u043f\u043e\u044f\u0441\u043d\u0435\u043d\u0438\u0435: <\/p>\n<p>\u041a\u043b\u044e\u0447\u0435\u0432\u043e\u0435 \u0441\u043b\u043e\u0432\u043e <strong><em>static<\/em><\/strong>, \u0434\u0435\u043b\u0430\u0435\u0442 \u0440\u043e\u0432\u043d\u043e \u0442\u043e, \u0447\u0442\u043e \u043e\u043d\u043e \u0433\u043b\u0430\u0441\u0438\u0442 &#8212; \u043e\u0431\u044a\u0435\u043a\u0442 \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u0441\u0442\u0430\u0442\u0438\u0447\u043d\u044b\u043c. \u0410 \u0432 \u043c\u0438\u0440\u0435 JVM \u044d\u0442\u043e \u0437\u043d\u0430\u0447\u0438\u0442, \u0447\u0442\u043e \u044d\u0442\u043e\u0442 \u043e\u0431\u044a\u0435\u043a\u0442 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0432 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0439 \u043e\u0431\u043b\u0430\u0441\u0442\u0438 \u043f\u0430\u043c\u044f\u0442\u0438 &#8212; Permanent Generation Space.<\/p>\n<p>\u042d\u0442\u043e \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442 2 \u0432\u0435\u0449\u0438: <\/p>\n<p>1. \u041e\u0431\u044a\u0435\u043a\u0442 \u0432 static \u0431\u0443\u0434\u0435\u0442 \u0436\u0438\u0442\u044c \u043f\u043e\u043a\u0430 \u0436\u0438\u0432\u0430 \u0435\u0433\u043e JVM.<br \/>2. \u041e\u043d \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d (\u043f\u043e\u043b\u043e\u0436\u0435\u043d \u0432 PermGen) 1 \u0440\u0430\u0437. <em>(\u0414\u0430, \u0434\u0430 \u0435\u0441\u0442\u044c \u043a\u0435\u0439\u0441\u044b \u043a\u043e\u0433\u0434\u0430 \u044d\u0442\u043e \u043d\u0435 \u043f\u0440\u0430\u0432\u0434\u0430, \u044d\u0442\u043e \u043d\u0430 \u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 Out of Scope)<\/em><\/p>\n<details class=\"spoiler\">\n<summary>\u0414\u043b\u044f \u0442\u0435\u0445, \u043a\u0442\u043e \u0432\u0441\u043f\u043e\u043c\u043d\u0438\u043b \u043f\u0440\u043e \u0441\u0438\u043d\u0433\u043b\u0442\u043e\u043d\u044b:<\/summary>\n<div class=\"spoiler__content\">\n<p>\u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0432\u044b \u0441\u0435\u0439\u0447\u0430\u0441 \u043f\u043e\u0434\u0443\u043c\u0430\u043b\u0438 \u0447\u0442\u043e-\u0442\u043e \u0432\u0440\u043e\u0434\u0435 &#171;\u0410 \u0437\u0430\u0447\u0435\u043c \u0442\u043e\u0433\u0434\u0430 \u043d\u0443\u0436\u0435\u043d \u0441\u043b\u043e\u0436\u043d\u044b\u0439 \u0441\u0438\u043d\u0433\u043b\u0442\u043e\u043d \u0441 Syncronized \u0435\u0441\u043b\u0438 static&#8217;a \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e?&#187;.<\/p>\n<p>\u041e\u0442\u0432\u0435\u0442: \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0430\u0446\u0438\u044f, \u0438 \u043f\u0440\u043e\u0447\u0438\u0435 \u0442\u0435\u0445\u043d\u0438\u043a\u0438 \u043d\u0443\u0436\u043d\u044b \u043a\u043e\u0433\u0434\u0430 \u0432\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u0438\u043d\u0433\u043b\u0442\u043e\u043d \u043e\u0442\u043b\u043e\u0436\u0435\u043d\u043d\u043e.<\/p>\n<pre><code class=\"java\">class Singleton1{      public final static Singleton1 singleton = new Singleton1()  } \/\/Warranty to be single time initialized, but will init on class init.<\/code><\/pre>\n<pre><code class=\"java\">class Singleton2{     private static Singleton2 singleton;          public static void getSingleton(){ if(singleton == null)         singleton = new Singleton2()         return singleton;     } } \/\/Late init but no warranty of single init in concurrent case.<\/code><\/pre>\n<p>\u0415\u0441\u043b\u0438 \u0443 \u0432\u0430\u0441 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u043e\u0431\u044a\u0435\u043a\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u043e\u0436\u043d\u043e \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u0440\u0430\u0437\u0443 &#8212; \u0442\u043e \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c Singleton1. <\/p>\n<p>Singleton2 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0435\u0441\u043b\u0438 \u0432\u044b \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u0443\u0435\u0442\u0435 \u0432\u044b\u0437\u043e\u0432 \u0435\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0430 get \u0438\u0437 \u043e\u0434\u043d\u043e\u0433\u043e \u043f\u043e\u0442\u043e\u043a\u0430 \u0432\u0441\u0435\u0433\u0434\u0430. \u0412 \u043f\u0440\u043e\u0442\u0438\u0432\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 &#8212; \u043e\u043d \u043d\u0435\u0432\u0435\u0440\u0435\u043d, \u043d\u043e \u044d\u0442\u043e \u0432\u044b\u0445\u043e\u0434\u0438\u0442 \u0437\u0430 \u0440\u0430\u043c\u043a\u0438 \u043e\u0431\u0441\u0443\u0436\u0434\u0435\u043d\u0438\u044f. \u041d\u043e \u0432\u043e\u0442 \u043d\u0435\u043f\u043b\u043e\u0445\u043e\u0439 \u043f\u043e\u0441\u0442 \u043d\u0430 \u044d\u0442\u0443 \u0442\u0435\u043c\u0443: <a href=\"https:\/\/habr.com\/ru\/post\/27108\/\" rel=\"noopener noreferrer nofollow\">https:\/\/habr.com\/ru\/post\/27108\/<\/a><\/p>\n<\/div>\n<\/details>\n<p>\u041d\u0430\u0441 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u0435\u0442 \u0432\u0442\u043e\u0440\u043e\u0439 \u043d\u044e\u0430\u043d\u0441. \u0418\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0438\u0434\u0435\u0442 1 \u0440\u0430\u0437, \u0430 \u043c\u044b \u0442\u0443\u0442 \u0441\u043e\u0437\u0434\u0430\u043b\u0438 2 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0441 \u043f\u0435\u0440\u0435\u043a\u0440\u0435\u0441\u0442\u043d\u044b\u043c\u0438 \u0441\u0441\u044b\u043b\u043a\u0430\u043c\u0438 \u0434\u0440\u0443\u0433 \u043d\u0430 \u0434\u0440\u0443\u0433\u0430. <\/p>\n<p>\u041a\u0430\u043a \u043f\u043e\u0432\u0435\u0434\u0435\u0442 \u0441\u0435\u0431\u044f JVM \u0432 \u0442\u0430\u043a\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435? <\/p>\n<hr\/>\n<h2>\/\/Classloader<\/h2>\n<p>\u0418\u0442\u0430\u043a, \u043c\u044b \u043f\u0440\u0438\u0448\u043b\u0438 \u043a \u043d\u0438\u0436\u043d\u0435\u043c\u0443 \u0443\u0440\u043e\u0432\u043d\u044e &#8212; \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0435 \u043a\u043b\u0430\u0441\u0441\u0430. \u041a\u043e\u0433\u0434\u0430 \u043c\u044b \u043f\u0435\u0440\u0432\u044b\u0439 \u0440\u0430\u0437 \u043f\u044b\u0442\u0430\u0435\u043c\u0441\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043a\u043b\u0430\u0441\u0441 &#8212; JVM \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u0442 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u043a\u043b\u0430\u0441\u0441\u0435 (\u0432 \u0442\u043e\u043c \u0447\u0438\u0441\u043b\u0435 \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0443\u044e) \u0432 PermGen, \u0430 \u0437\u0430\u0442\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0435\u0435 \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u043e\u0432 \u043a\u043b\u0430\u0441\u0441\u0430. <\/p>\n<p>\u0427\u0442\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u0432\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0441\u0441\u044b\u043b\u043a\u0438? <\/p>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0442\u0430\u043a\u0430\u044f \u0446\u0435\u043f\u043e\u0447\u043a\u0430: <\/p>\n<p>TryLoadClass1 -> LoadingClass1 -> FoundClass2InStatic -> TryLoadClass2 -> FoundClass1InStatic -> TryLoadClass1 -> AlreadyLoading, Null<\/p>\n<p>\u0418 \u0432 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043c Class1, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0435\u0441\u0442\u044c Class2, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 Null. <\/p>\n<p>\u041f\u043e\u0447\u0435\u043c\u0443 \u043e\u043d\u043e \u0442\u0430\u043a \u0441\u0435\u0431\u044f \u0432\u0435\u0434\u0435\u0442, \u0430 \u043d\u0435 \u043f\u0430\u0434\u0430\u0435\u0442 \u0441 Runtime Exception? <br \/>\u041c\u043e\u0435 \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u0435, \u0438 \u044d\u0442\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u0435 &#8212; \u0438\u0437-\u0437\u0430 \u043e\u0431\u0440\u0430\u0442\u043d\u043e\u0439 \u0441\u043e\u0432\u043c\u0435\u0441\u0442\u0438\u043c\u043e\u0441\u0442\u0438. \u0415\u0441\u043b\u0438 \u043c\u044b \u0438\u0441\u043f\u0440\u0430\u0432\u0438\u043c ClassLoader \u0438 \u0434\u0430\u0434\u0438\u043c \u0435\u043c\u0443 \u0443\u043f\u0430\u0441\u0442\u044c \u0432 \u044d\u0442\u043e\u043c \u043a\u0435\u0439\u0441\u0435 &#8212; \u0443 \u043d\u0430\u0441 \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u0432\u0430\u043b\u0438\u0442\u044c\u0441\u044f \u043e\u0433\u0440\u043e\u043c\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0441\u0435\u0440\u0432\u0435\u0440\u043e\u0432 \u043f\u0440\u043e\u0441\u0442\u043e \u0438\u0437-\u0437\u0430 \u0441\u043c\u0435\u043d\u044b \u0432\u0435\u0440\u0441\u0438\u0438 Java. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442 \u043d\u0430 \u0432\u044b\u0434\u0430\u0447\u0443 Null \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u0442\u0441\u044f \u043d\u0430 \u043f\u0440\u043e\u0442\u044f\u0436\u0435\u043d\u0438\u0438 \u0432\u0441\u0435\u0445 \u0432\u0435\u0440\u0441\u0438\u0439 \u0438 \u043e\u0441\u0442\u0430\u043d\u0435\u0442\u0441\u044f \u0442\u0430\u043c \u043d\u0430\u0432\u0441\u0435\u0433\u0434\u0430.<\/p>\n<p>\/\/Sidenote: \u0417\u0430\u0440\u0430\u043d\u0435\u0435 \u0434\u0443\u043c\u0430\u0439\u0442\u0435 \u043e \u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442\u0430\u0445, \u0435\u0441\u043b\u0438 \u0445\u043e\u0442\u0438\u0442\u0435 \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0447\u0442\u043e-\u0442\u043e \u043e\u0431\u0440\u0430\u0442\u043d\u043e \u0441\u043e\u0432\u043c\u0435\u0441\u0442\u0438\u043c\u043e\u0435.<\/p>\n<hr\/>\n<h2>\/\/Big Picture<\/h2>\n<p>\u0418\u0442\u0430\u043a, \u0432\u0441\u044f \u0446\u0435\u043f\u043e\u0447\u043a\u0430 \u0441\u043e\u0431\u044b\u0442\u0438\u0439: <\/p>\n<ul>\n<li>\n<p>\u041c\u044b \u043f\u0438\u0448\u0435\u043c \u043a\u043e\u0434 \u043d\u0430 Kotlin \u0441 \u0446\u0438\u043a\u043b\u0438\u0447\u0435\u0441\u043a\u043e\u0439\/\u0440\u0435\u043a\u0443\u0440\u0441\u0438\u0432\u043d\u043e\u0439 \u0441\u0441\u044b\u043b\u043a\u043e\u0439 \u0434\u0432\u0443\u0445 \u0438 \u0438 \u0431\u043e\u043b\u0435\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u0441\u0430\u043c\u0438\u0445 \u043d\u0430 \u0441\u0435\u0431\u044f \u0432 \u0431\u043b\u043e\u043a\u0435 \u0441 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0435\u0439. \u0410\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440 &#8212; \u043c\u043e\u043b\u0447\u0438\u0442. <\/p>\n<\/li>\n<li>\n<p>Kotlin \u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0432 java bytecode \u0438 \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u0442 \u0432 \u0447\u0443\u0434\u0435\u0441\u043d\u044b\u0439 \u043c\u0438\u0440 JVM \u0438 Null.<\/p>\n<\/li>\n<li>\n<p>\u0411\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043a\u043b\u0430\u0441\u0441\u044b \u0431\u0443\u0434\u0443\u0442 \u0437\u0430\u0433\u0440\u0443\u0436\u0435\u043d\u044b 1 \u0440\u0430\u0437, \u0438 \u043c\u044b \u043d\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u043c StackOverflow \u0432 Runtime, \u043a\u0430\u043a \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043e \u043d\u0438\u0445 \u0434\u043e\u0439\u0434\u0435\u043c.<\/p>\n<\/li>\n<li>\n<p>ClassLoader \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u0442 \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044c \u043a\u043b\u0430\u0441\u0441 \u0438 \u0431\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u0441\u0442\u0430\u0440\u043e\u043c\u0443, \u043d\u0435\u044f\u0432\u043d\u043e\u043c\u0443 \u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442\u0443 \u043d\u0430 \u0432\u043e\u0437\u0432\u0440\u0430\u0442 Null \u043f\u043e\u0441\u0442\u0430\u0432\u0438\u0442 null-refference \u0432 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 Class2 \u043f\u0440\u0438 \u043f\u043e\u043f\u044b\u0442\u043a\u0435 \u043e\u0431\u0440\u0430\u0442\u043d\u043e \u0441\u043e\u0441\u043b\u0430\u0442\u044c\u0441\u044f \u043d\u0430 Class1, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u0437\u0430\u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u0430\u043d \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0439 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0435\u0439, \u0432 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0435 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043a\u0430\u043a \u0440\u0430\u0437 \u0438 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f Class2. \u0421\u0445\u0435\u043c\u043a\u0430: <br \/>loading Class1 -> loading Class2 -> try load Class1 &#8212; result null<\/p>\n<\/li>\n<li>\n<p>\u0411\u0438\u043d\u0433\u043e, \u043c\u044b \u043f\u0440\u043e\u0432\u0435\u043b\u0438 \u0430\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440 \u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 Null \u0432 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0435, \u0433\u0434\u0435 Kotlin \u0435\u0433\u043e \u0441\u043e\u0432\u0435\u0440\u0448\u0435\u043d\u043d\u043e \u043d\u0435 \u0436\u0434\u0435\u0442.<\/p>\n<\/li>\n<li>\n<p>\u041d\u0430\u0441\u043b\u0430\u0436\u0434\u0430\u0435\u043c\u0441\u044f \u043d\u0430\u0448\u0438\u043c NPE<\/p>\n<\/li>\n<\/ul>\n<hr\/>\n<h2>\/\/\u041a\u0440\u0438\u0442\u0438\u043a\u0443\u0435\u0448\u044c &#8212; \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u0439<\/h2>\n<p>\u041d\u0443, \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e. \u041a\u0440\u0438\u0442\u0438\u043a\u043e\u0432\u0430\u0442\u044c \u0432\u0441\u0435 \u043c\u043e\u0433\u0443\u0442, \u0430 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0442\u043e \u043a\u0430\u043a\u043e\u0435?<\/p>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0434\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430, \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440 \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0442\u0430\u043a\u043e\u0439 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u0432 \u0434\u0440\u0443\u0433\u043e\u043c \u044f\u0437\u044b\u043a\u0435. <br \/>\u042f &#8212; \u043c\u043e\u0431\u0438\u043b\u044c\u043d\u044b\u0439 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043c\u043d\u0435 \u0431\u043b\u0438\u0437\u043e\u043a Swift:<\/p>\n<pre><code class=\"swift\">\/\/Won't compile enum RelationDirect{\/\/Error about recursive type declaration shown     case Blocks(RelationBT) } enum RelationBT{     case Reffers(RelationRevese) } enum RelationRevese{     case BlockedBy(RelationDirect) }<\/code><\/pre>\n<p>\u0422\u0430\u043a\u043e\u0439 \u043a\u043e\u0434 \u0432 \u0441\u0432\u0438\u0444\u0442\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u043d\u0435 \u0441\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u0443\u0435\u0442\u0441\u044f, \u0432\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u043c\u0435\u0442\u0438\u0442\u044c \u0435\u0433\u043e \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u043c \u043a\u043b\u044e\u0447\u0435\u0432\u044b\u043c \u0441\u043b\u043e\u0432\u043e\u043c <strong><em>indirect:<\/em><\/strong><\/p>\n<pre><code class=\"swift\">\/\/Compiles indirect enum RelationDirect{ \/\/No errors     case Blocks(RelationBT) } ...<\/code><\/pre>\n<p>\u041d\u043e \u0435\u0441\u0442\u044c \u043e\u0434\u043d\u0430 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 &#8212; \u0435\u0441\u043b\u0438 \u043c\u044b \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u043e\u0437\u044c\u043c\u0435\u043c \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0438\u0437 Swift &#8212; \u043c\u044b \u0441\u043b\u043e\u043c\u0430\u0435\u043c Backward Compatibility &#8212; \u043f\u0440\u0438 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0438 \u0447\u0430\u0441\u0442\u044c \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u0432 \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u043d\u0435\u0442 \u0441\u043e\u0431\u0438\u0440\u0430\u0442\u044c\u0441\u044f. <\/p>\n<p>\u041d\u0435\u043b\u044c\u0437\u044f \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u0437\u044f\u0442\u044c \u0438 \u0432\u0441\u0435 \u0441\u043b\u043e\u043c\u0430\u0442\u044c &#8212; \u044d\u0442\u043e \u043d\u0435 JVM Way. <\/p>\n<p>\u042f \u043f\u043e\u0434\u0443\u043c\u0430\u043b \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u043e\u0431 \u044d\u0442\u043e\u0439 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0435 (\u0446\u0435\u043b\u044b\u0445 45 \u043c\u0438\u043d\u0443\u0442), \u0438 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u043f\u0440\u0438\u0434\u0443\u043c\u0430\u043b \u0440\u0435\u0448\u0435\u043d\u0438\u0435. <\/p>\n<p>\u041c\u044b \u043d\u0435 \u043c\u043e\u0436\u0435\u043c \u0441\u043b\u043e\u043c\u0430\u0442\u044c \u0441\u0442\u0430\u0440\u044b\u0439 \u043a\u043e\u0434, \u043d\u043e \u043c\u043e\u0436\u0435\u043c \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0442\u0430\u043a, \u0447\u0442\u043e\u0431\u044b \u0432 \u0441\u0442\u0430\u0440\u043e\u043c \u043a\u043e\u0434\u0435 \u0432\u043e\u0437\u043d\u0438\u043a\u043b\u0438 Warnings (\u043f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u043e \u0442\u043e\u043c, \u043a\u0430\u043a \u043c\u043e\u0436\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c warning &#8212; \u0432 <a href=\"https:\/\/youtrack.jetbrains.com\/issue\/KTIJ-14263\" rel=\"noopener noreferrer nofollow\">\u0442\u0438\u043a\u0435\u0442\u0435<\/a>), \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u0441\u043e\u0432\u0435\u0442\u0443\u044e\u0442 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c keyword, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u043c\u0435\u0442\u0438\u0442 \u0434\u043b\u044f \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u0430 Kotlin \u044d\u0442\u043e\u0442 \u043a\u043b\u0430\u0441\u0441, \u043a\u0430\u043a \u0442\u0440\u0435\u0431\u0443\u044e\u0449\u0438\u0439 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438. \u042d\u0442\u043e \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0434\u043e\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435\u043c \u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442\u0430, \u0430 \u043d\u0435 \u0435\u0433\u043e \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435\u043c, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043d\u0435 \u043b\u043e\u043c\u0430\u0435\u0442 \u0441\u043e\u0432\u043c\u0435\u0441\u0442\u0438\u043c\u043e\u0441\u0442\u044c (\u043f\u043e \u043a\u0440\u0430\u0439\u043d\u0435\u0439 \u043c\u0435\u0440\u0435, \u043d\u0430 \u043f\u0435\u0440\u0432\u044b\u0439 \u0432\u0437\u0433\u043b\u044f\u0434).<\/p>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0442\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u0432 Java 1.1 \u0431\u044b\u043b\u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u044b final, \u0438 \u0442\u0430\u043a\u0438\u043c \u0436\u0435 \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 val \u0432 Kotlin: \u041c\u044b \u043d\u0435 \u0437\u0430\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 \u0431\u0440\u043e\u0441\u0430\u0442\u044c exception, \u0435\u0441\u043b\u0438 \u043c\u044b \u043c\u043e\u0434\u0438\u0444\u0438\u0446\u0438\u0440\u0443\u0435\u043c \u043b\u044e\u0431\u043e\u0435 \u043f\u043e\u043b\u0435. \u041d\u043e \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u043e\u043c\u0435\u0442\u0438\u0442\u044c \u043f\u043e\u043b\u0435, \u0438 \u043f\u043e\u043f\u0440\u043e\u0441\u0438\u0442\u044c \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 \u0431\u0440\u043e\u0441\u0438\u0442\u044c exception, \u0442\u043e\u0433\u0434\u0430 \u0438 \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u043e\u0433\u0434\u0430 \u043a\u043e\u0433\u0434\u0430 \u043e\u043d\u043e \u043f\u043e\u043c\u0435\u0447\u0435\u043d\u043e. \u041d\u0430 \u043c\u043e\u0439 \u0432\u043a\u0443\u0441, \u044d\u0442\u043e \u0434\u0430\u0436\u0435 \u0431\u043e\u043b\u0435\u0435 \u044d\u043b\u0435\u0433\u0430\u043d\u0442\u043d\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435, \u0447\u0435\u043c \u0442\u043e, \u0447\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0432 Swift. <\/p>\n<p>\u0412 \u043a\u043e\u0434\u0435 \u044d\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0442\u0430\u043a: <\/p>\n<p>Warning \u0431\u0435\u0437 keyword:<\/p>\n<pre><code class=\"kotlin\">\/\/Compiles with warning sealed class RelationDirect( val opposite: RelationReverseSealed ) { \/\/Warning - add selfref key to enable checks for self-refference in initializers     object Blocks : RelationDirectSealed(RelationReverseSealed.IsBlockedBy) }  sealed class RelationReverse( val opposite: RelationDirectSealed ) {      object IsBlockedBy : RelationReverseSealed(RelationDirectSealed.Blocks) } <\/code><\/pre>\n<p>\u0414\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 keyword, \u0442\u0435\u043f\u0435\u0440\u044c \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 \u0447\u0435\u043a\u0430\u0435\u0442 \u0438\u0435\u0440\u0430\u0440\u0445\u0438\u044e \u0438 \u043d\u0430\u0445\u043e\u0434\u0438\u0442 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443:<\/p>\n<pre><code class=\"kotlin\">\/\/Won't compile sealed selfref class RelationDirect(         val opposite: RelationReverseSealed ) { \/\/Error, initializer self reffrence detected     object Blocks : RelationDirectSealed(RelationReverseSealed.IsBlockedBy) }  sealed class RelationReverse(         val opposite: RelationDirectSealed ) {      object IsBlockedBy : RelationReverseSealed(RelationDirectSealed.Blocks) }<\/code><\/pre>\n<p>\u041d\u043e, \u044f \u043d\u0435 \u043f\u0440\u0435\u0442\u0435\u043d\u0434\u0443\u044e \u043d\u0430 \u0438\u0434\u0435\u0430\u043b\u044c\u043d\u044b\u0435 \u0437\u043d\u0430\u043d\u0438\u044f Kotlin \u0438 Java, JVM \u0438 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u043e\u0432 \u0438 \u0442\u0443\u0442 \u0431\u0443\u0434\u0435\u0442 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0435\u043d \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0439 \u043e\u0442 <a href=\"\/company\/jetbrains\" rel=\"noopener noreferrer nofollow\">JetBrains<\/a>. \u0411\u044b\u043b\u043e \u0431\u044b \u0437\u0434\u043e\u0440\u043e\u0432\u043e, \u0435\u0441\u043b\u0438 \u0431\u044b \u0432\u044b \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u043b\u0438 \u044d\u0442\u0443 \u0441\u0442\u0430\u0442\u044c\u044e. \u0418\u043b\u0438 \u043f\u043e\u043c\u043e\u0433\u043b\u0438 \u043f\u043e\u043f\u0440\u0430\u0432\u0438\u0442\u044c, \u0435\u0441\u043b\u0438 \u044f \u0433\u0434\u0435-\u0442\u043e \u043e\u0448\u0438\u0431\u0441\u044f \u0432 \u043e\u0431\u044a\u044f\u0441\u043d\u0435\u043d\u0438\u0438.<\/p>\n<hr\/>\n<p>\u041d\u0430\u043f\u043e\u0441\u043b\u0435\u0434\u043e\u043a, \u044f \u0431\u044b \u0445\u043e\u0442\u0435\u043b \u0441\u043a\u0430\u0437\u0430\u0442\u044c, \u0447\u0442\u043e \u044d\u0442\u043e \u043d\u0435 \u043f\u0435\u0440\u0432\u044b\u0439 \u043a\u0435\u0439\u0441 \u0432 \u043c\u043e\u0435\u0439 \u0436\u0438\u0437\u043d\u0438, \u043a\u043e\u0433\u0434\u0430 \u043c\u0435\u043d\u044f \u043f\u043e\u0434\u0432\u043e\u0434\u0438\u043b\u043e \u0438\u0437\u043b\u0438\u0448\u043d\u0435\u0435 \u0434\u043e\u0432\u0435\u0440\u0438\u0435 \u044f\u0437\u044b\u043a\u0443, \u0442\u0443\u043b\u0438\u043d\u0433\u0443 \u0438 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430\u043c. Singleton \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043d\u0435 \u043e\u0434\u0438\u043d, \u0435\u0441\u043b\u0438 \u0432\u044b \u0437\u0430\u0431\u044b\u043b\u0438 \u043f\u0440\u043e \u043e\u0434\u0438\u043d <a href=\"http:\/\/surguy.net\/articles\/communication-across-classloaders.xml\" rel=\"noopener noreferrer nofollow\">\u043d\u044e\u0430\u043d\u0441<\/a> \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0439 \u0441 ClassLoader. ConcurrentHashMap.computeIfAbsent &#8212; \u043c\u043e\u0436\u0435\u0442 <a href=\"https:\/\/www.programmersought.com\/article\/41891013805\/\" rel=\"noopener noreferrer nofollow\">\u043e\u043a\u0430\u0437\u0430\u0442\u044c\u0441\u044f<\/a> \u043c\u0435\u0441\u0442\u043e\u043c \u0433\u0434\u0435 \u0437\u0430\u0431\u043b\u043e\u043a\u0438\u0440\u0443\u044e\u0442\u0441\u044f \u0432\u0441\u0435 \u0442\u0440\u0435\u0434\u044b \u0432\u0430\u0448\u0435\u0433\u043e \u0441\u0435\u0440\u0432\u0435\u0440\u0430, \u0445\u043e\u0442\u044c \u043e\u043d \u0438 \u0441\u0447\u0438\u0442\u0430\u0435\u0442\u0441\u044f \u043f\u043e\u0442\u043e\u043a\u043e\u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u044b\u043c (\u0432 Java 8). \u0418 \u044d\u0442\u043e \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0435 production \u043a\u0435\u0439\u0441\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043d\u0435 \u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u0440\u0430\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u044c.<\/p>\n<p>\u041f\u043e\u043c\u0435\u043d\u044c\u0448\u0435 \u0434\u043e\u0432\u0435\u0440\u044f\u0439\u0442\u0435 \u0442\u0443\u043b\u0438\u043d\u0433\u0443 \u0438 embedded \u0444\u0438\u0447\u0430\u043c, \u0438 \u0432\u0441\u0435\u0433\u0434\u0430 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0439\u0442\u0435 \u0442\u0435\u0441\u0442\u044b. <\/p>\n<p>\u0410 \u0435\u0441\u043b\u0438 \u0443 \u0432\u0430\u0441 \u0435\u0441\u0442\u044c \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0435 \u043a\u0435\u0439\u0441\u044b \u0438\u0437 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0433\u043e \u043e\u043f\u044b\u0442\u0430, \u043a\u043e\u0433\u0434\u0430 \u043a\u0430\u043a\u0430\u044f-\u043d\u0438\u0431\u0443\u0434\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u0430\u044f \u0432 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443\/\u044f\u0437\u044b\u043a \u043e\u0442\u043a\u0430\u0437\u044b\u0432\u0430\u043b\u0430 \u043f\u0440\u0438 \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u043e\u0431\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u0441\u0442\u0432\u0430\u0445 &#8212; \u0431\u044b\u043b\u043e \u0431\u044b \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e \u0443\u0432\u0438\u0434\u0435\u0442\u044c \u044d\u0442\u0443 \u0438\u0441\u0442\u043e\u0440\u0438\u044e \u0432 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f\u0445. <\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/561962\/\"> https:\/\/habr.com\/ru\/articles\/561962\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u041d\u0435\u0434\u0430\u0432\u043d\u043e \u044f \u043f\u0440\u043e\u0445\u043e\u0434\u0438\u043b \u0441\u043e\u0431\u0435\u0441\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0435 \u0438 \u043e\u0434\u043d\u0438\u043c \u0438\u0437 \u0432\u043e\u043f\u0440\u043e\u0441\u043e\u0432, \u0441\u0442\u0430\u043b \u0442\u0430\u043a\u043e\u0439 \u0437\u0430\u0433\u0430\u0434\u043e\u0447\u043d\u044b\u0439 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440: <br \/>&#171;\u0410 \u043a\u0430\u043a\u043e\u0435 \u0433\u043b\u0430\u0432\u043d\u043e\u0435 \u043f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u043e \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u0442\u0438\u043f\u043e\u0432 Kotlin \u043f\u0435\u0440\u0435\u0434 Java&#187;? <\/p>\n<p>\u0427\u0435\u0441\u0442\u043d\u043e \u0433\u043e\u0432\u043e\u0440\u044f, \u0432\u044b\u0434\u0435\u043b\u0438\u0442\u044c \u043a\u0430\u043a\u043e\u0435 \u043f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u043e \u0441\u0447\u0438\u0442\u0430\u043b\u043e\u0441\u044c \u0433\u043b\u0430\u0432\u043d\u044b\u043c, \u043e\u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c \u043d\u0435\u0440\u0430\u0437\u0440\u0435\u0448\u0438\u043c\u043e\u0439 \u0434\u043b\u044f \u043c\u0435\u043d\u044f \u0437\u0430\u0434\u0430\u0447\u0435\u0439: Nothing, \u043e\u0442\u0441\u0443\u0442\u0441\u0432\u0438\u0435 Wildcard \u0438 First-Class Functions \u0432\u043c\u0435\u0441\u0442\u043e Java-\u043a\u043e\u0441\u0442\u044b\u043b\u044f \u0441 Functional Interface (\u0438\u043c\u0435\u0435\u0442\u0441\u044f \u0432\u0432\u0438\u0434\u0443 8\u044f \u0432\u0435\u0440\u0441\u0438\u044f Java) \u043d\u0435 \u0437\u0430\u043d\u044f\u043b\u0438 \u043f\u0435\u0440\u0432\u044b\u0445 \u043c\u0435\u0441\u0442 \u0432 \u043b\u0438\u0447\u043d\u043e\u043c \u0442\u043e\u043f\u0435 \u0438\u043d\u0442\u0435\u0440\u0432\u044c\u044e\u0435\u0440\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u043d\u0435 \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0438\u043b\u0438 \u0443\u0433\u0430\u0434\u0430\u0442\u044c. <\/p>\n<p>\u041e\u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c \u0447\u0442\u043e \u0433\u043b\u0430\u0432\u043d\u043e\u0435 \u0432 Kotlin &#8212; \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043e\u0431\u044c\u044f\u0432\u0438\u0442\u044c Nullable Type \u0438 Null Safety \u043f\u043e\u0434\u0445\u043e\u0434 (\u0417\u0430\u043c\u0435\u0447\u0443, \u0447\u0442\u043e \u043f\u043e \u043c\u043e\u0435\u043c\u0443 \u043e\u043f\u044b\u0442\u0443 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0435 \u0438\u043b\u0438 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u0447\u043d\u044b\u0435 Optional \u0438\u043b\u0438 Maybe \u0440\u0435\u0448\u0430\u044e\u0442 \u044d\u0442\u0443 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443, \u0438 \u043f\u0438\u0448\u0443\u0442\u0441\u044f \u0437\u0430 10 \u043c\u0438\u043d\u0443\u0442 \u043d\u0430 Java 7. \u0410 \u0435\u0449\u0435 \u0435\u0441\u0442\u044c \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0438 Nullable, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0438\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c \u043f\u043e\u043b\u044f \u0432 \u0441ompile-time. \u041a\u043e\u0440\u043e\u0447\u0435, \u0435\u0441\u0442\u044c \u043c\u043d\u043e\u0433\u043e \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u0432 \u0437\u0430\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0434\u0435\u043b\u0430\u0442\u044c Null \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0432 plain Java. \u041d\u0443 \u0434\u0430 \u043b\u0430\u0434\u043d\u043e). <\/p>\n<p>\u041d\u043e \u0440\u0435\u0447\u044c \u043f\u043e\u0439\u0434\u0435\u0442 \u043d\u0435 \u043e \u0441\u0442\u0440\u0430\u043d\u043d\u044b\u0445 \u0432\u043e\u043f\u0440\u043e\u0441\u0430\u0445, \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0445 \u0441\u043e \u0432\u043a\u0443\u0441\u043e\u0432\u044b\u043c\u0438 \u043f\u0440\u0435\u0434\u043f\u043e\u0447\u0442\u0435\u043d\u0438\u044f\u043c\u0438 \u0438\u043d\u0442\u0435\u0440\u0432\u044c\u044e\u0435\u0440\u043e\u0432 \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0441\u0430\u0445\u0430\u0440\u0430. <br \/>\u0414\u0435\u043b\u043e \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e Null Safety \u0432 Kotlin \u043c\u043e\u0436\u043d\u043e \u0441\u043b\u043e\u043c\u0430\u0442\u044c, \u043f\u0440\u0438\u0442\u043e\u043c \u043d\u0435 \u0432\u044b\u0445\u043e\u0434\u044f \u0438\u0437 \u043f\u043e\u0434 \u0435\u0433\u043e \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0433\u043e \u043a\u0443\u043f\u043e\u043b\u0430 \u0432 \u0441\u0443\u0440\u043e\u0432\u044b\u0439 \u0434\u0438\u043a\u0438\u0439 \u043c\u0438\u0440 Java \u0438 Null-Referrences.<\/p>\n<p>\u041a\u0430\u043a? <\/p>\n<p><strong>Long story short:<\/strong> ClassLoader \u0432\u0435\u0434\u0435\u0442 \u0441\u0435\u0431\u044f \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u043f\u0440\u0438 \u043f\u043e\u043f\u044b\u0442\u043a\u0435 \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044c \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u043f\u043e\u043b\u044f \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u0432\u043d\u043e \u0441\u0441\u044b\u043b\u0430\u044e\u0449\u0438\u0435\u0441\u044f \u043d\u0430 \u043a\u043b\u0430\u0441\u0441\u044b \u0434\u0440\u0443\u0433-\u0434\u0440\u0443\u0433\u0430. <\/p>\n<p>\u041f\u043e\u0434 \u043a\u0430\u0442\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u043a\u043e\u0434\u0430 \u0438 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e\u0435 \u043e\u0431\u044a\u044f\u0441\u043d\u0435\u043d\u0438\u0435 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u043e\u043d \u043e\u0431\u043c\u0430\u043d\u044b\u0432\u0430\u0435\u0442 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u043d\u0430 Nullable. \u042f \u0438\u0441\u043a\u0440\u0435\u043d\u043d\u0435 \u043d\u0430\u0434\u0435\u044e\u0441\u044c \u0447\u0442\u043e \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u0437\u043d\u0430\u043d\u0438\u044f Java\/Kotlin \u0434\u043b\u044f \u0441\u0442\u0430\u0442\u044c\u0438 \u043d\u0435 \u043d\u0443\u0436\u043d\u044b &#8212; \u044f \u043e\u0431\u044a\u044f\u0441\u043d\u044e \u0432\u0441\u0435 \u0434\u0435\u0442\u0430\u043b\u0438 \u043d\u0430 \u0445\u043e\u0434\u0443, \u0438 \u0443\u043b\u043e\u0436\u0443 \u0440\u0430\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0435 \u0432 10 \u043c\u0438\u043d\u0443\u0442. <\/p>\n<p>\u041d\u0430\u0447\u043d\u0435\u043c.<\/p>\n<hr\/>\n<p>\u041d\u0435 \u0431\u0443\u0434\u0443 \u0442\u044f\u043d\u0443\u0442\u044c \u043a\u043e\u0442\u0430 \u0437\u0430 \u0445\u0432\u043e\u0441\u0442. \u0412\u043e\u0442 \u043a\u043e\u0434:<\/p>\n<pre><code class=\"kotlin\">class ClassToLoad1() {     val classToLoad2 = ClassToLoad1.classToLoad2      \/\/Creating single instance of object     companion object {         val classToLoad2 = ClassToLoad2()     } }  class ClassToLoad2() {     val classToLoad1 = ClassToLoad2.classToLoad1      companion object {         val classToLoad1 = ClassToLoad1()     } }   fun main() {     val check = ClassToLoad1()     val classToLoadRecurciveRef = check.classToLoad2.classToLoad1.classToLoad2     println(classToLoadRecurciveRef) \/\/null      classToLoadRecurciveRef.classToLoad1 \/\/Throws NPE }<\/code><\/pre>\n<p>\u041d\u0438 \u043e\u0434\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u0447\u043a\u0438 \u043a\u043e\u0434\u0430 \u043d\u0430 Java, \u043d\u0438 \u043e\u0434\u043d\u043e\u0433\u043e \u043f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u044f \u0438 NPE \u0432 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f.<\/p>\n<p>\u041f\u043e\u0447\u0435\u043c\u0443 \u0442\u0430\u043a? <\/p>\n<p>\u0420\u043e\u043a\u043e\u0432\u043e\u0435 \u0441\u0442\u0435\u0447\u0435\u043d\u0438\u0435 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u043e\u0431\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u0441\u0442\u0432: <br \/>\u0420\u0435\u043a\u0443\u0440\u0441\u0438\u0432\u043d\u0430\u044f \u0441\u0441\u044b\u043b\u043a\u0430, \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f, \u0438 \u043d\u0435 \u0441\u0430\u043c\u044b\u0439 \u044f\u0432\u043d\u044b\u0439 \u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u044f ClassLoader \u0432 JVM \u0432 \u0442\u0430\u043a\u0438\u0445 \u0441\u043b\u0443\u0447\u0430\u044fx. <\/p>\n<hr\/>\n<h2>\/\/\u0420\u0435\u043a\u0443\u0440\u0441\u0438\u0432\u043d\u044b\u0435 \u0441\u0441\u044b\u043b\u043a\u0438<\/h2>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043e\u0442\u0441\u0435\u0447\u0435\u043c \u043e\u0442 \u043d\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u0432\u0441\u0435, \u043a\u0440\u043e\u043c\u0435 \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u0432\u043d\u043e\u0439 \u0441\u0441\u044b\u043b\u043a\u0438 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u043d\u0430 \u0441\u0430\u043c\u0438\u0445 \u0441\u0435\u0431\u044f. <\/p>\n<p>\u0411\u0430\u0437\u043e\u0432\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 &#8212; \u044d\u0442\u043e \u043e\u0434\u0438\u043d \u043a\u043b\u0430\u0441\u0441, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0445\u043e\u0447\u0435\u0442 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0441\u0435\u0431\u044f \u0436\u0435 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0430. <\/p>\n<details class=\"spoiler\">\n<summary>\u0417\u0430\u0447\u0435\u043c \u0432\u043e\u043e\u0431\u0449\u0435 \u0442\u0430\u043a \u0434\u0435\u043b\u0430\u0442\u044c?<\/summary>\n<div class=\"spoiler__content\">\n<p>\u0421\u0430\u043c\u044b\u0439 \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u043d\u044b\u0439 \u043a\u0435\u0439\u0441, \u0433\u0434\u0435 \u0432\u044b \u0442\u0430\u043a\u0443\u044e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u0432\u0441\u0442\u0440\u0435\u0447\u0430\u043b\u0438 &#8212; \u044d\u0442\u043e Linked List (\u043a\u043e\u0442\u043e\u0440\u044b\u0439, \u043a\u0441\u0442\u0430\u0442\u0438, \u0442\u043e\u0436\u0435 \u043b\u044e\u0431\u044f\u0442 \u043d\u0430 \u0441\u043e\u0431\u0435\u0441\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u044f\u0445).<\/p>\n<p>\u041b\u044e\u0431\u0430\u044f \u0434\u0440\u0443\u0433\u0430\u044f \u0441\u0441\u044b\u043b\u043e\u0447\u043d\u0430\u044f \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u0434\u0430\u043d\u043d\u044b\u0445, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 Node \u0432 Tree, \u0442\u043e\u0436\u0435 \u0431\u0443\u0434\u0435\u0442 \u0441\u0441\u044b\u043b\u0430\u0442\u044c\u0441\u044f \u043d\u0430 \u0441\u0435\u0431\u044f \u0441\u0430\u043c\u0443. \u0418 \u0435\u0441\u043b\u0438 \u0432\u044b \u043e\u0447\u0435\u043d\u044c \u043b\u044e\u0431\u0438\u0442\u0435 \u043f\u0438\u0441\u0430\u0442\u044c \u0433\u0440\u0430\u0444\u044b, \u0432\u044b \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0441\u0442\u043e\u043b\u043a\u043d\u0435\u0442\u0435\u0441\u044c \u0441 \u0442\u0430\u043a\u0438\u043c \u043a\u043e\u0434\u043e\u043c \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e.<\/p>\n<\/div>\n<\/details>\n<pre><code class=\"kotlin\">class SelfClassLoad(val s: SelfClassLoad) \/\/ warning: Constructor has non-null self reference parameter <\/code><\/pre>\n<p>\u041e\u0433\u043e, \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u043f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u0435!<br \/>\u0418 \u043e\u043d\u043e \u0435\u0441\u0442\u044c \u043f\u043e \u0432\u043f\u043e\u043b\u043d\u0435 \u043f\u043e\u043d\u044f\u0442\u043d\u043e\u0439 \u043f\u0440\u0438\u0447\u0438\u043d\u0435 &#8212; \u0432\u044b \u043d\u0435 \u0441\u043c\u043e\u0436\u0435\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u043e\u0442 \u043a\u043b\u0430\u0441\u0441:<\/p>\n<pre><code class=\"kotlin\">class SelfClassLoad(val s: SelfClassLoad) \/\/ warning: Constructor has non-null self reference parameter  fun main() {     SelfClassLoad(         SelfClassLoad(             SelfClassLoad(                 SelfClassLoad(                     SelfClassLoad(                     \/\/No value passed for parameter 's'                     )                 )             )         )     ) }<\/code><\/pre>\n<p>\u0418\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0442\u0430\u043a-\u0436\u0435 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u043f\u0440\u0438\u043c\u0435\u0440: <\/p>\n<pre><code class=\"kotlin\">class SelfClassLoad(){     val s = SelfClassLoad() }  fun main() {     SelfClassLoad() \/\/Stackoverflow error } <\/code><\/pre>\n<p>\u041f\u043e \u043f\u043e\u043d\u044f\u0442\u043d\u044b\u043c \u043f\u0440\u0438\u0447\u0438\u043d\u0430\u043c, \u043c\u044b \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u043c StackOverflow &#8212; \u0431\u0435\u0441\u043a\u043e\u043d\u0435\u0447\u043d\u0430\u044f \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0441\u0435\u0431\u044f \u043a \u0434\u043e\u0431\u0440\u0443 \u043d\u0435 \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442. <\/p>\n<p>\u041d\u043e \u0431\u0443\u0434\u0435\u0442 \u043b\u0438 \u0443 \u043d\u0430\u0441 \u043f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u0435, \u0435\u0441\u043b\u0438 \u043c\u044b \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u0432\u043d\u0443\u044e \u0441\u0432\u044f\u0437\u043a\u0443 \u0438\u0437 \u0434\u0432\u0443\u0445 \u043a\u043b\u0430\u0441\u0441\u043e\u0432? <\/p>\n<pre><code class=\"kotlin\">class SelfClassLoad1(val s2: SelfClassLoad2) class SelfClassLoad2(val s1: SelfClassLoad1) \/\/No warnings<\/code><\/pre>\n<p>\u0422\u0430\u043a\u043e\u0439 \u043a\u0435\u0439\u0441 warning \u0443\u0436\u0435 \u043d\u0435 \u0432\u044b\u0434\u0430\u0435\u0442. <\/p>\n<details class=\"spoiler\">\n<summary>Issue \u043d\u0430 \u044d\u0442\u0443 \u0442\u0435\u043c\u0443 \u0443\u0436\u0435 \u0441\u043e\u0437\u0434\u0430\u043d: <\/summary>\n<div class=\"spoiler__content\">\n<p><a href=\"https:\/\/youtrack.jetbrains.com\/issue\/KTIJ-14263\" rel=\"noopener noreferrer nofollow\">https:\/\/youtrack.jetbrains.com\/issue\/KTIJ-14263<\/a><\/p>\n<\/div>\n<\/details>\n<p>\u0418 \u044d\u0442\u043e \u043f\u0435\u0440\u0432\u0430\u044f \u0441\u0442\u0443\u043f\u0435\u043d\u044c\u043a\u0430 \u043d\u0430 \u043f\u0443\u0442\u0438 \u043a \u043d\u0430\u0448\u0435\u043c\u0443 NPE.<\/p>\n<hr\/>\n<h2>\/\/\u0421\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f<\/h2>\n<p>\u0427\u0442\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0432 Kotlin \u043a\u043e\u0433\u0434\u0430 \u0432\u044b \u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0435 Companion Object? <\/p>\n<p>\u0415\u0441\u043b\u0438 \u0432\u044b \u043f\u044b\u0442\u0430\u043b\u0438\u0441\u044c \u0432\u044b\u0437\u0432\u0430\u0442\u044c \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0439 \u043a\u043e\u0434 \u0438\u0437 Java &#8212; \u0442\u043e \u0432\u044b \u0437\u043d\u0430\u0435\u0442\u0435 \u043e \u0442\u043e\u043c, \u0447\u0442\u043e \u0432 \u0432\u0430\u0448\u0435\u043c \u043a\u043b\u0430\u0441\u0441\u0435 \u0431\u0443\u0434\u0435\u0442 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u044c\u0441\u044f \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0431\u044a\u0435\u043a\u0442-\u043a\u043e\u043c\u043f\u0430\u043d\u044c\u043e\u043d. <\/p>\n<p>\u0415\u0441\u043b\u0438 \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0442\u044c \u0442\u0440\u0430\u043d\u0441\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c Kotlin \u0432 Java, \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0441\u044f \u0447\u0442\u043e-\u0442\u043e \u043f\u043e\u0434\u043e\u0431\u043d\u043e\u0435: <\/p>\n<pre><code class=\"java\">public final class ClassToLoad1 {     @NotNull     private static final ClassToLoad2 classToLoad2;     @NotNull     public static final Companion Companion; \/\/Here, it's \"static\"      @NotNull     public final ClassToLoad2 getClassToLoad2() {         return this.classToLoad2$1;     }      static {         Companion = new Companion(null);         classToLoad2 = new ClassToLoad2();      }      public static final class Companion {         @NotNull         public final ClassToLoad2 getClassToLoad2() {             return classToLoad2;         }          private Companion() {         }          public Companion(DefaultConstructorMarker $constructor_marker) {             this();         }     } } <\/code><\/pre>\n<p>\u041e\u043f\u044b\u0442\u043d\u044b\u0435 Java \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438 \u0443\u0436\u0435 \u043f\u043e\u043d\u044f\u043b\u0438 \u043a \u0447\u0435\u043c\u0443 \u0432\u0441\u0435 \u0438\u0434\u0435\u0442, (\u0435\u0441\u043b\u0438 \u043a\u043e\u043d\u0435\u0447\u043d\u043e \u043d\u0435 \u043f\u043e\u043d\u044f\u043b\u0438 \u0441 \u0441\u0430\u043c\u043e\u0433\u043e \u043d\u0430\u0447\u0430\u043b\u0430), \u0430 \u0434\u043b\u044f \u0448\u0438\u0440\u043e\u043a\u043e\u0439 \u0430\u0443\u0434\u0438\u0442\u043e\u0440\u0438\u0438 \u043e\u0441\u0442\u0430\u0432\u043b\u044e \u043f\u043e\u044f\u0441\u043d\u0435\u043d\u0438\u0435: <\/p>\n<p>\u041a\u043b\u044e\u0447\u0435\u0432\u043e\u0435 \u0441\u043b\u043e\u0432\u043e <strong><em>static<\/em><\/strong>, \u0434\u0435\u043b\u0430\u0435\u0442 \u0440\u043e\u0432\u043d\u043e \u0442\u043e, \u0447\u0442\u043e \u043e\u043d\u043e \u0433\u043b\u0430\u0441\u0438\u0442 &#8212; \u043e\u0431\u044a\u0435\u043a\u0442 \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u0441\u0442\u0430\u0442\u0438\u0447\u043d\u044b\u043c. \u0410 \u0432 \u043c\u0438\u0440\u0435 JVM \u044d\u0442\u043e \u0437\u043d\u0430\u0447\u0438\u0442, \u0447\u0442\u043e \u044d\u0442\u043e\u0442 \u043e\u0431\u044a\u0435\u043a\u0442 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0432 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0439 \u043e\u0431\u043b\u0430\u0441\u0442\u0438 \u043f\u0430\u043c\u044f\u0442\u0438 &#8212; Permanent Generation Space.<\/p>\n<p>\u042d\u0442\u043e \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442 2 \u0432\u0435\u0449\u0438: <\/p>\n<p>1. \u041e\u0431\u044a\u0435\u043a\u0442 \u0432 static \u0431\u0443\u0434\u0435\u0442 \u0436\u0438\u0442\u044c \u043f\u043e\u043a\u0430 \u0436\u0438\u0432\u0430 \u0435\u0433\u043e JVM.<br \/>2. \u041e\u043d \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d (\u043f\u043e\u043b\u043e\u0436\u0435\u043d \u0432 PermGen) 1 \u0440\u0430\u0437. <em>(\u0414\u0430, \u0434\u0430 \u0435\u0441\u0442\u044c \u043a\u0435\u0439\u0441\u044b \u043a\u043e\u0433\u0434\u0430 \u044d\u0442\u043e \u043d\u0435 \u043f\u0440\u0430\u0432\u0434\u0430, \u044d\u0442\u043e \u043d\u0430 \u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 Out of Scope)<\/em><\/p>\n<details class=\"spoiler\">\n<summary>\u0414\u043b\u044f \u0442\u0435\u0445, \u043a\u0442\u043e \u0432\u0441\u043f\u043e\u043c\u043d\u0438\u043b \u043f\u0440\u043e \u0441\u0438\u043d\u0433\u043b\u0442\u043e\u043d\u044b:<\/summary>\n<div class=\"spoiler__content\">\n<p>\u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0432\u044b \u0441\u0435\u0439\u0447\u0430\u0441 \u043f\u043e\u0434\u0443\u043c\u0430\u043b\u0438 \u0447\u0442\u043e-\u0442\u043e \u0432\u0440\u043e\u0434\u0435 &#171;\u0410 \u0437\u0430\u0447\u0435\u043c \u0442\u043e\u0433\u0434\u0430 \u043d\u0443\u0436\u0435\u043d \u0441\u043b\u043e\u0436\u043d\u044b\u0439 \u0441\u0438\u043d\u0433\u043b\u0442\u043e\u043d \u0441 Syncronized \u0435\u0441\u043b\u0438 static&#8217;a \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e?&#187;.<\/p>\n<p>\u041e\u0442\u0432\u0435\u0442: \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0430\u0446\u0438\u044f, \u0438 \u043f\u0440\u043e\u0447\u0438\u0435 \u0442\u0435\u0445\u043d\u0438\u043a\u0438 \u043d\u0443\u0436\u043d\u044b \u043a\u043e\u0433\u0434\u0430 \u0432\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u0438\u043d\u0433\u043b\u0442\u043e\u043d \u043e\u0442\u043b\u043e\u0436\u0435\u043d\u043d\u043e.<\/p>\n<pre><code class=\"java\">class Singleton1{      public final static Singleton1 singleton = new Singleton1()  } \/\/Warranty to be single time initialized, but will init on class init.<\/code><\/pre>\n<pre><code class=\"java\">class Singleton2{     private static Singleton2 singleton;          public static void getSingleton(){ if(singleton == null)         singleton = new Singleton2()         return singleton;     } } \/\/Late init but no warranty of single init in concurrent case.<\/code><\/pre>\n<p>\u0415\u0441\u043b\u0438 \u0443 \u0432\u0430\u0441 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u043e\u0431\u044a\u0435\u043a\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u043e\u0436\u043d\u043e \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u0440\u0430\u0437\u0443 &#8212; \u0442\u043e \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c Singleton1. <\/p>\n<p>Singleton2 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0435\u0441\u043b\u0438 \u0432\u044b \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u0443\u0435\u0442\u0435 \u0432\u044b\u0437\u043e\u0432 \u0435\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0430 get \u0438\u0437 \u043e\u0434\u043d\u043e\u0433\u043e \u043f\u043e\u0442\u043e\u043a\u0430 \u0432\u0441\u0435\u0433\u0434\u0430. \u0412 \u043f\u0440\u043e\u0442\u0438\u0432\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 &#8212; \u043e\u043d \u043d\u0435\u0432\u0435\u0440\u0435\u043d, \u043d\u043e \u044d\u0442\u043e \u0432\u044b\u0445\u043e\u0434\u0438\u0442 \u0437\u0430 \u0440\u0430\u043c\u043a\u0438 \u043e\u0431\u0441\u0443\u0436\u0434\u0435\u043d\u0438\u044f. \u041d\u043e \u0432\u043e\u0442 \u043d\u0435\u043f\u043b\u043e\u0445\u043e\u0439 \u043f\u043e\u0441\u0442 \u043d\u0430 \u044d\u0442\u0443 \u0442\u0435\u043c\u0443: <a href=\"https:\/\/habr.com\/ru\/post\/27108\/\" rel=\"noopener noreferrer nofollow\">https:\/\/habr.com\/ru\/post\/27108\/<\/a><\/p>\n<\/div>\n<\/details>\n<p>\u041d\u0430\u0441 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u0435\u0442 \u0432\u0442\u043e\u0440\u043e\u0439 \u043d\u044e\u0430\u043d\u0441. \u0418\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0438\u0434\u0435\u0442 1 \u0440\u0430\u0437, \u0430 \u043c\u044b \u0442\u0443\u0442 \u0441\u043e\u0437\u0434\u0430\u043b\u0438 2 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0441 \u043f\u0435\u0440\u0435\u043a\u0440\u0435\u0441\u0442\u043d\u044b\u043c\u0438 \u0441\u0441\u044b\u043b\u043a\u0430\u043c\u0438 \u0434\u0440\u0443\u0433 \u043d\u0430 \u0434\u0440\u0443\u0433\u0430. <\/p>\n<p>\u041a\u0430\u043a \u043f\u043e\u0432\u0435\u0434\u0435\u0442 \u0441\u0435\u0431\u044f JVM \u0432 \u0442\u0430\u043a\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435? <\/p>\n<hr\/>\n<h2>\/\/Classloader<\/h2>\n<p>\u0418\u0442\u0430\u043a, \u043c\u044b \u043f\u0440\u0438\u0448\u043b\u0438 \u043a \u043d\u0438\u0436\u043d\u0435\u043c\u0443 \u0443\u0440\u043e\u0432\u043d\u044e &#8212; \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0435 \u043a\u043b\u0430\u0441\u0441\u0430. \u041a\u043e\u0433\u0434\u0430 \u043c\u044b \u043f\u0435\u0440\u0432\u044b\u0439 \u0440\u0430\u0437 \u043f\u044b\u0442\u0430\u0435\u043c\u0441\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043a\u043b\u0430\u0441\u0441 &#8212; JVM \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u0442 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u043a\u043b\u0430\u0441\u0441\u0435 (\u0432 \u0442\u043e\u043c \u0447\u0438\u0441\u043b\u0435 \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0443\u044e) \u0432 PermGen, \u0430 \u0437\u0430\u0442\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0435\u0435 \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u043e\u0432 \u043a\u043b\u0430\u0441\u0441\u0430. <\/p>\n<p>\u0427\u0442\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u0432\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0441\u0441\u044b\u043b\u043a\u0438? <\/p>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0442\u0430\u043a\u0430\u044f \u0446\u0435\u043f\u043e\u0447\u043a\u0430: <\/p>\n<p>TryLoadClass1 -> LoadingClass1 -> FoundClass2InStatic -> TryLoadClass2 -> FoundClass1InStatic -> TryLoadClass1 -> AlreadyLoading, Null<\/p>\n<p>\u0418 \u0432 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043c Class1, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0435\u0441\u0442\u044c Class2, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 Null. <\/p>\n<p>\u041f\u043e\u0447\u0435\u043c\u0443 \u043e\u043d\u043e \u0442\u0430\u043a \u0441\u0435\u0431\u044f \u0432\u0435\u0434\u0435\u0442, \u0430 \u043d\u0435 \u043f\u0430\u0434\u0430\u0435\u0442 \u0441 Runtime Exception? <br \/>\u041c\u043e\u0435 \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u0435, \u0438 \u044d\u0442\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u0435 &#8212; \u0438\u0437-\u0437\u0430 \u043e\u0431\u0440\u0430\u0442\u043d\u043e\u0439 \u0441\u043e\u0432\u043c\u0435\u0441\u0442\u0438\u043c\u043e\u0441\u0442\u0438. \u0415\u0441\u043b\u0438 \u043c\u044b \u0438\u0441\u043f\u0440\u0430\u0432\u0438\u043c ClassLoader \u0438 \u0434\u0430\u0434\u0438\u043c \u0435\u043c\u0443 \u0443\u043f\u0430\u0441\u0442\u044c \u0432 \u044d\u0442\u043e\u043c \u043a\u0435\u0439\u0441\u0435 &#8212; \u0443 \u043d\u0430\u0441 \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u0432\u0430\u043b\u0438\u0442\u044c\u0441\u044f \u043e\u0433\u0440\u043e\u043c\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0441\u0435\u0440\u0432\u0435\u0440\u043e\u0432 \u043f\u0440\u043e\u0441\u0442\u043e \u0438\u0437-\u0437\u0430 \u0441\u043c\u0435\u043d\u044b \u0432\u0435\u0440\u0441\u0438\u0438 Java. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442 \u043d\u0430 \u0432\u044b\u0434\u0430\u0447\u0443 Null \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u0442\u0441\u044f \u043d\u0430 \u043f\u0440\u043e\u0442\u044f\u0436\u0435\u043d\u0438\u0438 \u0432\u0441\u0435\u0445 \u0432\u0435\u0440\u0441\u0438\u0439 \u0438 \u043e\u0441\u0442\u0430\u043d\u0435\u0442\u0441\u044f \u0442\u0430\u043c \u043d\u0430\u0432\u0441\u0435\u0433\u0434\u0430.<\/p>\n<p>\/\/Sidenote: \u0417\u0430\u0440\u0430\u043d\u0435\u0435 \u0434\u0443\u043c\u0430\u0439\u0442\u0435 \u043e \u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442\u0430\u0445, \u0435\u0441\u043b\u0438 \u0445\u043e\u0442\u0438\u0442\u0435 \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0447\u0442\u043e-\u0442\u043e \u043e\u0431\u0440\u0430\u0442\u043d\u043e \u0441\u043e\u0432\u043c\u0435\u0441\u0442\u0438\u043c\u043e\u0435.<\/p>\n<hr\/>\n<h2>\/\/Big Picture<\/h2>\n<p>\u0418\u0442\u0430\u043a, \u0432\u0441\u044f \u0446\u0435\u043f\u043e\u0447\u043a\u0430 \u0441\u043e\u0431\u044b\u0442\u0438\u0439: <\/p>\n<ul>\n<li>\n<p>\u041c\u044b \u043f\u0438\u0448\u0435\u043c \u043a\u043e\u0434 \u043d\u0430 Kotlin \u0441 \u0446\u0438\u043a\u043b\u0438\u0447\u0435\u0441\u043a\u043e\u0439\/\u0440\u0435\u043a\u0443\u0440\u0441\u0438\u0432\u043d\u043e\u0439 \u0441\u0441\u044b\u043b\u043a\u043e\u0439 \u0434\u0432\u0443\u0445 \u0438 \u0438 \u0431\u043e\u043b\u0435\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u0441\u0430\u043c\u0438\u0445 \u043d\u0430 \u0441\u0435\u0431\u044f \u0432 \u0431\u043b\u043e\u043a\u0435 \u0441 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0435\u0439. \u0410\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440 &#8212; \u043c\u043e\u043b\u0447\u0438\u0442. <\/p>\n<\/li>\n<li>\n<p>Kotlin \u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0432 java bytecode \u0438 \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u0442 \u0432 \u0447\u0443\u0434\u0435\u0441\u043d\u044b\u0439 \u043c\u0438\u0440 JVM \u0438 Null.<\/p>\n<\/li>\n<li>\n<p>\u0411\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043a\u043b\u0430\u0441\u0441\u044b \u0431\u0443\u0434\u0443\u0442 \u0437\u0430\u0433\u0440\u0443\u0436\u0435\u043d\u044b 1 \u0440\u0430\u0437, \u0438 \u043c\u044b \u043d\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u043c StackOverflow \u0432 Runtime, \u043a\u0430\u043a \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043e \u043d\u0438\u0445 \u0434\u043e\u0439\u0434\u0435\u043c.<\/p>\n<\/li>\n<li>\n<p>ClassLoader \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u0442 \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044c \u043a\u043b\u0430\u0441\u0441 \u0438 \u0431\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u0441\u0442\u0430\u0440\u043e\u043c\u0443, \u043d\u0435\u044f\u0432\u043d\u043e\u043c\u0443 \u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442\u0443 \u043d\u0430 \u0432\u043e\u0437\u0432\u0440\u0430\u0442 Null \u043f\u043e\u0441\u0442\u0430\u0432\u0438\u0442 null-refference \u0432 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 Class2 \u043f\u0440\u0438 \u043f\u043e\u043f\u044b\u0442\u043a\u0435 \u043e\u0431\u0440\u0430\u0442\u043d\u043e \u0441\u043e\u0441\u043b\u0430\u0442\u044c\u0441\u044f \u043d\u0430 Class1, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u0437\u0430\u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u0430\u043d \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0439 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0435\u0439, \u0432 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0435 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043a\u0430\u043a \u0440\u0430\u0437 \u0438 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f Class2. \u0421\u0445\u0435\u043c\u043a\u0430: <br \/>loading Class1 -> loading Class2 -> try load Class1 &#8212; result null<\/p>\n<\/li>\n<li>\n<p>\u0411\u0438\u043d\u0433\u043e, \u043c\u044b \u043f\u0440\u043e\u0432\u0435\u043b\u0438 \u0430\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440 \u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 Null \u0432 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0435, \u0433\u0434\u0435 Kotlin \u0435\u0433\u043e \u0441\u043e\u0432\u0435\u0440\u0448\u0435\u043d\u043d\u043e \u043d\u0435 \u0436\u0434\u0435\u0442.<\/p>\n<\/li>\n<li>\n<p>\u041d\u0430\u0441\u043b\u0430\u0436\u0434\u0430\u0435\u043c\u0441\u044f \u043d\u0430\u0448\u0438\u043c NPE<\/p>\n<\/li>\n<\/ul>\n<hr\/>\n<h2>\/\/\u041a\u0440\u0438\u0442\u0438\u043a\u0443\u0435\u0448\u044c &#8212; \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u0439<\/h2>\n<p>\u041d\u0443, \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e. \u041a\u0440\u0438\u0442\u0438\u043a\u043e\u0432\u0430\u0442\u044c \u0432\u0441\u0435 \u043c\u043e\u0433\u0443\u0442, \u0430 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0442\u043e \u043a\u0430\u043a\u043e\u0435?<\/p>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0434\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430, \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440 \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0442\u0430\u043a\u043e\u0439 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u0432 \u0434\u0440\u0443\u0433\u043e\u043c \u044f\u0437\u044b\u043a\u0435. <br \/>\u042f &#8212; \u043c\u043e\u0431\u0438\u043b\u044c\u043d\u044b\u0439 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043c\u043d\u0435 \u0431\u043b\u0438\u0437\u043e\u043a Swift:<\/p>\n<pre><code class=\"swift\">\/\/Won't compile enum RelationDirect{\/\/Error about recursive type declaration shown     case Blocks(RelationBT) } enum RelationBT{     case Reffers(RelationRevese) } enum RelationRevese{     case BlockedBy(RelationDirect) }<\/code><\/pre>\n<p>\u0422\u0430\u043a\u043e\u0439 \u043a\u043e\u0434 \u0432 \u0441\u0432\u0438\u0444\u0442\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u043d\u0435 \u0441\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u0443\u0435\u0442\u0441\u044f, \u0432\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u043c\u0435\u0442\u0438\u0442\u044c \u0435\u0433\u043e \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u043c \u043a\u043b\u044e\u0447\u0435\u0432\u044b\u043c \u0441\u043b\u043e\u0432\u043e\u043c <strong><em>indirect:<\/em><\/strong><\/p>\n<pre><code class=\"swift\">\/\/Compiles indirect enum RelationDirect{ \/\/No errors     case Blocks(RelationBT) } ...<\/code><\/pre>\n<p>\u041d\u043e \u0435\u0441\u0442\u044c \u043e\u0434\u043d\u0430 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 &#8212; \u0435\u0441\u043b\u0438 \u043c\u044b \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u043e\u0437\u044c\u043c\u0435\u043c \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0438\u0437 Swift &#8212; \u043c\u044b \u0441\u043b\u043e\u043c\u0430\u0435\u043c Backward Compatibility &#8212; \u043f\u0440\u0438 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0438 \u0447\u0430\u0441\u0442\u044c \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u0432 \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u043d\u0435\u0442 \u0441\u043e\u0431\u0438\u0440\u0430\u0442\u044c\u0441\u044f. <\/p>\n<p>\u041d\u0435\u043b\u044c\u0437\u044f \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u0437\u044f\u0442\u044c \u0438 \u0432\u0441\u0435 \u0441\u043b\u043e\u043c\u0430\u0442\u044c &#8212; \u044d\u0442\u043e \u043d\u0435 JVM Way. <\/p>\n<p>\u042f \u043f\u043e\u0434\u0443\u043c\u0430\u043b \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u043e\u0431 \u044d\u0442\u043e\u0439 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0435 (\u0446\u0435\u043b\u044b\u0445 45 \u043c\u0438\u043d\u0443\u0442), \u0438 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u043f\u0440\u0438\u0434\u0443\u043c\u0430\u043b \u0440\u0435\u0448\u0435\u043d\u0438\u0435. <\/p>\n<p>\u041c\u044b \u043d\u0435 \u043c\u043e\u0436\u0435\u043c \u0441\u043b\u043e\u043c\u0430\u0442\u044c \u0441\u0442\u0430\u0440\u044b\u0439 \u043a\u043e\u0434, \u043d\u043e \u043c\u043e\u0436\u0435\u043c \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0442\u0430\u043a, \u0447\u0442\u043e\u0431\u044b \u0432 \u0441\u0442\u0430\u0440\u043e\u043c \u043a\u043e\u0434\u0435 \u0432\u043e\u0437\u043d\u0438\u043a\u043b\u0438 Warnings (\u043f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u043e \u0442\u043e\u043c, \u043a\u0430\u043a \u043c\u043e\u0436\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c warning &#8212; \u0432 <a href=\"https:\/\/youtrack.jetbrains.com\/issue\/KTIJ-14263\" rel=\"noopener noreferrer nofollow\">\u0442\u0438\u043a\u0435\u0442\u0435<\/a>), \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u0441\u043e\u0432\u0435\u0442\u0443\u044e\u0442 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c keyword, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u043c\u0435\u0442\u0438\u0442 \u0434\u043b\u044f \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u0430 Kotlin \u044d\u0442\u043e\u0442 \u043a\u043b\u0430\u0441\u0441, \u043a\u0430\u043a \u0442\u0440\u0435\u0431\u0443\u044e\u0449\u0438\u0439 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438. \u042d\u0442\u043e<\/p>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-401438","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/401438","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=401438"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/401438\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=401438"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=401438"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=401438"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}