{"id":368278,"date":"2024-05-21T03:39:19","date_gmt":"2024-05-21T03:39:19","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=368278"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=368278","title":{"rendered":"<span>\u041f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u041e\u041e\u041f \u043d\u0430 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0435<\/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>\u0427\u0430\u0449\u0435 \u0432\u0441\u0435\u0433\u043e \u0437\u0430\u0434\u0430\u0447\u0443 \u043c\u043e\u0436\u043d\u043e \u0440\u0435\u0448\u0438\u0442\u044c \u0438\u043d\u0442\u0443\u0438\u0442\u0438\u0432\u043d\u043e \u043f\u043e\u043d\u044f\u0442\u043d\u044b\u043c \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u043d\u044b\u043c \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u043c. \u041e\u0434\u043d\u0430\u043a\u043e \u0441\u0430\u043c\u044b\u0439 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u043d\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 \u0441\u0430\u043c\u044b\u0439 \u043b\u0443\u0447\u0448\u0438\u0439. \u041f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u044e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0438, \u043a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u043d\u043e-\u043e\u0440\u0438\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u043c, \u0438 \u043a\u0430\u043a\u0443\u044e \u043f\u043e\u043b\u044c\u0437\u0443 \u044d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u0438\u043d\u0435\u0441\u0442\u0438.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/f11\/775\/325\/f11775325c7dc2287e54275d548af792.png\" width=\"1600\" height=\"902\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/f11\/775\/325\/f11775325c7dc2287e54275d548af792.png\"\/><\/figure>\n<h3>Dive in \u0432 \u0434\u043e\u043c\u0435\u043d\u043d\u0443\u044e \u043e\u0431\u043b\u0430\u0441\u0442\u044c<\/h3>\n<p>\u0412 PVS-Studio \u043c\u044b \u0440\u0430\u0437\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u043c <a href=\"https:\/\/pvs-studio.ru\/ru\/blog\/terms\/0046\/\">\u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0430\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440<\/a> \u043a\u043e\u0434\u0430, \u0430 \u043d\u0430\u0448\u0430 \u0435\u0436\u0435\u0434\u043d\u0435\u0432\u043d\u0430\u044f \u0440\u0430\u0431\u043e\u0442\u0430 \u2014 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043d\u043e\u0432\u044b\u0445 \u0434\u0438\u0430\u0433\u043d\u043e\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u043f\u0440\u0430\u0432\u0438\u043b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0433\u0443\u0442 \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0438\u0442\u044c \u043f\u043e\u0442\u0435\u043d\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0435 \u043e\u0448\u0438\u0431\u043a\u0438 \u0432 \u043a\u043e\u0434\u0435. \u041f\u0440\u043e \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u044b \u0440\u0430\u0431\u043e\u0442\u044b \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0430\u043d\u0430\u043b\u0438\u0437\u0430 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0447\u0438\u0442\u0430\u0442\u044c <a href=\"https:\/\/pvs-studio.ru\/ru\/blog\/posts\/1048\/\">\u0442\u0443\u0442<\/a>, \u0430 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e \u043f\u0440\u043e Java \u0430\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440 \u2014 <a href=\"https:\/\/habr.com\/ru\/companies\/pvs-studio\/articles\/414669\/\">\u0437\u0434\u0435\u0441\u044c<\/a>. \u041e\u0434\u043d\u0430\u043a\u043e \u0434\u043b\u044f \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u044f \u0437\u0430\u0434\u0430\u0447\u0438 \u043d\u0430\u043c \u0445\u0432\u0430\u0442\u0438\u0442 \u043e\u0431\u044a\u044f\u0441\u043d\u0435\u043d\u0438\u044f \u043e\u0431\u0449\u0438\u0445 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u043e\u0432 \u0440\u0430\u0431\u043e\u0442\u044b \u043b\u0438\u0448\u044c \u0434\u0432\u0443\u0445 \u0438\u0437 \u043d\u0430\u0448\u0438\u0445 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432: \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0434\u0435\u0440\u0435\u0432\u0430 \u0438 \u0441\u0435\u043c\u0430\u043d\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u0438.<\/p>\n<p>\u0418\u0442\u0430\u043a, \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u0434\u0435\u0440\u0435\u0432\u043e, \u0441\u043e\u0441\u0442\u043e\u044f\u0449\u0438\u0435 \u0438\u0437 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u043a\u043e\u0434\u0430 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b. \u041d\u0435 \u0441\u0442\u0430\u043d\u0443 \u0443\u043c\u043d\u0438\u0447\u0430\u0442\u044c \u0438 \u043f\u0440\u0438\u0432\u0435\u0434\u0443 \u0441\u0445\u0435\u043c\u0443 \u0438\u0437 \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u0439 \u0432\u044b\u0448\u0435 \u0441\u0442\u0430\u0442\u044c\u0438:<\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/ee5\/21a\/93c\/ee521a93c288b5422d9ebca917d1748d.png\" width=\"452\" height=\"299\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/ee5\/21a\/93c\/ee521a93c288b5422d9ebca917d1748d.png\"\/><\/figure>\n<p>\u041a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0434\u043e\u0433\u0430\u0434\u0430\u0442\u044c\u0441\u044f, \u044d\u0442\u043e \u2014 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u0434\u0435\u0440\u0435\u0432\u043e \u0434\u043b\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0433\u043e \u043a\u043e\u0434\u0430:<\/p>\n<pre><code class=\"cpp\">int a = x + y * z;<\/code><\/pre>\n<p>\u041a\u0440\u043e\u043c\u0435 \u044d\u0442\u043e\u0433\u043e, \u0432 \u043d\u0430\u0448\u0435\u043c \u0440\u0430\u0441\u043f\u043e\u0440\u044f\u0436\u0435\u043d\u0438\u0438 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u0430\u044f \u0441\u0435\u043c\u0430\u043d\u0442\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u043f\u0440\u043e \u043a\u0430\u0436\u0434\u044b\u0439 \u0438\u0437 \u0443\u0437\u043b\u043e\u0432: \u0442\u0438\u043f, \u043c\u0435\u0441\u0442\u043e \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u044f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0438 \u043f\u0440. \u0421 \u0431\u0430\u0437\u043e\u0439 \u0437\u0430\u043a\u043e\u043d\u0447\u0438\u043b\u0438! \u041e\u0441\u0442\u0430\u043b\u044c\u043d\u043e\u0435 \u0440\u0430\u0437\u0431\u0435\u0440\u0451\u043c \u043f\u043e \u0445\u043e\u0434\u0443 \u0434\u0435\u043b\u0430. \u0414\u043b\u044f \u043f\u0440\u043e\u0441\u0442\u043e\u0442\u044b \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u044f \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043a\u043e\u0435-\u0433\u0434\u0435 \u044f \u0441\u0440\u0435\u0436\u0443 \u0443\u0433\u043b\u044b \u0438 \u043d\u0430\u043c\u0435\u0440\u0435\u043d\u043d\u043e \u0443\u043f\u0440\u043e\u0449\u0443 API.<\/p>\n<h3>\u041f\u043e\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 \u0437\u0430\u0434\u0430\u0447\u0438<\/h3>\n<h4>\u041f\u0440\u0435\u0434\u043f\u043e\u0441\u044b\u043b\u043a\u0430<\/h4>\n<p>\u0422\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435 <a href=\"https:\/\/pvs-studio.ru\/ru\/docs\/warnings\/v6108\/\">\u0434\u0438\u0430\u0433\u043d\u043e\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u043e<\/a>: \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0435\u043d\u0438\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u0442\u0438\u043f\u0430 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0441\u0447\u0451\u0442\u0447\u0438\u043a\u0430 \u0446\u0438\u043a\u043b\u0430 <em>for<\/em>. \u0415\u0433\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0442\u0440\u0438\u0432\u0438\u0430\u043b\u044c\u043d\u0430\u044f: \u043d\u0430\u0434\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u0442\u0438\u043f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445-\u0441\u0447\u0451\u0442\u0447\u0438\u043a\u043e\u0432 (\u043f\u043b\u044e\u0441 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u043e\u0441\u043e\u0431\u044b\u0435 \u0441\u043b\u0443\u0447\u0430\u0438, \u0432\u0440\u043e\u0434\u0435 \u0446\u0438\u043a\u043b\u043e\u0432 \u0432\u0438\u0434\u0430 <em>for (;;)<\/em>). \u0414\u0430\u043b\u0435\u0435 \u0432\u0441\u0442\u0430\u0451\u0442 \u0432\u043e\u043f\u0440\u043e\u0441 \u043e\u0431 \u0443\u0440\u043e\u0432\u043d\u0435 \u043f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u044f. \u0418 \u0432\u043e\u0442 \u0442\u0443\u0442 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f \u0441\u0430\u043c\u043e\u0435 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e\u0435.<\/p>\n<p>\u041e\u0434\u043d\u0438\u043c \u0438\u0437 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0445 \u0440\u0438\u0441\u043a\u043e\u0432 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0441\u0447\u0451\u0442\u0447\u0438\u043a\u043e\u0432 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u0442\u0438\u043f\u0430 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f <a href=\"https:\/\/cwe.mitre.org\/data\/definitions\/834.html\">\u043b\u0438\u0448\u043d\u0438\u0435<\/a> \u2014 \u043b\u0438\u0431\u043e \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u044e\u0449\u0438\u0435 \u2014 \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u0438. \u0423\u0447\u0438\u0442\u044b\u0432\u0430\u044f, \u0447\u0442\u043e <em>for<\/em> \u0447\u0430\u0441\u0442\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u044e\u0442 \u043a\u0430\u043a \u0446\u0438\u043a\u043b \u0441 \u0437\u0430\u0440\u0430\u043d\u0435\u0435 \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u044b\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e\u043c \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u0439, \u0432 \u0435\u0433\u043e \u0441\u043b\u0443\u0447\u0430\u0435 \u0442\u0430\u043a\u043e\u0435 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u0433\u0443\u0431\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u043c. \u041d\u043e \u0432\u0435\u0434\u044c \u043d\u0430 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0435 \u0434\u0430\u043b\u0435\u043a\u043e \u043d\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 \u043b\u044e\u0434\u0438 \u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u0430\u043c\u0438 \u043f\u043e \u0438\u0445 \u043f\u0440\u044f\u043c\u043e\u043c\u0443 \u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044e (\u0446\u0438\u043a\u043b <em>for<\/em> \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e <em>while<\/em>). \u0418 \u043a\u0430\u043a \u043d\u0430\u043c \u043e\u0442\u043b\u0438\u0447\u0438\u0442\u044c \u043e\u0434\u043d\u043e \u043d\u0430\u043c\u0435\u0440\u0435\u043d\u0438\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442\u0430 \u043e\u0442 \u0434\u0440\u0443\u0433\u043e\u0433\u043e? \u042d\u0432\u0440\u0438\u0441\u0442\u0438\u043a\u0430!<\/p>\n<h4>\u0417\u0430\u0434\u0430\u0447\u0430<\/h4>\n<p>\u0418\u043c\u0435\u0435\u043c <strong>\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u043e<\/strong>: \u0435\u0441\u043b\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0432\u0441\u0435\u0445 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0432 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0438 \u0446\u0438\u043a\u043b\u0430 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0438\u0437 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0430 \u043c\u0435\u0442\u043e\u0434\u0430, \u0442\u043e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442 \u044f\u0432\u043d\u043e \u043e\u0436\u0438\u0434\u0430\u043b \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u043e\u0433\u043e \u0447\u0438\u0441\u043b\u0430 \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u0439. \u0412 \u0442\u0430\u043a\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043c\u044b \u0432\u044b\u0434\u0430\u0451\u043c \u043f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u0435 \u0432\u0442\u043e\u0440\u043e\u0433\u043e \u0443\u0440\u043e\u0432\u043d\u044f. \u0418\u043d\u0430\u0447\u0435 \u043c\u044b \u043d\u0435 \u043c\u043e\u0436\u0435\u043c \u0431\u044b\u0442\u044c \u0443\u0432\u0435\u0440\u0435\u043d\u044b \u0432 \u043d\u0430\u043c\u0435\u0440\u0435\u043d\u0438\u044f\u0445 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442\u0430 \u0438 \u0432\u044b\u0434\u0430\u0451\u043c \u0442\u0440\u0435\u0442\u0438\u0439 \u0443\u0440\u043e\u0432\u0435\u043d\u044c.<\/p>\n<details class=\"spoiler\">\n<summary>\u0421\u0442\u043e\u043f, \u0430 \u043f\u043e\u0447\u0435\u043c\u0443 \u0432\u0442\u043e\u0440\u043e\u0433\u043e \u0438 \u0442\u0440\u0435\u0442\u044c\u0435\u0433\u043e? \u0418 \u0447\u0442\u043e \u044d\u0442\u043e \u0432\u043e\u043e\u0431\u0449\u0435 \u0437\u043d\u0430\u0447\u0438\u0442?<\/summary>\n<div class=\"spoiler__content\">\n<p>\u041f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u044f \u0432 \u043d\u0430\u0448\u0435\u043c \u0430\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440\u0435 \u0438\u043c\u0435\u044e\u0442 \u0442\u0440\u0438 \u0443\u0440\u043e\u0432\u043d\u044f \u0438 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u044e\u0442 \u0442\u043e, \u043d\u0430\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043c\u044b \u0443\u0432\u0435\u0440\u0435\u043d\u044b \u0432 \u044d\u0442\u043e\u043c \u0441\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u043d\u0438\u0438. \u041f\u0435\u0440\u0432\u044b\u0439 \u0443\u0440\u043e\u0432\u0435\u043d\u044c \u0441\u0430\u043c\u044b\u0439 \u0434\u043e\u0441\u0442\u043e\u0432\u0435\u0440\u043d\u044b\u0439, \u0442\u0440\u0435\u0442\u0438\u0439 \u0441\u0430\u043c\u044b\u0439 \u0441\u043e\u043c\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439.<\/p>\n<p>\u0412 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u044f \u043f\u0440\u0435\u0434\u043f\u043e\u0447\u0451\u043b \u043f\u0435\u0440\u0432\u043e\u043c\u0443 \u0443\u0440\u043e\u0432\u043d\u044e \u0432\u0442\u043e\u0440\u043e\u0439 \u043f\u043e \u043f\u0440\u0438\u0447\u0438\u043d\u0435 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u043d\u0435 \u043b\u044e\u0431\u043e\u0439 \u0441\u0447\u0451\u0442\u0447\u0438\u043a \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u0442\u0438\u043f\u0430 \u043f\u0440\u0438\u0432\u0435\u0434\u0451\u0442 \u043a \u043b\u0438\u0448\u043d\u0435\u0439 \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u0438. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u044d\u0442\u0438 \u0434\u0432\u0430 \u0446\u0438\u043a\u043b\u0430 \u043e\u0442\u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0440\u0430\u0437 (\u043f\u043e 20):<\/p>\n<pre><code class=\"cpp\">for (double i = 0.0; i &lt; 1.0; i += 0.05) { } for (double i = 0.0; i &lt;= 1.0; i += 0.05) { }<\/code><\/pre>\n<p>\u0412 \u043f\u0435\u0440\u0432\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u043e\u0436\u0438\u0434\u0430\u0435\u043c\u043e, \u0432 \u0442\u043e \u0432\u0440\u0435\u043c\u044f \u043a\u0430\u043a \u0432\u043e \u0432\u0442\u043e\u0440\u043e\u043c \u043e\u0434\u043d\u0430 \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u044f \u043f\u0440\u043e\u043f\u0430\u043b\u0430. <a href=\"https:\/\/cwe.mitre.org\/data\/definitions\/1077.html\">\u041d\u0435 \u0441\u0442\u043e\u0438\u0442<\/a> \u043e\u0436\u0438\u0434\u0430\u0442\u044c \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u044b\u0445 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432 \u043f\u0440\u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0435 \u043d\u0430 \u0440\u0430\u0432\u0435\u043d\u0441\u0442\u0432\u043e \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u0447\u0438\u0441\u043b\u0430.<\/p>\n<p>\u0422\u0440\u0435\u0442\u0438\u0439 \u0443\u0440\u043e\u0432\u0435\u043d\u044c \u0432\u044b\u0434\u0430\u0451\u0442\u0441\u044f \u043d\u0430 \u0441\u043b\u0443\u0447\u0430\u0439, \u0435\u0441\u043b\u0438 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u0439 \u0432\u0441\u0451-\u0442\u0430\u043a\u0438 \u0434\u043e\u043b\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0431\u044b\u0442\u044c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u044b\u043c, \u0430 \u0446\u0438\u043a\u043b \u043f\u0440\u043e\u0441\u0442\u043e \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0432 \u043c\u0435\u0442\u043e\u0434\u0435, \u043b\u0438\u0431\u043e \u043d\u0430 \u0440\u0435\u0434\u043a\u0438\u0439, \u043d\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0439 <a href=\"https:\/\/cwe.mitre.org\/data\/definitions\/835.html\">\u0431\u0435\u0441\u043a\u043e\u043d\u0435\u0447\u043d\u044b\u0439 \u0446\u0438\u043a\u043b<\/a> (CVE-2006-6499).<\/p>\n<\/div>\n<\/details>\n<h4>\u041e\u0436\u0438\u0434\u0430\u0435\u043c\u044b\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442<\/h4>\n<p>\u042d\u0442\u0430\u043b\u043e\u043d\u043d\u044b\u0439 \u0441\u043b\u0443\u0447\u0430\u0439 \u2014 \u0432\u0441\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043f\u0440\u044f\u043c\u043e \u0432 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0438 \u0446\u0438\u043a\u043b\u0430 \u2014 \u0434\u043b\u044f \u043f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u044f \u0432\u0442\u043e\u0440\u043e\u0433\u043e \u0443\u0440\u043e\u0432\u043d\u044f:<\/p>\n<pre><code class=\"java\">for (double i = 0.0; i &lt; 1.0; i += 0.1) { }<\/code><\/pre>\n<p>\u041d\u043e \u043d\u0430\u043c \u043d\u0430\u0434\u043e \u043d\u0430\u0439\u0442\u0438 \u0438 \u0442\u0430\u043a\u0438\u0435 \u0441\u043b\u0443\u0447\u0430\u0438:<\/p>\n<pre><code class=\"java\">double lowerBoundary = 0.5; for (double i = lowerBoundary; i &lt; 1.0; i += 0.1) { } <\/code><\/pre>\n<p>\u0418 \u0442\u0430\u043a\u0438\u0435:<\/p>\n<pre><code class=\"java\">double shift = 0.5; double lowerBoundary = 0.0 + shift; double upperBoundary = 1.0; for (double i = lowerBoundary; i &lt; shift + upperBoundary; i += 0.1) { } <\/code><\/pre>\n<p>\u0412 \u0441\u043b\u0443\u0447\u0430\u0435 \u0436\u0435, \u0435\u0441\u043b\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0432 \u0446\u0438\u043a\u043b \u043f\u043e\u043f\u0430\u043b\u0438 \u0438\u0437\u0432\u043d\u0435 \u2014 \u043f\u043e\u043b\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u0438\u043b\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u043c\u0435\u0442\u043e\u0434\u043e\u0432, \u2014 \u043c\u044b \u0432\u044b\u0434\u0430\u0451\u043c \u0442\u0440\u0435\u0442\u0438\u0439 \u0443\u0440\u043e\u0432\u0435\u043d\u044c.<\/p>\n<h3>\u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0440\u0435\u0448\u0435\u043d\u0438\u044f<\/h3>\n<p>\u0418\u0442\u0430\u043a, \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u0443\u0437\u0435\u043b \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0434\u0435\u0440\u0435\u0432\u0430 \u0441 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0435\u043c \u0446\u0438\u043a\u043b\u0430 <em>for<\/em>, \u0430 \u0432\u0435\u0440\u043d\u0443\u0442\u044c \u043d\u0430\u043c \u043d\u0430\u0434\u043e <em>true<\/em> \u0438\u043b\u0438 <em>false<\/em> \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0442\u043e\u0433\u043e, \u0432\u0441\u0435 \u043b\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0438\u0437 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0430.<\/p>\n<p>\u0412 \u043a\u0430\u0436\u0434\u043e\u0439 \u0438\u0437 \u0441\u0435\u043a\u0446\u0438\u0439 \u0446\u0438\u043a\u043b\u0430: \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0441\u0447\u0451\u0442\u0447\u0438\u043a\u043e\u0432, \u0438\u0445 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u0438 \u0443\u0441\u043b\u043e\u0432\u0438\u0435 \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u2014 \u043d\u0430\u0434\u043e \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0432 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u044f\u0445.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/2ef\/90c\/a15\/2ef90ca15b7a0435baf5e05250809416.png\" width=\"1600\" height=\"902\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/2ef\/90c\/a15\/2ef90ca15b7a0435baf5e05250809416.png\"\/><\/figure>\n<p>\u0412\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u043c\u043e\u0433\u0443\u0442 \u0441\u043e\u0441\u0442\u043e\u044f\u0442\u044c \u0438\u0437 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432:<\/p>\n<ul>\n<li>\n<p>\u041b\u0438\u0442\u0435\u0440\u0430\u043b\u044b, \u043d\u0430\u043b\u0438\u0447\u0438\u0435 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043d\u0430\u0441 \u0438 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u0435\u0442;<\/p>\n<\/li>\n<li>\n<p>\u0423\u043d\u0430\u0440\u043d\u044b\u0435 \u0438 \u0431\u0438\u043d\u0430\u0440\u043d\u044b\u0435 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u044b: \u0438\u0445 \u043d\u0430\u0434\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0440\u0430\u0441\u043a\u0440\u044b\u0442\u044c;<\/p>\n<\/li>\n<li>\n<p>\u041f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435: \u043d\u0443\u0436\u043d\u043e \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435, \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u043e\u0435 \u0438\u0437 \u0438\u0445 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438;<\/p>\n<\/li>\n<li>\n<p>\u041b\u044e\u0431\u044b\u0435 \u0434\u0440\u0443\u0433\u0438\u0435: \u043f\u043e\u043b\u0435 \u043a\u043b\u0430\u0441\u0441\u0430, \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u0438 \u043f\u0440. \u0412 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043e\u0431\u0445\u043e\u0434 \u043c\u043e\u0436\u043d\u043e \u043e\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0442\u044c.<\/p>\n<\/li>\n<\/ul>\n<p>\u041e\u0447\u0435\u0432\u0438\u0434\u043d\u043e, \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0441\u043e\u0441\u0435\u0434\u043d\u0438\u0435 \u0443\u0437\u043b\u044b \u0432 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0447\u0435\u0441\u043a\u043e\u043c \u0434\u0435\u0440\u0435\u0432\u0435, \u0432\u0435\u0434\u044c \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u043c\u043e\u0433\u0443\u0442 \u0441\u043e\u0441\u0442\u043e\u044f\u0442\u044c \u0438\u0437 \u0434\u0440\u0443\u0433\u0438\u0445 \u043f\u043e\u0434\u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0439, \u0430 \u043e\u0434\u043d\u0438 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0437\u0430\u0432\u0438\u0441\u0435\u0442\u044c \u043e\u0442 \u0434\u0440\u0443\u0433\u0438\u0445. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043d\u0430\u043c \u043d\u0443\u0436\u0435\u043d \u0441\u043f\u043e\u0441\u043e\u0431 \u043e\u0431\u043e\u0439\u0442\u0438 \u0432\u0441\u0451 \u0434\u0435\u0440\u0435\u0432\u043e \u0446\u0435\u043b\u0438\u043a\u043e\u043c, \u043d\u0435 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0432\u0430\u044f\u0441\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u043e\u0441\u0435\u0434\u043d\u0438\u043c\u0438 \u0443\u0437\u043b\u0430\u043c\u0438 (\u0438 \u0442\u0435\u043c\u0438, \u0447\u0442\u043e \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u044b \u0438\u0437 \u0441\u0435\u043c\u0430\u043d\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0430\u043d\u0430\u043b\u0438\u0437\u0430).<\/p>\n<p>\u0423\u0441\u043b\u043e\u0432\u0438\u0435\u043c \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u0431\u0443\u0434\u0435\u0442 \u043e\u0431\u0445\u043e\u0434 \u0432\u0441\u0435\u0445 \u0442\u0435\u0440\u043c\u0438\u043d\u0430\u043b\u044c\u043d\u044b\u0445 \u0443\u0437\u043b\u043e\u0432 (\u0442\u0430\u043a\u0438\u0445, \u0447\u0442\u043e \u043d\u0435 \u0438\u043c\u0435\u044e\u0442 \u0434\u043e\u0447\u0435\u0440\u043d\u0438\u0445 \u0443\u0437\u043b\u043e\u0432). \u0415\u0441\u043b\u0438 \u0432\u0441\u0435 \u0442\u0435\u0440\u043c\u0438\u043d\u0430\u043b\u044c\u043d\u044b\u0435 \u0443\u0437\u043b\u044b \u0432 \u043e\u0431\u0445\u043e\u0434\u0435 \u2014 \u044d\u0442\u043e \u043b\u0438\u0442\u0435\u0440\u0430\u043b\u044b, \u0442\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0443\u0435\u043c\u044b\u043c. \u0412 \u043e\u0431\u0440\u0430\u0442\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0444\u0438\u043a\u0441\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u043d\u0435\u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0443\u0435\u043c\u043e\u0441\u0442\u044c.<\/p>\n<h3>\u041f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u043d\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435<\/h3>\n<p>\u0418\u0442\u0430\u043a, \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043e\u0431\u043e\u0439\u0442\u0438 \u0434\u0435\u0440\u0435\u0432\u043e \u043d\u0435\u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e\u0439 \u0433\u043b\u0443\u0431\u0438\u043d\u044b. \u041a\u043b\u0430\u0441\u0441\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u2014 \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u044f. \u041d\u0430\u043f\u0438\u0448\u0435\u043c \u043c\u0435\u0442\u043e\u0434 <em>isAccessible<\/em>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u043d\u0430 \u0432\u0445\u043e\u0434 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435, \u043f\u043e\u0441\u043b\u0435 \u0447\u0435\u0433\u043e \u0440\u0430\u0441\u043a\u0440\u044b\u0432\u0430\u0435\u0442 \u0435\u0433\u043e \u0438 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u043e\u0441\u0442\u044c \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0430 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439.<\/p>\n<pre><code class=\"java\">private static boolean isAccessible(CtCodeElement el) {   return isAccessible(el, Collections.emptyList()); }  private static boolean isAccessible(   CtCodeElement el,   List&lt;CtVariable> exclude ) {   if (isCodeElementEqualsToAny(el, exclude)) {     return true;   }    var expressionElements = new LinkedList&lt;CtCodeElement>();   parseExpression(el, expressionElements);   return expressionElements.stream().allMatch(x -> x instanceof CtLiteral); }  private static void parseExpression(   CtCodeElement el,   List&lt;CtCodeElement> terminalNodes ) {   if (el instanceof CtBinaryOperator) {     var op = (CtBinaryOperator) el;     parseExpression(op.getLeftHandOperand(), terminalNodes);     parseExpression(op.getRightHandOperand(), terminalNodes);   } else if (el instanceof CtUnaryOperator) {     parseExpression(((CtUnaryOperator)el).getOperand(), terminalNodes);   } else if (el instanceof CtVariable) {     parseExpression(Optional.ofNullable(((CtVariable)el).getDeclaration())                             .map(CtDeclaration::getDefaultExpression)                             .orElse(null), terminalNodes);   } else {     terminalNodes.add(el);   } }<\/code><\/pre>\n<details class=\"spoiler\">\n<summary>\u041f\u043e\u044f\u0441\u043d\u0435\u043d\u0438\u044f \u043f\u043e \u043f\u043e\u0432\u043e\u0434\u0443 isCodeElementEqualsToAny<\/summary>\n<div class=\"spoiler__content\">\n<p>\u0412 \u0441\u0435\u043a\u0446\u0438\u044f\u0445 \u0443\u0441\u043b\u043e\u0432\u0438\u044f \u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0441\u0447\u0451\u0442\u0447\u0438\u043a\u043e\u0432 \u043d\u0435\u0442 \u0441\u043c\u044b\u0441\u043b\u0430 \u0440\u0430\u0441\u043a\u0440\u044b\u0432\u0430\u0442\u044c \u0441\u0430\u043c \u0441\u0447\u0451\u0442\u0447\u0438\u043a, \u0432\u0435\u0434\u044c \u0435\u0433\u043e \u043c\u044b \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u043c \u043f\u0435\u0440\u0432\u044b\u043c \u0434\u0435\u043b\u043e\u043c. \u0412\u043e\u0442 \u043a\u043e\u0434 \u044d\u0442\u043e\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0430.<\/p>\n<pre><code class=\"java\">private static boolean isCodeElementEqualsToAny(   CtCodeElement el,    List&lt;CtVariable> toCompare ) {   return el instanceof CtVariable          &amp;&amp; toCompare.stream()                      .anyMatch(x -> ((CtVariable)el).equals(x)); }<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<p>\u0421\u0430\u043c\u0430\u044f \u0441\u043b\u043e\u0436\u043d\u0430\u044f \u0440\u0430\u0431\u043e\u0442\u0430 \u0441\u0434\u0435\u043b\u0430\u043d\u0430. \u041e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0438\u0437 \u043a\u0430\u0436\u0434\u043e\u0439 \u0441\u0435\u043a\u0446\u0438\u0438 \u0446\u0438\u043a\u043b\u0430. \u0412 \u0441\u0435\u043a\u0446\u0438\u0438 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0432\u0441\u0451 \u043f\u0440\u043e\u0441\u0442\u043e: \u0441\u0447\u0451\u0442\u0447\u0438\u043a \u043c\u043e\u0436\u0435\u0442 \u043e\u0431\u044a\u044f\u0432\u043b\u044f\u0442\u044c\u0441\u044f \u043b\u0438\u0431\u043e \u043f\u0440\u044f\u043c\u043e \u0432 \u044d\u0442\u043e\u0439 \u0441\u0435\u043a\u0446\u0438\u0438, \u043b\u0438\u0431\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0443\u0436\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0430\u044f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f. \u0412 \u043b\u044e\u0431\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043d\u0430\u0441 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u0435\u0442 \u043b\u0438\u0448\u044c \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435, \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043f\u0440\u0438\u0441\u0432\u0430\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0441\u0447\u0451\u0442\u0447\u0438\u043a\u0443. \u0421\u0447\u0451\u0442\u0447\u0438\u043a\u043e\u0432 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0431\u043e\u043b\u0435\u0435 \u043e\u0434\u043d\u043e\u0433\u043e, \u0442\u0430\u043a \u0447\u0442\u043e \u044d\u0442\u043e \u043c\u044b \u0442\u043e\u0436\u0435 \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u043c.<\/p>\n<pre><code class=\"java\">public boolean areInitsPredictable() {   return init.stream().allMatch(x -> {     if (x instanceof CtLocalVariable) {       return isAccessible(((CtLocalVariable)x).getDefaultExpression());     } else if (x instanceof CtAssignment) {       return isAccessible(((CtAssignment)x).getAssignment());     } else {       return false;     }   }); }<\/code><\/pre>\n<p>\u0421 \u0443\u0441\u043b\u043e\u0432\u0438\u0435\u043c \u043f\u0440\u043e\u0449\u0435 \u0432\u0441\u0435\u0433\u043e: \u043b\u0438\u0448\u044c \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c, \u0447\u0442\u043e \u044d\u0442\u043e \u0432\u043e\u043e\u0431\u0449\u0435 \u0431\u0438\u043d\u0430\u0440\u043d\u044b\u0439 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440 (\u0438\u043d\u0430\u0447\u0435 \u0443 \u043d\u0430\u0441 \u043b\u0430\u043f\u043a\u0438), \u043f\u043e\u0441\u043b\u0435 \u0447\u0435\u0433\u043e \u0440\u0430\u0441\u043a\u0440\u044b\u0432\u0430\u0435\u043c \u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u043e\u043f\u0435\u0440\u0430\u043d\u0434\u044b.<\/p>\n<pre><code class=\"java\">public boolean isConditionPredictable(   List&lt;CtVariableReference> initReferences ) {   var operator = safeCast(condition, CtBinaryOperator.class);   if (operator == null)     return false;    return Stream.of(     operator.getLeftHandOperand(),     operator.getRightHandOperand()   ).allMatch(x -> isAccessible(x, initReferences)); }<\/code><\/pre>\n<details class=\"spoiler\">\n<summary>\u0427\u0442\u043e \u0437\u0430 safeCast?<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"java\">@Nullable public static &lt;T> T safeCast(Object obj, @Nullable Class&lt;T> cl) {   return cl != null &amp;&amp; cl.isInstance(obj) ? cl.cast(obj) : null; }<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<p>\u0418 \u043d\u0430\u043f\u043e\u0441\u043b\u0435\u0434\u043e\u043a \u0441\u0435\u043a\u0446\u0438\u044f \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0441\u0447\u0451\u0442\u0447\u0438\u043a\u043e\u0432. \u0417\u0434\u0435\u0441\u044c \u0432\u0441\u0451 \u043f\u043e\u0447\u0442\u0438 \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e: \u0431\u0438\u043d\u0430\u0440\u043d\u044b\u0439 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440 \u0440\u0430\u0441\u043a\u0440\u044b\u0432\u0430\u0435\u043c, \u0430 \u043d\u0430 \u0443\u043d\u0430\u0440\u043d\u044b\u0445 \u2014 \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0438\u043d\u043a\u0440\u0435\u043c\u0435\u043d\u0442\u0430\u0445 \u2014 \u0441\u0440\u0430\u0437\u0443 \u043e\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c\u0441\u044f.<\/p>\n<pre><code class=\"java\">public boolean areUpdatesPredictable(   List&lt;CtVariableReference> initReferences ) {   return update.stream().allMatch(x -> {     if (x instanceof CtAssignment) {       return isAccessible(         ((CtAssignment)x).getAssignment(),         initReferences       );     } else {       return x instanceof CtUnaryOperator;     }   }); }<\/code><\/pre>\n<p>\u0418 \u0441\u043e\u0435\u0434\u0438\u043d\u044f\u0435\u043c \u0432\u0441\u0451 \u044d\u0442\u043e \u0432\u043e\u0435\u0434\u0438\u043d\u043e:<\/p>\n<pre><code class=\"java\">public boolean areAllValuesPredictable() {   var initReferences = getInitReferences();   return    areInitsPredictable()          &amp;&amp; isConditionPredictable(initReferences)          &amp;&amp; areUpdatesPredictable(initReferences); }<\/code><\/pre>\n<details class=\"spoiler\">\n<summary>\u041c\u043d\u0435 \u043e\u0447\u0435\u043d\u044c \u043d\u0430\u0434\u043e \u0437\u043d\u0430\u0442\u044c, \u0447\u0442\u043e \u0432\u043d\u0443\u0442\u0440\u0438 getInitReferences<\/summary>\n<div class=\"spoiler__content\">\n<p>\u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0432 \u043e\u0431\u0449\u0435\u043c \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u0435\u043d \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044e \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0439 \u0438\u0437 \u0441\u0435\u043a\u0446\u0438\u0438 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438, \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u0430 \u043b\u0435\u0432\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438\/\u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u044f.<\/p>\n<pre><code class=\"java\">public List&lt;CtVariable> getInitReferences() {   var res = new LinkedList&lt;CtVariable>();   init.forEach(x -> {     if (x instanceof CtLocalVariable) {         res.add(((CtLocalVariable) x).getVariable());     } else if (x instanceof CtAssignment) {       var variableWrite = safeCast(         ((CtAssignment) x).getAssigned(),         CtVariableWrite.class       );       if (variableWrite != null) {         res.add(variableWrite.getVariable());       }     }   });   return res; }<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<p>\u0412\u0441\u0451 \u0433\u043e\u0442\u043e\u0432\u043e! \u041a\u043e\u0434 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442, \u0442\u0435\u0441\u0442\u044b \u043f\u0440\u043e\u0445\u043e\u0434\u044f\u0442, \u043f\u043e\u0442\u0435\u043d\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0435 \u043e\u0448\u0438\u0431\u043a\u0438 \u043d\u0430\u0445\u043e\u0434\u044f\u0442\u0441\u044f.<\/p>\n<h3>\u041e\u0431\u044a\u0435\u043a\u0442\u043d\u043e-\u043e\u0440\u0438\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435<\/h3>\n<h4>\u0410 \u0437\u0430\u0447\u0435\u043c?<\/h4>\n<p>\u041f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u043d\u044b\u0439 \u043a\u043e\u0434 \u0432\u043f\u043e\u043b\u043d\u0435 \u0447\u0438\u0442\u0430\u0435\u043c\u044b\u0439, \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u0437\u0430\u0434\u0430\u0447\u0443. \u0420\u0430\u0437\u0432\u0435 \u0442\u0443\u0442 \u043c\u043e\u0436\u043d\u043e \u0447\u0442\u043e-\u0442\u043e \u0443\u043b\u0443\u0447\u0448\u0438\u0442\u044c?<\/p>\n<p>\u0412\u043e\u043f\u0440\u043e\u0441, \u043a\u043e\u043d\u0435\u0447\u043d\u043e, \u0434\u0438\u0441\u043a\u0443\u0441\u0441\u0438\u043e\u043d\u043d\u044b\u0439, \u0438\u0431\u043e <a href=\"https:\/\/ru.wikipedia.org\/wiki\/KISS_(%D0%BF%D1%80%D0%B8%D0%BD%D1%86%D0%B8%D0%BF)\">KISS<\/a>, <a href=\"https:\/\/ru.wikipedia.org\/wiki\/YAGNI\">YAGNI<\/a> \u0438 \u0432\u0441\u0451 \u0442\u0430\u043a\u043e\u0435. \u041d\u043e \u0432\u0441\u0451 \u0436\u0435 \u0441\u0442\u043e\u0438\u0442 \u0438\u043d\u043e\u0433\u0434\u0430 \u0432\u0441\u043f\u043e\u043c\u0438\u043d\u0430\u0442\u044c, \u0447\u0442\u043e \u0440\u0430\u0431\u043e\u0442\u0430 \u043d\u0435 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0440\u0430\u043c\u043a\u0430\u043c\u0438 \u043e\u0434\u043d\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0438, \u0438\u0437-\u0437\u0430 \u0447\u0435\u0433\u043e \u0438\u043c\u0435\u0435\u0442 \u0441\u043c\u044b\u0441\u043b \u043c\u044b\u0441\u043b\u0438\u0442\u044c \u0448\u0438\u0440\u0435. \u0421\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0438 \u0441\u0435\u043c\u0430\u043d\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0430\u043d\u0430\u043b\u0438\u0437\u044b \u2014 \u043d\u0435 \u0432\u0441\u0435 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u044b \u0430\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440\u0430, \u043d\u043e \u043e\u0434\u043d\u0438 \u0438\u0437 \u0441\u0430\u043c\u044b\u0445 \u0431\u0430\u0437\u043e\u0432\u044b\u0445. \u0418, \u0440\u0430\u0437\u0443\u043c\u0435\u0435\u0442\u0441\u044f, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u043c\u044b \u0438\u0445 \u0447\u0430\u0441\u0442\u043e.<\/p>\n<p>\u0422\u0430\u043a \u0432\u043e\u0442, \u0435\u0441\u043b\u0438 \u043f\u0440\u0438\u043d\u044f\u0442\u044c \u0433\u0438\u043f\u043e\u0442\u0435\u0437\u0443, \u0447\u0442\u043e \u043e\u0431\u0445\u043e\u0434 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0434\u0435\u0440\u0435\u0432\u0430 \u0432 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0431\u0443\u0434\u0435\u0442 \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043e\u0447\u0435\u043d\u044c \u0447\u0430\u0441\u0442\u043e, \u0442\u043e \u0442\u0430\u043a\u043e\u0439 \u043a\u043e\u0434 \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u043f\u0435\u0440\u0435\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c. \u041d\u043e \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u043e, \u0447\u0442\u043e &#171;\u043a\u0430\u043a \u0435\u0441\u0442\u044c&#187; \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0442\u044c \u0442\u043e\u0442 \u0436\u0435 \u043c\u0435\u0442\u043e\u0434 <em>parseExpressions<\/em> \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0441\u044f \u043d\u0435 \u0432\u0441\u0435\u0433\u0434\u0430. \u041c\u043e\u0436\u0435\u0442, \u043c\u044b \u0437\u0430\u0445\u043e\u0442\u0438\u043c \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u043f\u043e\u0438\u0441\u043a \u0432 \u0433\u043b\u0443\u0431\u0438\u043d\u0443 \u043d\u0430 \u043f\u043e\u0438\u0441\u043a \u0432 \u0448\u0438\u0440\u0438\u043d\u0443, \u0438\u043b\u0438 \u0432\u044b\u0431\u0440\u0430\u0442\u044c \u0435\u0449\u0451 \u0431\u043e\u043b\u0435\u0435 \u0438\u0437\u044f\u0449\u043d\u044b\u0439 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u043e\u0431\u0445\u043e\u0434\u0430 \u0434\u0435\u0440\u0435\u0432\u0430. \u0410 \u043c\u043e\u0436\u0435\u0442, \u043d\u0430\u043c \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u044f\u0442\u0441\u044f \u0434\u0440\u0443\u0433\u0438\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u0430 \u0440\u0430\u0437\u0432\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u043d\u0438\u044f \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0439 \u0438\u043b\u0438 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0441\u0435\u043c\u0430\u043d\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0440\u0430\u0441\u043a\u0440\u044b\u0432\u0430\u0442\u044c \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u043c\u0430\u0441\u0441\u0438\u0432\u0430).<\/p>\n<p>\u041a\u043e\u043d\u0435\u0447\u043d\u043e, \u043c\u043e\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u043d\u0435\u0441\u0442\u0438 \u043c\u0435\u0442\u043e\u0434\u044b \u0432 \u0443\u0442\u0438\u043b\u0438\u0442\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 \u0438 \u043f\u0440\u043e\u0432\u0435\u0441\u0442\u0438 \u0440\u0435\u0444\u0430\u043a\u0442\u043e\u0440\u0438\u043d\u0433, \u043d\u043e \u043f\u043e\u0441\u043b\u0435 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u0439 \u043a\u043e\u0434 \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0443\u0435\u043c\u043e \u043f\u0440\u0435\u0432\u0440\u0430\u0442\u0438\u0442\u0441\u044f \u0432 \u0441\u043f\u0430\u0433\u0435\u0442\u0442\u0438. \u0427\u0443\u0432\u0441\u0442\u0432\u0443\u0435\u0442\u0435? \u042d\u0442\u043e \u0436\u0435 \u043f\u0440\u0435\u0434\u043f\u043e\u0441\u044b\u043b\u043a\u0430 \u0434\u043b\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u043e\u0432!<\/p>\n<h3>\u0422\u0435\u043e\u0440\u0438\u044f<\/h3>\n<h4>\u041e\u041e\u041f<\/h4>\n<p>\u0420\u0435\u0448\u0438\u043b\u0438: \u0434\u0435\u043b\u0430\u0435\u043c \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u041e\u041e\u041f. \u041d\u043e \u043a\u0430\u043a \u0438\u043c\u0435\u043d\u043d\u043e \u043d\u0430\u043c \u0434\u043e\u0441\u0442\u0438\u0433\u043d\u0443\u0442\u044c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430? \u0418\u043d\u043a\u0430\u043f\u0441\u0443\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0435 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u043d\u0430\u043c \u043f\u043e\u043c\u043e\u0433\u0443\u0442 \u043a\u043b\u0430\u0441\u0441\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u044b \u043f\u0440\u043e\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f. \u041d\u0435 \u0441\u0442\u0430\u043d\u0443 \u0437\u0430\u0431\u0438\u0440\u0430\u0442\u044c \u0441\u0435\u0431\u0435 \u043b\u0430\u0432\u0440\u044b <a href=\"https:\/\/ru.wikipedia.org\/wiki\/Design_Patterns\">GoF<\/a> \u0438 \u0442\u044b\u0441\u044f\u0447 \u0434\u0440\u0443\u0433\u0438\u0445 \u043b\u044e\u0434\u0435\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0443\u0436\u0435 \u0438\u0445 \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u043b\u0438, \u043d\u043e \u0431\u044b\u0441\u0442\u0440\u043e \u043d\u0430\u043f\u043e\u043c\u043d\u0438\u0442\u044c \u0441\u0447\u0438\u0442\u0430\u044e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u043c.<\/p>\n<h4>\u0418\u0442\u0435\u0440\u0430\u0442\u043e\u0440<\/h4>\n<p>\u0423\u0447\u0438\u0442\u044b\u0432\u0430\u044f, \u0447\u0442\u043e \u043f\u043e\u0447\u0442\u0438 \u0432\u0441\u044f \u0437\u0430\u0434\u0430\u0447\u0430 \u0441\u0442\u0440\u043e\u0438\u0442\u0441\u044f \u043d\u0430 \u043e\u0431\u0445\u043e\u0434\u0435 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0434\u0435\u0440\u0435\u0432\u0430, \u0438\u0442\u0435\u0440\u0430\u0442\u043e\u0440 \u043d\u0430\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0441\u0430\u043c \u0441\u043e\u0431\u043e\u0439. \u041a\u043b\u0430\u0441\u0441\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u0434\u0438\u0430\u0433\u0440\u0430\u043c\u043c\u0430 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u0434\u043b\u044f \u043d\u0435\u0433\u043e \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a.<\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/ad9\/233\/d67\/ad9233d67ee6ed259e5bf2feeffd8c8b.png\" width=\"481\" height=\"256\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/ad9\/233\/d67\/ad9233d67ee6ed259e5bf2feeffd8c8b.png\"\/><\/figure>\n<p>\u0421 \u0441\u0430\u043c\u0438\u043c \u0438\u0442\u0435\u0440\u0430\u0442\u043e\u0440\u043e\u043c \u0432\u0441\u0451 \u043f\u043e\u043d\u044f\u0442\u043d\u043e: \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u0435\u0440\u0435\u043c\u0435\u0449\u0430\u0442\u044c\u0441\u044f, \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u0442\u0435\u043a\u0443\u0449\u0438\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0438 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0442\u044c, \u043a\u043e\u0433\u0434\u0430 \u043e\u0431\u0445\u043e\u0434 \u0437\u0430\u043a\u043e\u043d\u0447\u0435\u043d.<\/p>\n<p>\u041f\u043e\u0434 \u0430\u0433\u0440\u0435\u0433\u0430\u0442\u043e\u043c \u0447\u0430\u0449\u0435 \u0432\u0441\u0435\u0433\u043e \u043f\u043e\u043d\u0438\u043c\u0430\u0435\u0442\u0441\u044f \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u044f, \u043f\u043e \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442\u044c \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u044f. \u041d\u043e \u043f\u043e\u0441\u0442\u043e\u0439\u0442\u0435! \u0412\u043d\u0438\u043c\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u0447\u0438\u0442\u0430\u0442\u0435\u043b\u044c \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u043b \u043f\u043e\u0434\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e \u043d\u0430 \u0432\u0445\u043e\u0434 \u043d\u0430\u043c \u0434\u0430\u0432\u0430\u043b\u0441\u044f \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0434\u0435\u0440\u0435\u0432\u0430, \u043d\u043e \u043d\u0435 \u043a\u0430\u043a\u0430\u044f-\u0442\u043e \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u044f \u0441\u0430\u043c\u0430 \u043f\u043e \u0441\u0435\u0431\u0435.<\/p>\n<p>\u0418 \u0442\u0443\u0442 \u0432\u0440\u0435\u043c\u044f \u0430\u0431\u0441\u0442\u0440\u0430\u0433\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f. \u0412\u0435\u0434\u044c \u043c\u044b \u043e\u0431\u0445\u043e\u0434\u0438\u043c \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u0430\u043c\u043e \u0434\u0435\u0440\u0435\u0432\u043e (\u0440\u0430\u0441\u043a\u0440\u044b\u0442\u0438\u0435 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u043e\u0432), \u043d\u043e \u0435\u0449\u0451 \u0438 \u0438\u0449\u0435\u043c \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 (\u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u0432 \u0441\u043e\u0432\u0441\u0435\u043c \u0434\u0440\u0443\u0433\u0438\u0435 \u0443\u0437\u043b\u044b \u044d\u0442\u043e\u0433\u043e \u0434\u0435\u0440\u0435\u0432\u0430). \u0422\u043e \u0435\u0441\u0442\u044c \u044d\u0442\u0430 &#171;\u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u044f&#187; \u043e\u0447\u0435\u043d\u044c \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0442\u043d\u0430 \u0438 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0443 \u043d\u0430\u0441 \u0432 \u0433\u043e\u043b\u043e\u0432\u0435. \u041d\u0435 \u0441\u043e\u0432\u0441\u0435\u043c \u043f\u043e \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u0443 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f&#8230; \u041a \u0441\u0447\u0430\u0441\u0442\u044c\u044e, \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u044b \u043d\u0435 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0441\u0432\u043e\u0434\u043e\u043c \u0441\u0442\u0440\u043e\u0433\u0438\u0445 \u043f\u0440\u0430\u0432\u0438\u043b, \u0442\u0430\u043a \u0447\u0442\u043e \u043c\u044b \u0441\u043e \u0441\u043f\u043e\u043a\u043e\u0439\u043d\u043e\u0439 \u0434\u0443\u0448\u043e\u0439 \u0441\u043c\u043e\u0436\u0435\u043c \u043e\u0442 \u043d\u0438\u0445 \u043e\u0442\u043e\u0439\u0442\u0438 \u0438 \u0437\u0430\u0431\u044b\u0442\u044c \u043f\u0440\u043e \u0432\u0441\u044e \u043b\u0435\u0432\u0443\u044e \u0447\u0430\u0441\u0442\u044c \u0434\u0438\u0430\u0433\u0440\u0430\u043c\u043c\u044b.<\/p>\n<h4>\u0421\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u044f<\/h4>\n<p>\u0425\u043e\u0440\u043e\u0448\u043e, \u043c\u044b \u0434\u043e\u0433\u043e\u0432\u043e\u0440\u0438\u043b\u0438\u0441\u044c, \u0447\u0442\u043e \u0438\u0442\u0435\u0440\u0430\u0442\u043e\u0440 \u0434\u043e\u043b\u0436\u0435\u043d \u0438\u043d\u043a\u0430\u043f\u0441\u0443\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432 \u0441\u0435\u0431\u0435 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u043e\u0431\u0445\u043e\u0434\u0430 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u2014 \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0442\u043d\u043e\u0433\u043e \u2014 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432. \u041d\u043e \u043c\u044b, \u043a\u0430\u0436\u0435\u0442\u0441\u044f, \u0445\u043e\u0442\u0435\u043b\u0438, \u0447\u0442\u043e\u0431\u044b \u043f\u0440\u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u044b\u0432\u0430\u0442\u044c \u0440\u0430\u0437\u043d\u044b\u0435 <strong>\u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u0438<\/strong> \u043e\u0431\u0445\u043e\u0434\u0430? \u041d\u0443 \u0432\u043e\u0442, \u0441\u0430\u043c\u043e \u0432\u044b\u0440\u0432\u0430\u043b\u043e\u0441\u044c :).<\/p>\n<p>\u041c\u044b, \u043a\u043e\u043d\u0435\u0447\u043d\u043e, \u043c\u043e\u0433\u043b\u0438 \u0431\u044b \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u044b\u0432\u0430\u0442\u044c \u0438\u0445 \u0432 \u0440\u0430\u0437\u043d\u044b\u0445 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u0445 \u0438\u0442\u0435\u0440\u0430\u0442\u043e\u0440\u0430\u0445, \u043d\u043e \u0432\u043e\u0442 \u043d\u0435\u0437\u0430\u0434\u0430\u0447\u0430: \u0442\u0438\u043f\u043e\u0432 \u044d\u0442\u0438\u0445 \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u0439 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043c\u043d\u043e\u0433\u043e. \u041a\u0430\u043a \u044f \u0438 \u0433\u043e\u0432\u043e\u0440\u0438\u043b, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0437\u0430\u0445\u043e\u0442\u0435\u0442\u044c \u043f\u043e\u043c\u0435\u043d\u044f\u0442\u044c \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u043e\u0431\u0445\u043e\u0434\u0430 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0438 \u0441 \u0448\u0438\u0440\u0438\u043d\u044b \u043d\u0430 \u0433\u043b\u0443\u0431\u0438\u043d\u0443, \u0430 \u043c\u043e\u0436\u0435\u043c \u043f\u043e\u043c\u0435\u043d\u044f\u0442\u044c \u0441\u0430\u043c \u043f\u0440\u0438\u043d\u0446\u0438\u043f \u0440\u0430\u0441\u043a\u0440\u044b\u0442\u0438\u044f \u0443\u0437\u043b\u043e\u0432 (\u0432 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u2014 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u0443\u0437\u043b\u044b \u0438\u0437 \u0441\u0435\u043c\u0430\u043d\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438). \u0418 \u0435\u0441\u043b\u0438 \u0431\u044b \u043c\u044b \u0441\u043e\u0435\u0434\u0438\u043d\u0438\u043b\u0438 \u044d\u0442\u0438 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u044b \u0432 \u043e\u0434\u043d\u043e\u043c \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u043c \u0438\u0442\u0435\u0440\u0430\u0442\u043e\u0440\u0435, \u0442\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u0431\u044b \u043a\u043e\u043c\u0431\u0438\u043d\u0430\u0442\u043e\u0440\u043d\u043e\u0435 \u0443\u0432\u0435\u043b\u0438\u0447\u0435\u043d\u0438\u0435 \u0442\u0438\u043f\u043e\u0432 \u0438\u0442\u0435\u0440\u0430\u0442\u043e\u0440\u043e\u0432.<\/p>\n<p>\u0420\u0430\u0431\u043e\u0442\u0430 \u0441 \u043a\u043e\u043c\u043f\u043e\u0437\u0438\u0446\u0438\u0435\u0439 \u0432\u043c\u0435\u0441\u0442\u043e \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u044f \u0440\u0435\u0448\u0430\u0435\u0442 \u044d\u0442\u0443 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443, \u0442\u0430\u043a \u0447\u0442\u043e \u0442\u0438\u043f \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 \u043e\u0431\u0445\u043e\u0434\u0430 \u044f \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u044e \u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0432 \u0438\u0442\u0435\u0440\u0430\u0442\u043e\u0440\u0435, \u0430 \u0440\u0430\u0441\u043a\u0440\u044b\u0442\u0438\u0435 \u0443\u0437\u043b\u043e\u0432 \u0438\u043d\u043a\u0430\u043f\u0441\u0443\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432 \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u044e. \u0415\u0451 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u0430\u044f \u0434\u0438\u0430\u0433\u0440\u0430\u043c\u043c\u0430 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/d03\/1fd\/83f\/d031fd83ffbdf1ad9b609255baa6cf7c.png\" width=\"531\" height=\"216\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/d03\/1fd\/83f\/d031fd83ffbdf1ad9b609255baa6cf7c.png\"\/><\/figure>\n<p>\u0412 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u043e\u043c \u0431\u0443\u0434\u0435\u0442 \u0441\u0430\u043c \u0438\u0442\u0435\u0440\u0430\u0442\u043e\u0440, \u0432 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u043e\u043c \u0432\u0441\u0451 \u0434\u043e\u043b\u0436\u043d\u043e \u0431\u044b\u0442\u044c \u044f\u0441\u043d\u043e. \u041e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0440\u0435\u0448\u0438\u0442\u044c \u0432\u043e\u043f\u0440\u043e\u0441, \u043a\u0430\u043a \u043c\u044b \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043c \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u043e\u0431\u0445\u043e\u0434\u0430 \u043c\u0435\u0436\u0434\u0443 \u0440\u0430\u0437\u043d\u044b\u043c\u0438 \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u044f\u043c\u0438.<\/p>\n<h4>\u0428\u0430\u0431\u043b\u043e\u043d\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434<\/h4>\n<p>\u0415\u0449\u0451 \u043e\u0434\u043d\u0430 \u0433\u0438\u043f\u043e\u0442\u0435\u0437\u0430: \u0440\u0430\u0441\u043a\u0440\u044b\u0442\u0438\u0435 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u043e\u0432 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043d\u0430\u0441\u0442\u043e\u043b\u044c\u043a\u043e \u0447\u0430\u0441\u0442\u043e\u0439 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0435\u0439, \u0447\u0442\u043e \u043c\u044b \u0441\u0447\u0438\u0442\u0430\u0435\u043c \u0442\u0430\u043a\u043e\u0435 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435\u043c \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e. \u0412 \u0442\u0430\u043a\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0430\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 \u0440\u0430\u0441\u043a\u0440\u044b\u0442\u0438\u044f \u0443\u0437\u043b\u0430 \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u043d\u0435\u0441\u0442\u0438 \u0432 <strong>\u0437\u0430\u0446\u0435\u043f\u043a\u0443<\/strong>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0447\u0430\u0441\u0442\u043d\u044b\u043c \u0441\u043b\u0443\u0447\u0430\u0435\u043c \u0448\u0430\u0431\u043b\u043e\u043d\u043d\u043e\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0430. \u0415\u0433\u043e \u0441\u0445\u0435\u043c\u0430 \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u0430 \u043d\u0438\u0436\u0435.<\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/69f\/e7a\/4ae\/69fe7a4ae6b5463a3d513f3936c28fa8.png\" width=\"161\" height=\"242\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/69f\/e7a\/4ae\/69fe7a4ae6b5463a3d513f3936c28fa8.png\"\/><\/figure>\n<p>\u041d\u0430 \u044d\u0442\u043e\u043c \u043f\u043e\u0432\u0442\u043e\u0440\u0435\u043d\u0438\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0439 \u0442\u0435\u043e\u0440\u0438\u0438 \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043a\u043e\u043d\u0447\u0438\u0442\u044c \u0438 \u043d\u0430\u043a\u043e\u043d\u0435\u0446-\u0442\u043e \u043f\u0435\u0440\u0435\u0439\u0442\u0438 \u043a \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0435.<\/p>\n<h3>\u041a\u043e\u0434<\/h3>\n<p>\u041f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u043a \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438. \u0418 \u043d\u0430\u0447\u043d\u0451\u043c \u043c\u044b, \u043a\u0430\u043a \u0438 \u0432 \u043f\u0440\u043e\u0448\u043b\u044b\u0439 \u0440\u0430\u0437, \u0441 \u0440\u0430\u0441\u043a\u0440\u044b\u0442\u0438\u044f \u0443\u0437\u043b\u043e\u0432. \u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u2014 \u0441 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 <strong>\u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u0438.<\/strong><\/p>\n<p>\u0412 \u0435\u0451 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0432\u0432\u0435\u0434\u0451\u043c \u043a\u043b\u0430\u0441\u0441 <em>TreeNode<\/em>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0438\u043d\u043a\u0430\u043f\u0441\u0443\u043b\u0438\u0440\u0443\u0435\u0442 \u0432 \u0441\u0435\u0431\u0435 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0440\u0430\u0441\u043a\u0440\u044b\u0442\u0438\u044f \u0442\u0430\u043a\u0438\u0445 \u0443\u0437\u043b\u043e\u0432 \u0438 \u0438\u043c\u0435\u0435\u0442 <strong>\u0437\u0430\u0446\u0435\u043f\u043a\u0443<\/strong> \u0434\u043b\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0430\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u043d\u044b\u0445 \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u0439. \u041d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0440\u0430\u0437\u0432\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u043d\u0438\u0435 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0432 \u043c\u0435\u0442\u043e\u0434\u0435 <em>getChildrenInternal<\/em>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0438\u043c\u0435\u0435\u0442 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u044b\u0439 \u0432 \u043f\u043e\u0442\u043e\u043c\u043a\u0430\u0445 <em>getChildrenHook<\/em>.<\/p>\n<pre><code class=\"java\">public class TreeNode {   private CtCodeElement element;    private List&lt;CtCodeElement> children = null;    public TreeNode(CtCodeElement element) {     this.element = element;   }    public final CtCodeElement getElement() {     return element;   }   public final void setElement(CtCodeElement element) {     this.element = element;     children = null;   }    \/\/ \u041c\u0435\u0442\u043e\u0434, \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u044e\u0449\u0438\u0439 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0440\u0430\u0441\u043a\u0440\u044b\u0442\u0438\u044f \u0443\u0437\u043b\u043e\u0432   private List&lt;CtCodeElement> getChildrenInternal() {     var current = getElement();     if (current instanceof CtLiteral) {       return Collections.emptyList();     }     var children = getChildrenHook();     if (children != null) {       return children;     } else if (current instanceof CtBinaryOperator) {       CtBinaryOperator op = (CtBinaryOperator) current;       return Arrays.asList(op.getLeftHandOperand(),                            op.getRightHandOperand());     } else if (current instanceof CtUnaryOperator) {       return Collections.singletonList(         ((CtUnaryOperator) current).getOperand()       );     } else {       return Collections.emptyList();     }   }   protected List&lt;CtCodeElement> getChildrenHook() {     return null;   }    \/\/ \u041e\u0431\u0451\u0440\u0442\u043e\u0447\u043d\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u0434\u043b\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043a\u044d\u0448\u0430 \u0443\u0437\u043b\u043e\u0432   public List&lt;CtCodeElement> getChildren() {     if (children == null) {       children = getChildrenInternal();     }     return children;   }   public boolean hasChildren() {     if (children == null) {       children = getChildrenInternal();     }     return !children.isEmpty();   } }<\/code><\/pre>\n<p>\u041c\u0435\u0441\u0442\u043e \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u044d\u0442\u043e\u0442 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u043d\u0435 \u043d\u0430\u0439\u0434\u0451\u0442. \u042d\u0442\u043e \u043c\u044b \u043e\u0441\u0442\u0430\u0432\u0438\u043c \u043f\u043e\u0442\u043e\u043c\u043a\u0430\u043c. \u0412\u0435\u0440\u043d\u0451\u043c\u0441\u044f \u0432 \u043a\u043b\u0430\u0441\u0441 \u0434\u0438\u0430\u0433\u043d\u043e\u0441\u0442\u0438\u043a\u0438 \u0438 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0442\u0443\u0434\u0430 \u043c\u0435\u0442\u043e\u0434, \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044e\u0449\u0438\u0439 \u0430\u043d\u043e\u043d\u0438\u043c\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441.<\/p>\n<pre><code class=\"java\">private TreeNode createDeclarationFinderNode(CtCodeElement el) {   return new TreeNode(el) {     @Override     public List&lt;CtCodeElement> getChildrenHook() {       var el = this.getElement();       CtExpression expr = null;        if (el instanceof CtLocalVariable) {         expr = ((CtLocalVariable) el).getDefaultExpression();       } else if (el instanceof CtAssignment) {         expr = ((CtAssignment) el).getAssignment();       } else if (el instanceof CtVariable) {         expr = Optional.of(((CtVariable) el))                        .map(CtVariable::getDeclaration)                        .map(CtDeclaration::getDefaultExpression)                        .orElse(null);       }        return expr != null ? Collections.singletonList(expr)                           : null;     }   }; }<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c, \u0435\u0441\u043b\u0438 \u043c\u044b \u0432\u0441\u0442\u0440\u0435\u0442\u0438\u043c \u043d\u0430 \u043f\u0443\u0442\u0438 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e, \u0442\u043e \u043a \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0447\u0435\u0441\u043a\u043e\u043c\u0443 \u0430\u043d\u0430\u043b\u0438\u0437\u0443 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u0441\u044f \u0441\u0435\u043c\u0430\u043d\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439, \u0438 \u043c\u044b \u0441\u043c\u043e\u0436\u0435\u043c \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043d\u043e\u0432\u044b\u0435 \u0443\u0437\u043b\u044b \u0434\u043b\u044f \u043e\u0431\u0445\u043e\u0434\u0430.<\/p>\n<p>\u041e\u0441\u0442\u0430\u043b\u0441\u044f \u043b\u0438\u0448\u044c \u0441\u0430\u043c <strong>\u0438\u0442\u0435\u0440\u0430\u0442\u043e\u0440<\/strong>. \u041f\u043e\u043c\u0438\u043c\u043e \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u044f \u0430\u0433\u0440\u0435\u0433\u0430\u0442\u0430 \u043f\u043e\u0437\u0432\u043e\u043b\u044e \u0441\u0435\u0431\u0435 \u0435\u0449\u0451 \u0432\u043e\u043b\u044c\u043d\u043e\u0441\u0442\u0435\u0439 \u0438 \u0441\u0434\u0435\u043b\u0430\u044e \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043c\u0435\u043d\u044c\u0448\u0435 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u0431\u044b\u043b \u0443\u043a\u0430\u0437\u0430\u043d \u043d\u0430 \u0434\u0438\u0430\u0433\u0440\u0430\u043c\u043c\u0435. <em>first()<\/em> \u043d\u0430\u043c \u043d\u0435 \u043d\u0443\u0436\u0435\u043d, \u0430 \u0432\u043c\u0435\u0441\u0442\u043e <em>isDone()<\/em> \u0431\u0443\u0434\u0443 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <em>getCurrent()<\/em>, \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044e\u0449\u0438\u0439 <em>null<\/em>. \u041f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0440\u0430\u0441\u043a\u0440\u044b\u0442\u0438\u044f \u0443\u0437\u043b\u043e\u0432 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442\u0441\u044f \u0442\u0438\u043f\u043e\u043c <em>TreeNode<\/em>, \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u043d\u044b\u043c \u0432 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0438\u0437 \u043b\u043e\u0433\u0438\u043a\u0438 \u0437\u0434\u0435\u0441\u044c \u043e\u0441\u0442\u0430\u043b\u0441\u044f \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u043e\u0431\u0445\u043e\u0434\u0430 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u2014 \u0432 \u0448\u0438\u0440\u0438\u043d\u0443.<\/p>\n<pre><code class=\"java\">public class TreeIterator {   private final TreeNode currentNode;   private final LinkedList&lt;CtCodeElement> unfoldedNodes = new LinkedList&lt;>();    public TreeIterator(CtCodeElement node) {      currentNode = new TreeNode(node);   }   \/\/ \u041a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0438\u0442\u0435\u0440\u0430\u0442\u043e\u0440\u0430 \u0441 \u043f\u043e\u0442\u043e\u043c\u043a\u043e\u043c TreeNode   public TreeIterator(     CtCodeElement node,     Function&lt;CtCodeElement, TreeNode> constructor   ) {     currentNode = constructor.apply(node);   }    public CtCodeElement getCurrentNode() {     return currentNode.getElement();   }   public boolean isTerminalNode() {     return !currentNode.hasChildren();   }    public CtCodeElement next() {     var children = currentNode.getChildren();     if (children != null)     unfoldedNodes.addAll(children);      if (unfoldedNodes.isEmpty())       return null;      currentNode.setElement(unfoldedNodes.pop());     return currentNode.getElement();   } }<\/code><\/pre>\n<p>\u041d\u0443 \u0438 \u043d\u0430\u043a\u043e\u043d\u0435\u0446 \u0430\u0434\u0430\u043f\u0442\u0438\u0440\u0443\u0435\u043c \u0443\u0436\u0435 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0435 \u0432 \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u043d\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u043c\u0435\u0442\u043e\u0434\u044b (\u043d\u0435 \u0432\u0441\u0442\u0440\u0435\u0447\u0430\u0432\u0448\u0438\u0435\u0441\u044f \u0440\u0430\u043d\u0435\u0435 \u0432\u044b\u0437\u043e\u0432\u044b \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u043e\u0431\u044a\u044f\u0441\u043d\u0435\u043d\u044b \u0432 \u0442\u043e\u0439 \u0436\u0435 \u0447\u0430\u0441\u0442\u0438).<\/p>\n<p>\u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u0441\u0434\u0435\u043b\u0430\u0435\u043c \u0430\u043d\u0430\u043b\u043e\u0433\u0438 <em>isAccessible<\/em>, \u043d\u043e \u0447\u0451\u0442\u043a\u043e \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u0435 \u043d\u0430 \u0432\u044b\u044f\u0432\u043b\u0435\u043d\u0438\u0435 \u0441\u043e\u0431\u043b\u044e\u0434\u0435\u043d\u0438\u044f \u0443\u0441\u043b\u043e\u0432\u0438\u044f: \u0432 \u0442\u0435\u0440\u043c\u0438\u043d\u0430\u043b\u044c\u043d\u043e\u043c \u0443\u0437\u043b\u0435 \u043d\u0435 \u0434\u043e\u043b\u0436\u043d\u043e \u0431\u044b\u0442\u044c \u043d\u0438\u0447\u0435\u0433\u043e, \u043a\u0440\u043e\u043c\u0435 \u043b\u0438\u0442\u0435\u0440\u0430\u043b\u0430 (\u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f \u2014 \u0441\u0430\u043c \u0441\u0447\u0451\u0442\u0447\u0438\u043a).<\/p>\n<pre><code class=\"java\">private static boolean isPassable(TreeIterator iterator, CtCodeElement el) {   return !iterator.isTerminalNode() || el instanceof CtLiteral; }  private static boolean isPassableOrExcludes(   TreeIterator iterator,   CtCodeElement el,   List&lt;CtVariableReference> exclude ) {   return isPassable(iterator, el)        || el instanceof CtVariable &amp;&amp; isCodeElementEqualsToAny(el, exclude); }<\/code><\/pre>\n<p>\u0410 \u0442\u0435\u043f\u0435\u0440\u044c \u043c\u043e\u0436\u043d\u043e \u0441\u043e \u0441\u043f\u043e\u043a\u043e\u0439\u043d\u043e\u0439 \u0434\u0443\u0448\u043e\u0439 \u043f\u0435\u0440\u0435\u0434\u0435\u043b\u0430\u0442\u044c \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e.<\/p>\n<pre><code class=\"java\">private boolean areInitsPredictable() {   for (var el : init) {     var iterator = new TreeIterator(el, this::createDeclarationFinderNode);     for (var node = iterator.getCurrentNode();          node != null;          node = iterator.next()     ) {       if (!isPassable(iterator, node)) {         return false;       }     }   }   return true; }<\/code><\/pre>\n<p>\u0422\u0430\u043a\u0438\u043c \u0436\u0435 \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0443\u0441\u043b\u043e\u0432\u0438\u0435.<\/p>\n<pre><code class=\"java\">private boolean isConditionPredictable(   List&lt;CtVariableReference> initReferences ) {   var iterator = new TreeIterator(condition, this::createDeclarationFinderNode);   for (     var node = iterator.getCurrentNode();     node != null;     node = iterator.next()   ) {     if (!isPassableOrExcludes(iterator, node, initReferences)) {       return false;     }   }   return true; }<\/code><\/pre>\n<p>\u0418 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u0441\u0447\u0451\u0442\u0447\u0438\u043a\u043e\u0432. \u0414\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u0430\u044f \u043b\u043e\u0433\u0438\u043a\u0430 \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u0430 \u0442\u0430\u043a\u043e\u0432\u043e\u0439 \u0432 \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u043d\u043e\u0439 \u0447\u0430\u0441\u0442\u0438.<\/p>\n<pre><code class=\"java\">private boolean areUpdatesPredictable(   List&lt;CtVariableReference> initReferences ) {   return update.stream()                .allMatch(     x -> {       if (x instanceof CtAssignment) {         var iterator = new TreeIterator(x, this::createDeclarationFinderNode);         for (           var node = iterator.getCurrentNode();           node != null;           node = iterator.next()         ) {           if (!isPassableOrExcludes(iterator, node, initReferences)           ) {             return false;           }         }         return true;       }       else {         return x instanceof CtUnaryOperator;       }   }); }<\/code><\/pre>\n<p>\u041e\u0431\u0449\u0438\u0439 \u043c\u0435\u0442\u043e\u0434 \u0431\u0435\u0437 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439.<\/p>\n<pre><code class=\"java\">public boolean areAllValuesPredictable() {   var initReferences = getInitReferences();   return    areInitsPredictable()          &amp;&amp; isConditionPredictable(initReferences)          &amp;&amp; areUpdatesPredictable(initReferences); }<\/code><\/pre>\n<p>\u0412\u043e\u0442 \u0438 \u0432\u0441\u0451! \u0424\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e \u043a\u043e\u0434 \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u0435\u043d \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u043e\u043c\u0443 \u0440\u0430\u043d\u0435\u0435, \u043d\u043e \u0442\u0435\u043f\u0435\u0440\u044c \u043d\u0430\u043f\u0438\u0441\u0430\u043d \u0432 \u043e\u0431\u044a\u0435\u043a\u0442\u043d\u043e-\u043e\u0440\u0438\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u043c \u0441\u0442\u0438\u043b\u0435, \u0438\u0437-\u0437\u0430 \u0447\u0435\u0433\u043e \u0435\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0438 \u0440\u0430\u0441\u0448\u0438\u0440\u044f\u0442\u044c. \u041d\u043e \u0438 \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c\u0441\u044f \u0442\u043e\u0436\u0435 \u0441\u0442\u0430\u043b\u043e \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0441\u043b\u043e\u0436\u043d\u0435\u0435, \u0441\u043f\u043e\u0440\u0438\u0442\u044c \u043d\u0435 \u0441\u0442\u0430\u043d\u0443 :).<\/p>\n<h3>\u0412\u044b\u0432\u043e\u0434\u044b<\/h3>\n<p>\u041d\u0430\u0434\u0435\u044e\u0441\u044c, \u0443 \u043c\u0435\u043d\u044f \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c \u043f\u0440\u043e\u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c, \u043a\u0430\u043a \u0440\u044f\u0434\u043e\u0432\u0443\u044e \u0437\u0430\u0434\u0430\u0447\u0443 \u0441 \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u044b\u043c \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u043d\u044b\u043c \u0440\u0435\u0448\u0435\u043d\u0438\u0435\u043c \u043c\u043e\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043d\u0430 \u0440\u0435\u043b\u044c\u0441\u044b \u043e\u0431\u044a\u0435\u043a\u0442\u043d\u043e-\u043e\u0440\u0438\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f. \u041a\u043e\u043d\u0435\u0447\u043d\u043e, \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043f\u043e\u0434 \u0441\u043e\u043c\u043d\u0435\u043d\u0438\u0435 \u0432\u0432\u0435\u0434\u0451\u043d\u043d\u044b\u0435 \u0432 \u0442\u0435\u043a\u0441\u0442\u0435 \u0433\u0438\u043f\u043e\u0442\u0435\u0437\u044b \u0438 \u043e\u0431\u0432\u0438\u043d\u0438\u0442\u044c \u043c\u0435\u043d\u044f \u0432 \u043e\u0432\u0435\u0440\u0438\u043d\u0436\u0438\u043d\u0438\u0440\u0438\u043d\u0433\u0435, \u043d\u043e \u0442\u0435\u043c\u0430 \u0432\u044b\u0431\u043e\u0440\u0430 \u043f\u043e\u0434\u0445\u043e\u0434\u043e\u0432 \u043a\u0430\u043a \u0442\u0430\u043a\u043e\u0432\u0430\u044f \u0432\u0441\u0451 \u0436\u0435 \u0437\u0430 \u0440\u0430\u043c\u043a\u0430\u043c\u0438 \u044d\u0442\u043e\u0439 \u0437\u0430\u043c\u0435\u0442\u043a\u0438.<\/p>\n<p>\u0412 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f\u0445 \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f, \u0441\u0442\u043e\u0438\u0442 \u043b\u0438 \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u0442\u044c \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u043e \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u0438 \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u043e\u0432 \u043d\u0430 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0435? \u0425\u043e\u0440\u043e\u0448\u043e \u043b\u0438 \u0440\u0430\u0441\u043a\u0440\u044b\u0442\u0430 \u0442\u0435\u043c\u0430 \u043d\u0430 \u0444\u043e\u043d\u0435 \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0430\u043d\u0430\u043b\u0438\u0437\u0430?<\/p>\n<p>\u041a\u0441\u0442\u0430\u0442\u0438, <a href=\"https:\/\/pvs-studio.ru\/ru\/docs\/warnings\/v6108\/\">\u0434\u0438\u0430\u0433\u043d\u043e\u0441\u0442\u0438\u043a\u0430<\/a> \u0438\u0437 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0438 \u0432\u043e\u0439\u0434\u0451\u0442 \u0432 PVS-Studio 7.29. \u0415\u0441\u043b\u0438 \u0445\u043e\u0442\u0438\u0442\u0435 \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0442\u044c \u0435\u0451 \u0432 \u0434\u0435\u043b\u0435, \u0442\u043e \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u0435\u0440\u0435\u0439\u0442\u0438 \u043f\u043e <a href=\"https:\/\/pvs-studio.ru\/ru\/pvs-studio\/try-free\/?utm_source=website&amp;utm_medium=habr&amp;utm_campaign=article&amp;utm_content=1103\">\u044d\u0442\u043e\u0439<\/a> \u0441\u0441\u044b\u043b\u043a\u0435.<\/p>\n<p>\u0410 \u0447\u0442\u043e\u0431\u044b \u0441\u043b\u0435\u0434\u0438\u0442\u044c \u0437\u0430 \u0432\u044b\u0445\u043e\u0434\u043e\u043c \u043d\u043e\u0432\u044b\u0445 \u0441\u0442\u0430\u0442\u0435\u0439 \u043f\u0440\u043e \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u043e \u043a\u043e\u0434\u0430, \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u043e\u0434\u043f\u0438\u0441\u0430\u0442\u044c\u0441\u044f \u043d\u0430:<\/p>\n<ul>\n<li>\n<p><a href=\"https:\/\/twitter.com\/Code_Analysis\">\u0422\u0432\u0438\u0442\u0442\u0435\u0440<\/a> PVS-Studio;<\/p>\n<\/li>\n<li>\n<p>\u041d\u0430\u0448 \u0435\u0436\u0435\u043c\u0435\u0441\u044f\u0447\u043d\u044b\u0439 <a href=\"https:\/\/pvs-studio.ru\/ru\/subscribe\/\">\u0434\u0430\u0439\u0434\u0436\u0435\u0441\u0442<\/a> \u0441\u0442\u0430\u0442\u0435\u0439;<\/p>\n<\/li>\n<li>\n<p>\u041c\u043e\u0439 \u043b\u0438\u0447\u043d\u044b\u0439 <a href=\"https:\/\/twitter.com\/kvolokhovskii\">\u0431\u043b\u043e\u0433<\/a>.<\/p>\n<\/li>\n<\/ul>\n<p>\u0415\u0441\u043b\u0438 \u0445\u043e\u0442\u0438\u0442\u0435 \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435\u0439 \u0441 \u0430\u043d\u0433\u043b\u043e\u044f\u0437\u044b\u0447\u043d\u043e\u0439 \u0430\u0443\u0434\u0438\u0442\u043e\u0440\u0438\u0435\u0439, \u0442\u043e \u043f\u0440\u043e\u0448\u0443 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u0441\u044b\u043b\u043a\u0443 \u043d\u0430 \u043f\u0435\u0440\u0435\u0432\u043e\u0434: Konstantin Volohovsky. <a href=\"https:\/\/pvs-studio.com\/en\/blog\/posts\/java\/1103\/\">OOP in real-life cases<\/a>.<\/p>\n<\/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\/793900\/\"> https:\/\/habr.com\/ru\/articles\/793900\/<\/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>\u0427\u0430\u0449\u0435 \u0432\u0441\u0435\u0433\u043e \u0437\u0430\u0434\u0430\u0447\u0443 \u043c\u043e\u0436\u043d\u043e \u0440\u0435\u0448\u0438\u0442\u044c \u0438\u043d\u0442\u0443\u0438\u0442\u0438\u0432\u043d\u043e \u043f\u043e\u043d\u044f\u0442\u043d\u044b\u043c \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u043d\u044b\u043c \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u043c. \u041e\u0434\u043d\u0430\u043a\u043e \u0441\u0430\u043c\u044b\u0439 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u043d\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 \u0441\u0430\u043c\u044b\u0439 \u043b\u0443\u0447\u0448\u0438\u0439. \u041f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u044e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0438, \u043a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u043d\u043e-\u043e\u0440\u0438\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u043c, \u0438 \u043a\u0430\u043a\u0443\u044e \u043f\u043e\u043b\u044c\u0437\u0443 \u044d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u0438\u043d\u0435\u0441\u0442\u0438.<\/p>\n<figure class=\"full-width\"><\/figure>\n<h3>Dive in \u0432 \u0434\u043e\u043c\u0435\u043d\u043d\u0443\u044e \u043e\u0431\u043b\u0430\u0441\u0442\u044c<\/h3>\n<p>\u0412 PVS-Studio \u043c\u044b \u0440\u0430\u0437\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u043c <a href=\"https:\/\/pvs-studio.ru\/ru\/blog\/terms\/0046\/\">\u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0430\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440<\/a> \u043a\u043e\u0434\u0430, \u0430 \u043d\u0430\u0448\u0430 \u0435\u0436\u0435\u0434\u043d\u0435\u0432\u043d\u0430\u044f \u0440\u0430\u0431\u043e\u0442\u0430 \u2014 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043d\u043e\u0432\u044b\u0445 \u0434\u0438\u0430\u0433\u043d\u043e\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u043f\u0440\u0430\u0432\u0438\u043b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0433\u0443\u0442 \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0438\u0442\u044c \u043f\u043e\u0442\u0435\u043d\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0435 \u043e\u0448\u0438\u0431\u043a\u0438 \u0432 \u043a\u043e\u0434\u0435. \u041f\u0440\u043e \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u044b \u0440\u0430\u0431\u043e\u0442\u044b \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0430\u043d\u0430\u043b\u0438\u0437\u0430 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0447\u0438\u0442\u0430\u0442\u044c <a href=\"https:\/\/pvs-studio.ru\/ru\/blog\/posts\/1048\/\">\u0442\u0443\u0442<\/a>, \u0430 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e \u043f\u0440\u043e Java \u0430\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440 \u2014 <a href=\"https:\/\/habr.com\/ru\/companies\/pvs-studio\/articles\/414669\/\">\u0437\u0434\u0435\u0441\u044c<\/a>. \u041e\u0434\u043d\u0430\u043a\u043e \u0434\u043b\u044f \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u044f \u0437\u0430\u0434\u0430\u0447\u0438 \u043d\u0430\u043c \u0445\u0432\u0430\u0442\u0438\u0442 \u043e\u0431\u044a\u044f\u0441\u043d\u0435\u043d\u0438\u044f \u043e\u0431\u0449\u0438\u0445 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u043e\u0432 \u0440\u0430\u0431\u043e\u0442\u044b \u043b\u0438\u0448\u044c \u0434\u0432\u0443\u0445 \u0438\u0437 \u043d\u0430\u0448\u0438\u0445 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432: \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0434\u0435\u0440\u0435\u0432\u0430 \u0438 \u0441\u0435\u043c\u0430\u043d\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u0438.<\/p>\n<p>\u0418\u0442\u0430\u043a, \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u0434\u0435\u0440\u0435\u0432\u043e, \u0441\u043e\u0441\u0442\u043e\u044f\u0449\u0438\u0435 \u0438\u0437 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u043a\u043e\u0434\u0430 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b. \u041d\u0435 \u0441\u0442\u0430\u043d\u0443 \u0443\u043c\u043d\u0438\u0447\u0430\u0442\u044c \u0438 \u043f\u0440\u0438\u0432\u0435\u0434\u0443 \u0441\u0445\u0435\u043c\u0443 \u0438\u0437 \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u0439 \u0432\u044b\u0448\u0435 \u0441\u0442\u0430\u0442\u044c\u0438:<\/p>\n<figure class=\"\"><\/figure>\n<p>\u041a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0434\u043e\u0433\u0430\u0434\u0430\u0442\u044c\u0441\u044f, \u044d\u0442\u043e \u2014 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u0434\u0435\u0440\u0435\u0432\u043e \u0434\u043b\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0433\u043e \u043a\u043e\u0434\u0430:<\/p>\n<pre><code class=\"cpp\">int a = x + y * z;<\/code><\/pre>\n<p>\u041a\u0440\u043e\u043c\u0435 \u044d\u0442\u043e\u0433\u043e, \u0432 \u043d\u0430\u0448\u0435\u043c \u0440\u0430\u0441\u043f\u043e\u0440\u044f\u0436\u0435\u043d\u0438\u0438 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u0430\u044f \u0441\u0435\u043c\u0430\u043d\u0442\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u043f\u0440\u043e \u043a\u0430\u0436\u0434\u044b\u0439 \u0438\u0437 \u0443\u0437\u043b\u043e\u0432: \u0442\u0438\u043f, \u043c\u0435\u0441\u0442\u043e \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u044f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0438 \u043f\u0440. \u0421 \u0431\u0430\u0437\u043e\u0439 \u0437\u0430\u043a\u043e\u043d\u0447\u0438\u043b\u0438! \u041e\u0441\u0442\u0430\u043b\u044c\u043d\u043e\u0435 \u0440\u0430\u0437\u0431\u0435\u0440\u0451\u043c \u043f\u043e \u0445\u043e\u0434\u0443 \u0434\u0435\u043b\u0430. \u0414\u043b\u044f \u043f\u0440\u043e\u0441\u0442\u043e\u0442\u044b \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u044f \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043a\u043e\u0435-\u0433\u0434\u0435 \u044f \u0441\u0440\u0435\u0436\u0443 \u0443\u0433\u043b\u044b \u0438 \u043d\u0430\u043c\u0435\u0440\u0435\u043d\u043d\u043e \u0443\u043f\u0440\u043e\u0449\u0443 API.<\/p>\n<h3>\u041f\u043e\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 \u0437\u0430\u0434\u0430\u0447\u0438<\/h3>\n<h4>\u041f\u0440\u0435\u0434\u043f\u043e\u0441\u044b\u043b\u043a\u0430<\/h4>\n<p>\u0422\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435 <a href=\"https:\/\/pvs-studio.ru\/ru\/docs\/warnings\/v6108\/\">\u0434\u0438\u0430\u0433\u043d\u043e\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u043e<\/a>: \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0435\u043d\u0438\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u0442\u0438\u043f\u0430 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0441\u0447\u0451\u0442\u0447\u0438\u043a\u0430 \u0446\u0438\u043a\u043b\u0430 <em>for<\/em>. \u0415\u0433\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0442\u0440\u0438\u0432\u0438\u0430\u043b\u044c\u043d\u0430\u044f: \u043d\u0430\u0434\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u0442\u0438\u043f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445-\u0441\u0447\u0451\u0442\u0447\u0438\u043a\u043e\u0432 (\u043f\u043b\u044e\u0441 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u043e\u0441\u043e\u0431\u044b\u0435 \u0441\u043b\u0443\u0447\u0430\u0438, \u0432\u0440\u043e\u0434\u0435 \u0446\u0438\u043a\u043b\u043e\u0432 \u0432\u0438\u0434\u0430 <em>for (;;)<\/em>). \u0414\u0430\u043b\u0435\u0435 \u0432\u0441\u0442\u0430\u0451\u0442 \u0432\u043e\u043f\u0440\u043e\u0441 \u043e\u0431 \u0443\u0440\u043e\u0432\u043d\u0435 \u043f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u044f. \u0418 \u0432\u043e\u0442 \u0442\u0443\u0442 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f \u0441\u0430\u043c\u043e\u0435 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e\u0435.<\/p>\n<p>\u041e\u0434\u043d\u0438\u043c \u0438\u0437 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0445 \u0440\u0438\u0441\u043a\u043e\u0432 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0441\u0447\u0451\u0442\u0447\u0438\u043a\u043e\u0432 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u0442\u0438\u043f\u0430 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f <a href=\"https:\/\/cwe.mitre.org\/data\/definitions\/834.html\">\u043b\u0438\u0448\u043d\u0438\u0435<\/a> \u2014 \u043b\u0438\u0431\u043e \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u044e\u0449\u0438\u0435 \u2014 \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u0438. \u0423\u0447\u0438\u0442\u044b\u0432\u0430\u044f, \u0447\u0442\u043e <em>for<\/em> \u0447\u0430\u0441\u0442\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u044e\u0442 \u043a\u0430\u043a \u0446\u0438\u043a\u043b \u0441 \u0437\u0430\u0440\u0430\u043d\u0435\u0435 \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u044b\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e\u043c \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u0439, \u0432 \u0435\u0433\u043e \u0441\u043b\u0443\u0447\u0430\u0435 \u0442\u0430\u043a\u043e\u0435 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u0433\u0443\u0431\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u043c. \u041d\u043e \u0432\u0435\u0434\u044c \u043d\u0430 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0435 \u0434\u0430\u043b\u0435\u043a\u043e \u043d\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 \u043b\u044e\u0434\u0438 \u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u0430\u043c\u0438 \u043f\u043e \u0438\u0445 \u043f\u0440\u044f\u043c\u043e\u043c\u0443 \u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044e (\u0446\u0438\u043a\u043b <em>for<\/em> \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e <em>while<\/em>). \u0418 \u043a\u0430\u043a \u043d\u0430\u043c \u043e\u0442\u043b\u0438\u0447\u0438\u0442\u044c \u043e\u0434\u043d\u043e \u043d\u0430\u043c\u0435\u0440\u0435\u043d\u0438\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442\u0430 \u043e\u0442 \u0434\u0440\u0443\u0433\u043e\u0433\u043e? \u042d\u0432\u0440\u0438\u0441\u0442\u0438\u043a\u0430!<\/p>\n<h4>\u0417\u0430\u0434\u0430\u0447\u0430<\/h4>\n<p>\u0418\u043c\u0435\u0435\u043c <strong>\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u043e<\/strong>: \u0435\u0441\u043b\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0432\u0441\u0435\u0445 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0432 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0438 \u0446\u0438\u043a\u043b\u0430 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0438\u0437 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0430 \u043c\u0435\u0442\u043e\u0434\u0430, \u0442\u043e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442 \u044f\u0432\u043d\u043e \u043e\u0436\u0438\u0434\u0430\u043b \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u043e\u0433\u043e \u0447\u0438\u0441\u043b\u0430 \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u0439. \u0412 \u0442\u0430\u043a\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043c\u044b \u0432\u044b\u0434\u0430\u0451\u043c \u043f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u0435 \u0432\u0442\u043e\u0440\u043e\u0433\u043e \u0443\u0440\u043e\u0432\u043d\u044f. \u0418\u043d\u0430\u0447\u0435 \u043c\u044b \u043d\u0435 \u043c\u043e\u0436\u0435\u043c \u0431\u044b\u0442\u044c \u0443\u0432\u0435\u0440\u0435\u043d\u044b \u0432 \u043d\u0430\u043c\u0435\u0440\u0435\u043d\u0438\u044f\u0445 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442\u0430 \u0438 \u0432\u044b\u0434\u0430\u0451\u043c \u0442\u0440\u0435\u0442\u0438\u0439 \u0443\u0440\u043e\u0432\u0435\u043d\u044c.<\/p>\n<details class=\"spoiler\">\n<summary>\u0421\u0442\u043e\u043f, \u0430 \u043f\u043e\u0447\u0435\u043c\u0443 \u0432\u0442\u043e\u0440\u043e\u0433\u043e \u0438 \u0442\u0440\u0435\u0442\u044c\u0435\u0433\u043e? \u0418 \u0447\u0442\u043e \u044d\u0442\u043e \u0432\u043e\u043e\u0431\u0449\u0435 \u0437\u043d\u0430\u0447\u0438\u0442?<\/summary>\n<div class=\"spoiler__content\">\n<p>\u041f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u044f \u0432 \u043d\u0430\u0448\u0435\u043c \u0430\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440\u0435 \u0438\u043c\u0435\u044e\u0442 \u0442\u0440\u0438 \u0443\u0440\u043e\u0432\u043d\u044f \u0438 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u044e\u0442 \u0442\u043e, \u043d\u0430\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043c\u044b \u0443\u0432\u0435\u0440\u0435\u043d\u044b \u0432 \u044d\u0442\u043e\u043c \u0441\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u043d\u0438\u0438. \u041f\u0435\u0440\u0432\u044b\u0439 \u0443\u0440\u043e\u0432\u0435\u043d\u044c \u0441\u0430\u043c\u044b\u0439 \u0434\u043e\u0441\u0442\u043e\u0432\u0435\u0440\u043d\u044b\u0439, \u0442\u0440\u0435\u0442\u0438\u0439 \u0441\u0430\u043c\u044b\u0439 \u0441\u043e\u043c\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439.<\/p>\n<p>\u0412 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u044f \u043f\u0440\u0435\u0434\u043f\u043e\u0447\u0451\u043b \u043f\u0435\u0440\u0432\u043e\u043c\u0443 \u0443\u0440\u043e\u0432\u043d\u044e \u0432\u0442\u043e\u0440\u043e\u0439 \u043f\u043e \u043f\u0440\u0438\u0447\u0438\u043d\u0435 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u043d\u0435 \u043b\u044e\u0431\u043e\u0439 \u0441\u0447\u0451\u0442\u0447\u0438\u043a \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u0442\u0438\u043f\u0430 \u043f\u0440\u0438\u0432\u0435\u0434\u0451\u0442 \u043a \u043b\u0438\u0448\u043d\u0435\u0439 \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u0438. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u044d\u0442\u0438 \u0434\u0432\u0430 \u0446\u0438\u043a\u043b\u0430 \u043e\u0442\u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0440\u0430\u0437 (\u043f\u043e 20):<\/p>\n<pre><code class=\"cpp\">for (double i = 0.0; i &lt; 1.0; i += 0.05) { } for (double i = 0.0; i &lt;= 1.0; i += 0.05) { }<\/code><\/pre>\n<p>\u0412 \u043f\u0435\u0440\u0432\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u043e\u0436\u0438\u0434\u0430\u0435\u043c\u043e, \u0432 \u0442\u043e \u0432\u0440\u0435\u043c\u044f \u043a\u0430\u043a \u0432\u043e \u0432\u0442\u043e\u0440\u043e\u043c \u043e\u0434\u043d\u0430 \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u044f \u043f\u0440\u043e\u043f\u0430\u043b\u0430. <a href=\"https:\/\/cwe.mitre.org\/data\/definitions\/1077.html\">\u041d\u0435 \u0441\u0442\u043e\u0438\u0442<\/a> \u043e\u0436\u0438\u0434\u0430\u0442\u044c \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u044b\u0445 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432 \u043f\u0440\u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0435 \u043d\u0430 \u0440\u0430\u0432\u0435\u043d\u0441\u0442\u0432\u043e \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u0447\u0438\u0441\u043b\u0430.<\/p>\n<p>\u0422\u0440\u0435\u0442\u0438\u0439 \u0443\u0440\u043e\u0432\u0435\u043d\u044c \u0432\u044b\u0434\u0430\u0451\u0442\u0441\u044f \u043d\u0430 \u0441\u043b\u0443\u0447\u0430\u0439, \u0435\u0441\u043b\u0438 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u0439 \u0432\u0441\u0451-\u0442\u0430\u043a\u0438 \u0434\u043e\u043b\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0431\u044b\u0442\u044c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u044b\u043c, \u0430 \u0446\u0438\u043a\u043b \u043f\u0440\u043e\u0441\u0442\u043e \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0432 \u043c\u0435\u0442\u043e\u0434\u0435, \u043b\u0438\u0431\u043e \u043d\u0430 \u0440\u0435\u0434\u043a\u0438\u0439, \u043d\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0439 <a href=\"https:\/\/cwe.mitre.org\/data\/definitions\/835.html\">\u0431\u0435\u0441\u043a\u043e\u043d\u0435\u0447\u043d\u044b\u0439 \u0446\u0438\u043a\u043b<\/a> (CVE-2006-6499).<\/p>\n<\/div>\n<\/details>\n<h4>\u041e\u0436\u0438\u0434\u0430\u0435\u043c\u044b\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442<\/h4>\n<p>\u042d\u0442\u0430\u043b\u043e\u043d\u043d\u044b\u0439 \u0441\u043b\u0443\u0447\u0430\u0439 \u2014 \u0432\u0441\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043f\u0440\u044f\u043c\u043e \u0432 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0438 \u0446\u0438\u043a\u043b\u0430 \u2014 \u0434\u043b\u044f \u043f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u044f \u0432\u0442\u043e\u0440\u043e\u0433\u043e \u0443\u0440\u043e\u0432\u043d\u044f:<\/p>\n<pre><code class=\"java\">for (double i = 0.0; i &lt; 1.0; i += 0.1) { }<\/code><\/pre>\n<p>\u041d\u043e \u043d\u0430\u043c \u043d\u0430\u0434\u043e \u043d\u0430\u0439\u0442\u0438 \u0438 \u0442\u0430\u043a\u0438\u0435 \u0441\u043b\u0443\u0447\u0430\u0438:<\/p>\n<pre><code class=\"java\">double lowerBoundary = 0.5; for (double i = lowerBoundary; i &lt; 1.0; i += 0.1) { } <\/code><\/pre>\n<p>\u0418 \u0442\u0430\u043a\u0438\u0435:<\/p>\n<pre><code class=\"java\">double shift = 0.5; double lowerBoundary = 0.0 + shift; double upperBoundary = 1.0; for (double i = lowerBoundary; i &lt; shift + upperBoundary; i += 0.1) { } <\/code><\/pre>\n<p>\u0412 \u0441\u043b\u0443\u0447\u0430\u0435 \u0436\u0435, \u0435\u0441\u043b\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0432 \u0446\u0438\u043a\u043b \u043f\u043e\u043f\u0430\u043b\u0438 \u0438\u0437\u0432\u043d\u0435 \u2014 \u043f\u043e\u043b\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u0438\u043b\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u043c\u0435\u0442\u043e\u0434\u043e\u0432, \u2014 \u043c\u044b \u0432\u044b\u0434\u0430\u0451\u043c \u0442\u0440\u0435\u0442\u0438\u0439 \u0443\u0440\u043e\u0432\u0435\u043d\u044c.<\/p>\n<h3>\u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0440\u0435\u0448\u0435\u043d\u0438\u044f<\/h3>\n<p>\u0418\u0442\u0430\u043a, \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u0443\u0437\u0435\u043b \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0434\u0435\u0440\u0435\u0432\u0430 \u0441 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0435\u043c \u0446\u0438\u043a\u043b\u0430 <em>for<\/em>, \u0430 \u0432\u0435\u0440\u043d\u0443\u0442\u044c \u043d\u0430\u043c \u043d\u0430\u0434\u043e <em>true<\/em> \u0438\u043b\u0438 <em>false<\/em> \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0442\u043e\u0433\u043e, \u0432\u0441\u0435 \u043b\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0438\u0437 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0430.<\/p>\n<p>\u0412 \u043a\u0430\u0436\u0434\u043e\u0439 \u0438\u0437 \u0441\u0435\u043a\u0446\u0438\u0439 \u0446\u0438\u043a\u043b\u0430: \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0441\u0447\u0451\u0442\u0447\u0438\u043a\u043e\u0432, \u0438\u0445 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u0438 \u0443\u0441\u043b\u043e\u0432\u0438\u0435 \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u2014 \u043d\u0430\u0434\u043e \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0432 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u044f\u0445.<\/p>\n<figure class=\"full-width\"><\/figure>\n<p>\u0412\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u043c\u043e\u0433\u0443\u0442 \u0441\u043e\u0441\u0442\u043e\u044f\u0442\u044c \u0438\u0437 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432:<\/p>\n<ul>\n<li>\n<p>\u041b\u0438\u0442\u0435\u0440\u0430\u043b\u044b, \u043d\u0430\u043b\u0438\u0447\u0438\u0435 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043d\u0430\u0441 \u0438 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u0435\u0442;<\/p>\n<\/li>\n<li>\n<p>\u0423\u043d\u0430\u0440\u043d\u044b\u0435 \u0438 \u0431\u0438\u043d\u0430\u0440\u043d\u044b\u0435 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u044b: \u0438\u0445 \u043d\u0430\u0434\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0440\u0430\u0441\u043a\u0440\u044b\u0442\u044c;<\/p>\n<\/li>\n<li>\n<p>\u041f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435: \u043d\u0443\u0436\u043d\u043e \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435, \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u043e\u0435 \u0438\u0437 \u0438\u0445 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438;<\/p>\n<\/li>\n<li>\n<p>\u041b\u044e\u0431\u044b\u0435 \u0434\u0440\u0443\u0433\u0438\u0435: \u043f\u043e\u043b\u0435 \u043a\u043b\u0430\u0441\u0441\u0430, \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u0438 \u043f\u0440. \u0412 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043e\u0431\u0445\u043e\u0434 \u043c\u043e\u0436\u043d\u043e \u043e\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0442\u044c.<\/p>\n<\/li>\n<\/ul>\n<p>\u041e\u0447\u0435\u0432\u0438\u0434\u043d\u043e, \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0441\u043e\u0441\u0435\u0434\u043d\u0438\u0435 \u0443\u0437\u043b\u044b \u0432 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0447\u0435\u0441\u043a\u043e\u043c \u0434\u0435\u0440\u0435\u0432\u0435, \u0432\u0435\u0434\u044c \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u043c\u043e\u0433\u0443\u0442 \u0441\u043e\u0441\u0442\u043e\u044f\u0442\u044c \u0438\u0437 \u0434\u0440\u0443\u0433\u0438\u0445 \u043f\u043e\u0434\u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0439, \u0430 \u043e\u0434\u043d\u0438 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0437\u0430\u0432\u0438\u0441\u0435\u0442\u044c \u043e\u0442 \u0434\u0440\u0443\u0433\u0438\u0445. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043d\u0430\u043c \u043d\u0443\u0436\u0435\u043d \u0441\u043f\u043e\u0441\u043e\u0431 \u043e\u0431\u043e\u0439\u0442\u0438 \u0432\u0441\u0451 \u0434\u0435\u0440\u0435\u0432\u043e \u0446\u0435\u043b\u0438\u043a\u043e\u043c, \u043d\u0435 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0432\u0430\u044f\u0441\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u043e\u0441\u0435\u0434\u043d\u0438\u043c\u0438 \u0443\u0437\u043b\u0430\u043c\u0438 (\u0438 \u0442\u0435\u043c\u0438, \u0447\u0442\u043e \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u044b \u0438\u0437 \u0441\u0435\u043c\u0430\u043d\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0430\u043d\u0430\u043b\u0438\u0437\u0430).<\/p>\n<p>\u0423\u0441\u043b\u043e\u0432\u0438\u0435\u043c \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u0431\u0443\u0434\u0435\u0442 \u043e\u0431\u0445\u043e\u0434 \u0432\u0441\u0435\u0445 \u0442\u0435\u0440\u043c\u0438\u043d\u0430\u043b\u044c\u043d\u044b\u0445 \u0443\u0437\u043b\u043e\u0432 (\u0442\u0430\u043a\u0438\u0445, \u0447\u0442\u043e \u043d\u0435 \u0438\u043c\u0435\u044e\u0442 \u0434\u043e\u0447\u0435\u0440\u043d\u0438\u0445 \u0443\u0437\u043b\u043e\u0432). \u0415\u0441\u043b\u0438 \u0432\u0441\u0435 \u0442\u0435\u0440\u043c\u0438\u043d\u0430\u043b\u044c\u043d\u044b\u0435 \u0443\u0437\u043b\u044b \u0432 \u043e\u0431\u0445\u043e\u0434\u0435 \u2014 \u044d\u0442\u043e \u043b\u0438\u0442\u0435\u0440\u0430\u043b\u044b, \u0442\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0443\u0435\u043c\u044b\u043c. \u0412 \u043e\u0431\u0440\u0430\u0442\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0444\u0438\u043a\u0441\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u043d\u0435\u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0443\u0435\u043c\u043e\u0441\u0442\u044c.<\/p>\n<h3>\u041f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u043d\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435<\/h3>\n<p>\u0418\u0442\u0430\u043a, \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043e\u0431\u043e\u0439\u0442\u0438 \u0434\u0435\u0440\u0435\u0432\u043e \u043d\u0435\u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e\u0439 \u0433\u043b\u0443\u0431\u0438\u043d\u044b. \u041a\u043b\u0430\u0441\u0441\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u2014 \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u044f. \u041d\u0430\u043f\u0438\u0448\u0435\u043c \u043c\u0435\u0442\u043e\u0434 <em>isAccessible<\/em>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u043d\u0430 \u0432\u0445\u043e\u0434 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435, \u043f\u043e\u0441\u043b\u0435 \u0447\u0435\u0433\u043e \u0440\u0430\u0441\u043a\u0440\u044b\u0432\u0430\u0435\u0442 \u0435\u0433\u043e \u0438 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u043e\u0441\u0442\u044c \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0430 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439.<\/p>\n<pre><code class=\"java\">private static boolean isAccessible(CtCodeElement el) {   return isAccessible(el, Collections.emptyList()); }  private static boolean isAccessible(   CtCodeElement el,   List&lt;CtVariable> exclude ) {   if (isCodeElementEqualsToAny(el, exclude)) {     return true;   }    var expressionElements = new LinkedList&lt;CtCodeElement>();   parseExpression(el, expressionElements);   return expressionElements.stream().allMatch(x -> x instanceof CtLiteral); }  private static void parseExpression(   CtCodeElement el,   List&lt;CtCodeElement> terminalNodes ) {   if (el instanceof CtBinaryOperator) {     var op = (CtBinaryOperator) el;     parseExpression(op.getLeftHandOperand(), terminalNodes);     parseExpression(op.getRightHandOperand(), terminalNodes);   } else if (el instanceof CtUnaryOperator) {     parseExpression(((CtUnaryOperator)el).getOperand(), terminalNodes);   } else if (el instanceof CtVariable) {     parseExpression(Optional.ofNullable(((CtVariable)el).getDeclaration())                             .map(CtDeclaration::getDefaultExpression)                             .orElse(null), terminalNodes);   } else {     terminalNodes.add(el);   } }<\/code><\/pre>\n<details class=\"spoiler\">\n<summary>\u041f\u043e\u044f\u0441\u043d\u0435\u043d\u0438\u044f \u043f\u043e \u043f\u043e\u0432\u043e\u0434\u0443 isCodeElementEqualsToAny<\/summary>\n<div class=\"spoiler__content\">\n<p>\u0412 \u0441\u0435\u043a\u0446\u0438\u044f\u0445 \u0443\u0441\u043b\u043e\u0432\u0438\u044f \u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0441\u0447\u0451\u0442\u0447\u0438\u043a\u043e\u0432 \u043d\u0435\u0442 \u0441\u043c\u044b\u0441\u043b\u0430 \u0440\u0430\u0441\u043a\u0440\u044b\u0432\u0430\u0442\u044c \u0441\u0430\u043c \u0441\u0447\u0451\u0442\u0447\u0438\u043a, \u0432\u0435\u0434\u044c \u0435\u0433\u043e \u043c\u044b \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u043c \u043f\u0435\u0440\u0432\u044b\u043c \u0434\u0435\u043b\u043e\u043c. \u0412\u043e\u0442 \u043a\u043e\u0434 \u044d\u0442\u043e\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0430.<\/p>\n<pre><code class=\"java\">private static boolean isCodeElementEqualsToAny(   CtCodeElement el,    List&lt;CtVariable> toCompare ) {   return el instanceof CtVariable          &amp;&amp; toCompare.stream()                      .anyMatch(x -> ((CtVariable)el).equals(x)); }<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<p>\u0421\u0430\u043c\u0430\u044f \u0441\u043b\u043e\u0436\u043d\u0430\u044f \u0440\u0430\u0431\u043e\u0442\u0430 \u0441\u0434\u0435\u043b\u0430\u043d\u0430. \u041e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0438\u0437 \u043a\u0430\u0436\u0434\u043e\u0439 \u0441\u0435\u043a\u0446\u0438\u0438 \u0446\u0438\u043a\u043b\u0430. \u0412 \u0441\u0435\u043a\u0446\u0438\u0438 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0432\u0441\u0451 \u043f\u0440\u043e\u0441\u0442\u043e: \u0441\u0447\u0451\u0442\u0447\u0438\u043a \u043c\u043e\u0436\u0435\u0442 \u043e\u0431\u044a\u044f\u0432\u043b\u044f\u0442\u044c\u0441\u044f \u043b\u0438\u0431\u043e \u043f\u0440\u044f\u043c\u043e \u0432 \u044d\u0442\u043e\u0439 \u0441\u0435\u043a\u0446\u0438\u0438, \u043b\u0438\u0431\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0443\u0436\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0430\u044f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f. \u0412 \u043b\u044e\u0431\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043d\u0430\u0441 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u0435\u0442 \u043b\u0438\u0448\u044c \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435, \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043f\u0440\u0438\u0441\u0432\u0430\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0441\u0447\u0451\u0442\u0447\u0438\u043a\u0443. \u0421\u0447\u0451\u0442\u0447\u0438\u043a\u043e\u0432 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0431\u043e\u043b\u0435\u0435 \u043e\u0434\u043d\u043e\u0433\u043e, \u0442\u0430\u043a \u0447\u0442\u043e \u044d\u0442\u043e \u043c\u044b \u0442\u043e\u0436\u0435 \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u043c.<\/p>\n<pre><code class=\"java\">public boolean areInitsPredictable() {   return init.stream().allMatch(x -> {     if (x instanceof CtLocalVariable) {       return isAccessible(((CtLocalVariable)x).getDefaultExpression());     } else if (x instanceof CtAssignment) {       return isAccessible(((CtAssignment)x).getAssignment());     } else {       return false;     }   }); }<\/code><\/pre>\n<p>\u0421 \u0443\u0441\u043b\u043e\u0432\u0438\u0435\u043c \u043f\u0440\u043e\u0449\u0435 \u0432\u0441\u0435\u0433\u043e: \u043b\u0438\u0448\u044c \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c, \u0447\u0442\u043e \u044d\u0442\u043e \u0432\u043e\u043e\u0431\u0449\u0435 \u0431\u0438\u043d\u0430\u0440\u043d\u044b\u0439 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440 (\u0438\u043d\u0430\u0447\u0435 \u0443 \u043d\u0430\u0441 \u043b\u0430\u043f\u043a\u0438), \u043f\u043e\u0441\u043b\u0435 \u0447\u0435\u0433\u043e \u0440\u0430\u0441\u043a\u0440\u044b\u0432\u0430\u0435\u043c \u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u043e\u043f\u0435\u0440\u0430\u043d\u0434\u044b.<\/p>\n<pre><code class=\"java\">public boolean isConditionPredictable(   List&lt;CtVariableReference> initReferences ) {   var operator = safeCast(condition, CtBinaryOperator.class);   if (operator == null)     return false;    return Stream.of(     operator.getLeftHandOperand(),     operator.getRightHandOperand()   ).allMatch(x -> isAccessible(x, initReferences)); }<\/code><\/pre>\n<details class=\"spoiler\">\n<summary>\u0427\u0442\u043e \u0437\u0430 safeCast?<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"java\">@Nullable public static &lt;T> T safeCast(Object obj, @Nullable Class&lt;T> cl) {   return cl != null &amp;&amp; cl.isInstance(obj) ? cl.cast(obj) : null; }<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<p>\u0418 \u043d\u0430\u043f\u043e\u0441\u043b\u0435\u0434\u043e\u043a \u0441\u0435\u043a\u0446\u0438\u044f \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0441\u0447\u0451\u0442\u0447\u0438\u043a\u043e\u0432. \u0417\u0434\u0435\u0441\u044c \u0432\u0441\u0451 \u043f\u043e\u0447\u0442\u0438 \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e: \u0431\u0438\u043d\u0430\u0440\u043d\u044b\u0439 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440 \u0440\u0430\u0441\u043a\u0440\u044b\u0432\u0430\u0435\u043c, \u0430 \u043d\u0430 \u0443\u043d\u0430\u0440\u043d\u044b\u0445 \u2014 \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0438\u043d\u043a\u0440\u0435\u043c\u0435\u043d\u0442\u0430\u0445 \u2014 \u0441\u0440\u0430\u0437\u0443 \u043e\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c\u0441\u044f.<\/p>\n<pre><code class=\"java\">public boolean areUpdatesPredictable(   List&lt;CtVariableReference> initReferences ) {   return update.stream().allMatch(x -> {     if (x instanceof CtAssignment) {       return isAccessible(         ((CtAssignment)x).getAssignment(),         initReferences       );     } else {       return x instanceof CtUnaryOperator;     }   }); }<\/code><\/pre>\n<p>\u0418 \u0441\u043e\u0435\u0434\u0438\u043d\u044f\u0435\u043c \u0432\u0441\u0451 \u044d\u0442\u043e \u0432\u043e\u0435\u0434\u0438\u043d\u043e:<\/p>\n<pre><code class=\"java\">public boolean areAllValuesPredictable() {   var initReferences = getInitReferences();   return    areInitsPredictable()          &amp;&amp; isConditionPredictable(initReferences)          &amp;&amp; areUpdatesPredictable(initReferences); }<\/code><\/pre>\n<details class=\"spoiler\">\n<summary>\u041c\u043d\u0435 \u043e\u0447\u0435\u043d\u044c \u043d\u0430\u0434\u043e \u0437\u043d\u0430\u0442\u044c, \u0447\u0442\u043e \u0432\u043d\u0443\u0442\u0440\u0438 getInitReferences<\/summary>\n<div class=\"spoiler__content\">\n<p>\u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0432 \u043e\u0431\u0449\u0435\u043c \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u0435\u043d \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044e \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0439 \u0438\u0437 \u0441\u0435\u043a\u0446\u0438\u0438 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438, \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u0430 \u043b\u0435\u0432\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438\/\u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u044f.<\/p>\n<pre><code class=\"java\">public List&lt;CtVariable> getInitReferences() {   var res = new LinkedList&lt;CtVariable>();   init.forEach(x -> {     if (x instanceof CtLocalVariable) {         res.add(((CtLocalVariable) x).getVariable());     } else if (x instanceof CtAssignment) {       var variableWrite = safeCast(         ((CtAssignment) x).getAssigned(),         CtVariableWrite.class       );       if (variableWrite != null) {         res.add(variableWrite.getVariable());       }     }   });   return res; }<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<p>\u0412\u0441\u0451 \u0433\u043e\u0442\u043e\u0432\u043e! \u041a\u043e\u0434 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442, \u0442\u0435\u0441\u0442\u044b \u043f\u0440\u043e\u0445\u043e\u0434\u044f\u0442, \u043f\u043e\u0442\u0435\u043d\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0435 \u043e\u0448\u0438\u0431\u043a\u0438 \u043d\u0430\u0445\u043e\u0434\u044f\u0442\u0441\u044f.<\/p>\n<h3>\u041e\u0431\u044a\u0435\u043a\u0442\u043d\u043e-\u043e\u0440\u0438\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435<\/h3>\n<h4>\u0410 \u0437\u0430\u0447\u0435\u043c?<\/h4>\n<p>\u041f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u043d\u044b\u0439 \u043a\u043e\u0434 \u0432\u043f\u043e\u043b\u043d\u0435 \u0447\u0438\u0442\u0430\u0435\u043c\u044b\u0439, \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u0437\u0430\u0434\u0430\u0447\u0443. \u0420\u0430\u0437\u0432\u0435 \u0442\u0443\u0442 \u043c\u043e\u0436\u043d\u043e \u0447\u0442\u043e-\u0442\u043e \u0443\u043b\u0443\u0447\u0448\u0438\u0442\u044c?<\/p>\n<p>\u0412\u043e\u043f\u0440\u043e\u0441, \u043a\u043e\u043d\u0435\u0447\u043d\u043e, \u0434\u0438\u0441\u043a\u0443\u0441\u0441\u0438\u043e\u043d\u043d\u044b\u0439, \u0438\u0431\u043e <a href=\"https:\/\/ru.wikipedia.org\/wiki\/KISS_(%D0%BF%D1%80%D0%B8%D0%BD%D1%86%D0%B8%D0%BF)\">KISS<\/a>, <a href=\"https:\/\/ru.wikipedia.org\/wiki\/YAGNI\">YAGNI<\/a> \u0438 \u0432\u0441\u0451 \u0442\u0430\u043a\u043e\u0435. \u041d\u043e \u0432\u0441\u0451 \u0436\u0435 \u0441\u0442\u043e\u0438\u0442 \u0438\u043d\u043e\u0433\u0434\u0430 \u0432\u0441\u043f\u043e\u043c\u0438\u043d\u0430\u0442\u044c, \u0447\u0442\u043e \u0440\u0430\u0431\u043e\u0442\u0430 \u043d\u0435 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0440\u0430\u043c\u043a\u0430\u043c\u0438 \u043e\u0434\u043d\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0438, \u0438\u0437-\u0437\u0430<\/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-368278","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/368278","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=368278"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/368278\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=368278"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=368278"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=368278"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}