{"id":351143,"date":"2023-08-02T15:02:40","date_gmt":"2023-08-02T15:02:40","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=351143"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=351143","title":{"rendered":"<span>\u0420\u0430\u0437\u043d\u0438\u0446\u0430 \u043c\u0435\u0436\u0434\u0443 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u043e\u0439 \u0438 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0435\u0439 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u0432 Java \u043d\u0430 \u043b\u044e\u0431\u043e\u043f\u044b\u0442\u043d\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\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-1\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u041f\u0440\u0438\u0432\u0435\u0442, \u0441\u0435\u0433\u043e\u0434\u043d\u044f\u0448\u043d\u044f\u044f \u0441\u0442\u0430\u0442\u044c\u044f \u0431\u0443\u0434\u0435\u0442 \u043e \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0442\u043e\u043d\u043a\u043e\u0441\u0442\u044f\u0445 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u0438 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u0438 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043e \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 (\u0441\u043e\u0432\u0441\u0435\u043c \u0447\u0443\u0442\u044c-\u0447\u0443\u0442\u044c \u0438 \u0432 \u0441\u0430\u043c\u043e\u043c \u043a\u043e\u043d\u0446\u0435).<\/p>\n<p>  <\/p>\n<p>\u041f\u043e\u0432\u043e\u0434\u043e\u043c \u0434\u043b\u044f \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0441\u0442\u0430\u0442\u044c\u0438 \u0441\u0442\u0430\u043b <a href=\"https:\/\/stackoverflow.com\/questions\/76260269\/classes-used-in-method-body-are-loaded-lazily-or-eagerly-depending-on-method-ret\" rel=\"nofollow noopener noreferrer\">\u0432\u043e\u043f\u0440\u043e\u0441<\/a> \u043d\u0430 StackOverflow. \u041e\u0442\u043a\u0440\u043e\u0439\u0442\u0435, \u043d\u043e \u043d\u0435 \u0442\u043e\u0440\u043e\u043f\u0438\u0442\u0435\u0441\u044c \u0447\u0438\u0442\u0430\u0442\u044c \u043e\u0442\u0432\u0435\u0442 \ud83d\ude09<\/p>\n<p><a name=\"habracut\"><\/a>  <\/p>\n<p>\u0414\u0430\u043b\u0435\u0435 \u0441\u0430\u043c \u0432\u043e\u043f\u0440\u043e\u0441:<\/p>\n<p>  <\/p>\n<blockquote><p>I&#8217;m making an API wrapper library that supports multiple versions of the API. A public class was added in the recent API version. I&#8217;m trying to compile the wrapper against the latest API version and make it check in run time if the new class exists. And I&#8217;m trying to avoid reflection and instead catch <code>NoClassDefFoundError<\/code> and set a flag accordingly. It works until I add a method that returns the class which the non-existent class extends. Then my library fails to load. I mean: <code>BaseClass<\/code> exists; <code>ChildClass<\/code> does not exist; the method uses <code>ChildClass<\/code> internally. If the method returns <code>BaseClass<\/code> the library fails to load. If the method returns <code>Object<\/code> the library loads and the error is deferred and can be caught.<\/p><\/blockquote>\n<p>  <\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">\u041a\u043e\u0434 \u0434\u043b\u044f \u0432\u043e\u0441\u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u044f<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"java\">public class TestLoading {    public static void main(String[] args) throws Exception {     Class.forName(BaseClass.class.getName());     URL classFileB = TestLoading.class.getResource(TestLoading.class.getSimpleName() + \"$ChildClass.class\");     if (classFileB != null) {       if (!\"file\".equals(classFileB.getProtocol())) {         throw new UnsupportedOperationException();       }       Path path = new File(classFileB.getPath()).toPath();       System.out.println(\"deleting: \" + path);       Files.delete(path);     }      loadMyClass(ObjectReturner.class.getName());     loadMyClass(BaseClassReturner.class.getName());   }    private static void loadMyClass(String name) {     System.out.println(\"loading: \" + name + \"...\");     try {       Class.forName(name);     } catch (Throwable e) {       e.printStackTrace(System.out);     }   }    public static class BaseClass {     static {       System.out.println(\"loaded: \" + BaseClass.class.getName());     }   }    public static class ChildClass extends BaseClass {     static {       System.out.println(\"loaded: \" + ChildClass.class.getName());     }   }    public static class ObjectReturner {     static {       System.out.println(\"loaded: \" + ObjectReturner.class.getName());     }      public Object getObject() {       return new ChildClass();     }   }    public static class BaseClassReturner {     static {       System.out.println(\"loaded: \" + BaseClassReturner.class.getName());     }      public BaseClass getObject() {       if (\"\".length() == 10) {         return new ChildClass();       } else {         return null;       }     }   } }<\/code><\/pre>\n<\/div><\/div>\n<p>  <\/p>\n<p>\u0417\u0434\u0435\u0441\u044c \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043d\u0443\u0436\u043d\u043e\u0433\u043e \u044d\u0444\u0444\u0435\u043a\u0442\u0430 \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u044f \u043a\u043b\u0430\u0441\u0441\u0430 \u043c\u044b \u0441\u0430\u043c\u0438 \u0443\u0434\u0430\u043b\u044f\u0435\u043c <code>ChildClass<\/code> \u0438\u0437 classpath-\u0430 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0438 \u0432\u043d\u0435\u0437\u0430\u043f\u043d\u043e \u043b\u043e\u0432\u0438\u043c \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 <code>NoClassDefFoundError<\/code>:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">java.lang.NoClassDefFoundError: snippet\/TestLoading$ChildClass     at java.base\/java.lang.Class.forName0(Native Method)     at java.base\/java.lang.Class.forName(Class.java:377)     at snippet.TestLoading.loadMyClass(TestLoading.java:31)     at snippet.TestLoading.main(TestLoading.java:25) Caused by: java.lang.ClassNotFoundException: snippet.TestLoading$ChildClass     at java.base\/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:606)     at java.base\/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:168)     at java.base\/java.lang.ClassLoader.loadClass(ClassLoader.java:522)     ... 4 more<\/code><\/pre>\n<p>  <\/p>\n<p>\u041d\u0435\u043e\u0436\u0438\u0434\u0430\u043d\u043d\u044b\u043c \u0442\u0443\u0442 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0435 \u0432 \u043a\u043e\u0434\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0443\u0441\u043b\u043e\u0432\u0438\u0439 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u043a\u043b\u0430\u0441\u0441\u0430, \u043e \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0447\u0438\u0442\u0430\u0442\u0435\u043b\u044f \u043d\u0430\u0432\u0435\u0440\u043d\u044f\u043a\u0430 \u0441\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u043b\u0438 \u043d\u0430 \u0441\u043e\u0431\u0435\u0441\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u044f\u0445.<\/p>\n<p>  <\/p>\n<p>\u0423\u0432\u0435\u0440\u0435\u043d, \u043a\u0430\u0436\u0434\u043e\u043c\u0443 \u0445\u043e\u0442\u044f \u0431\u044b \u0440\u0430\u0437 \u0437\u0430\u0434\u0430\u0432\u0430\u043b\u0438 \u0432\u043e\u043f\u0440\u043e\u0441 \u0432\u0440\u043e\u0434\u0435 &#171;\u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0438\u0442\u0435 \u043e \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0435 \u043a\u043b\u0430\u0441\u0441\u043e\u0432&#187;, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u0442\u0432\u0435\u0447\u0430\u043b\u0438 \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0442\u0430\u043a:<\/p>\n<p>  <\/p>\n<p>1) \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0430 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u0432 Java \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u043b\u0435\u043d\u0438\u0432\u043e;<\/p>\n<p>  <\/p>\n<p>2) \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u0430\u044f \u043c\u0430\u0448\u0438\u043d\u0430 \u0441\u0430\u043c\u0430 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u0438 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0445 \u0435\u0439 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u0438\u0437 JRE;<\/p>\n<p>  <\/p>\n<p>3) \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0430 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0445 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 (\u0442.\u0435. \u043d\u0435 \u043e\u0442\u043d\u043e\u0441\u044f\u0449\u0438\u0445\u0441\u044f \u043a JRE) \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043f\u0440\u0438 \u043f\u0435\u0440\u0432\u043e\u043c:<\/p>\n<p>  <\/p>\n<ul>\n<li>\u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u043a\u043b\u0430\u0441\u0441\u0430;<\/li>\n<li>\u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0443\u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430;<\/li>\n<li>\u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u0438 \u043a \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u043c\u0443 \u043f\u043e\u043b\u044e\/\u043c\u0435\u0442\u043e\u0434\u0443 \u043a\u043b\u0430\u0441\u0441\u0430;<\/li>\n<li>\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u0440\u0435\u0444\u043b\u0435\u043a\u0441\u0438\u0438.<\/li>\n<\/ul>\n<p>  <\/p>\n<p>\u041f\u0440\u043e\u0445\u043e\u0434\u0438 \u044f \u0441\u043e\u0431\u0435\u0441\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0435, \u043d\u0430 \u043f\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u0439 \u0432\u043e\u043f\u0440\u043e\u0441 \u043e\u0442\u0432\u0435\u0442\u0438\u043b \u0431\u044b \u0442\u0430\u043a \u0436\u0435 (\u0438 \u0431\u044b\u043b \u0431\u044b \u043d\u0435\u043f\u0440\u0430\u0432). \u0414\u0430\u0436\u0435 \u043e\u043f\u044b\u0442\u043d\u044b\u0435 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438 \u0447\u0430\u0441\u0442\u043e \u0441\u043c\u0435\u0448\u0438\u0432\u0430\u044e\u0442 \u043f\u043e\u043d\u044f\u0442\u0438\u044f \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u0438 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043a\u043b\u0430\u0441\u0441\u0430 (\u043c\u0435\u0436\u0434\u0443 \u043d\u0438\u043c\u0438 \u0442\u0430\u043a\u0436\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0441\u0432\u044f\u0437\u044b\u0432\u0430\u043d\u0438\u0435 (linking), \u0432 \u0441\u0432\u043e\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u0432\u043a\u043b\u044e\u0447\u0430\u044e\u0449\u0435\u0435 \u0432 \u0441\u0435\u0431\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0443 (verification), \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043a\u0443 (preparation) \u0438 \u0438\u043d\u043e\u0433\u0434\u0430 \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u0438\u0435 (resolution). \u041d\u0430 \u043f\u0435\u0440\u0432\u044b\u0439 \u0432\u0437\u0433\u043b\u044f\u0434, \u043e\u0441\u043e\u0431\u043e\u0439 \u0440\u0430\u0437\u043d\u0438\u0446\u044b \u043d\u0435\u0442, \u0432\u0435\u0434\u044c \u0435\u0441\u043b\u0438 \u043c\u044b \u0441\u043e\u0437\u0434\u0430\u0451\u043c \u043e\u0431\u044a\u0435\u043a\u0442 \u0438\u043b\u0438 \u043e\u0431\u0440\u0430\u0449\u0430\u0435\u043c\u0441\u044f \u043a \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u043c \u043f\u043e\u043b\u044f\u043c\/\u043c\u0435\u0442\u043e\u0434\u0430\u043c, \u0442\u043e \u043d\u0430\u043c \u0432 \u043b\u044e\u0431\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043d\u0443\u0436\u043d\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0443 (\u0441\u0442\u0440\u043e\u0433\u043e \u0433\u043e\u0432\u043e\u0440\u044f \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0449\u0443\u044e \u0441\u043e\u0431\u043e\u0439 \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0434\u0442\u044f\u0433\u0438\u0432\u0430\u043d\u0438\u0435 \u0432 \u043f\u0430\u043c\u044f\u0442\u044c \u0434\u0432\u043e\u0438\u0447\u043d\u043e\u0433\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043a\u043b\u0430\u0441\u0441\u0430 \u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0442\u0438\u043f\u0430 <code>Class<\/code>). \u0417\u0430\u0447\u0435\u043c \u0442\u043e\u0433\u0434\u0430 \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u0442\u044c \u044d\u0442\u0438 \u043f\u043e\u043d\u044f\u0442\u0438\u044f? \u0420\u0430\u0437\u0432\u0435 \u043c\u043e\u0436\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c\u0441\u044f \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0430 \u0431\u0435\u0437 \u043f\u043e\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0433\u043e \u0441\u0432\u044f\u0437\u044b\u0432\u0430\u043d\u0438\u044f \u0438 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438?<\/p>\n<p>  <\/p>\n<p>\u041e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f, \u043c\u043e\u0436\u0435\u0442, \u0438 \u0431\u0435\u0437 \u0447\u0451\u0442\u043a\u043e\u0433\u043e \u0440\u0430\u0437\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f \u044d\u0442\u0438\u0445 \u043f\u043e\u043d\u044f\u0442\u0438\u0439 \u043c\u044b \u043d\u0435 \u0441\u043c\u043e\u0436\u0435\u043c \u043e\u0442\u0432\u0435\u0442\u0438\u0442\u044c \u043d\u0430 \u043f\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u0439 \u0432 \u043d\u0430\u0447\u0430\u043b\u0435 \u0441\u0442\u0430\u0442\u044c\u0438 \u0432\u043e\u043f\u0440\u043e\u0441.<\/p>\n<p>  <\/p>\n<p>\u041e\u0442\u043a\u0440\u043e\u0435\u043c <a href=\"https:\/\/docs.oracle.com\/javase\/specs\/jls\/se20\/html\/jls-12.html#jls-12.2\" rel=\"nofollow noopener noreferrer\">\u0440\u0430\u0437\u0434\u0435\u043b 12.2<\/a> \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 \u044f\u0437\u044b\u043a\u0430 Java (JLS):<\/p>\n<p>  <\/p>\n<blockquote><p>Loading refers to the process of finding the binary form of a class or interface with a particular name, perhaps by computing it on the fly, but more typically by retrieving a binary representation previously computed from source code by a Java compiler, and constructing, from that binary form, a <code>Class<\/code> object to represent the class or interface (\u00a71.4).<\/p><\/blockquote>\n<p>\u041f\u0440\u043e \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u043d\u0430\u043c \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0435\u0442 <a href=\"https:\/\/docs.oracle.com\/javase\/specs\/jls\/se20\/html\/jls-12.html#jls-12.4.1\" rel=\"nofollow noopener noreferrer\">\u0440\u0430\u0437\u0434\u0435\u043b 12.4.1<\/a>:<\/p>\n<p>  <\/p>\n<blockquote><p>A class or interface <code>T<\/code> will be initialized immediately before the first occurrence of any one of the following:  <\/p>\n<ul>\n<li><code>T<\/code> is a class and an instance of <code>T<\/code> is created.<\/li>\n<li>a <code>static<\/code> method declared by <code>T<\/code> is invoked.<\/li>\n<li>a <code>static<\/code> field declared by <code>T<\/code> is assigned.<\/li>\n<li>a <code>static<\/code> field declared by <code>T<\/code> is used and the field is not a constant variable (\u00a74.12.4).<\/li>\n<\/ul>\n<p>  <\/p><\/blockquote>\n<p>\u041f\u043e\u0434\u0447\u0451\u0440\u043a\u0438\u0432\u0430\u044e: \u0443\u0441\u043b\u043e\u0432\u0438\u044f \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043a\u043b\u0430\u0441\u0441\u0430 \u0441\u0442\u0440\u043e\u0433\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u044b, \u0447\u0435\u0433\u043e \u043d\u0435 \u0441\u043a\u0430\u0436\u0435\u0448\u044c \u043e\u0431 \u0443\u0441\u043b\u043e\u0432\u0438\u044f\u0445 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u043a\u043b\u0430\u0441\u0441\u0430.<\/p>\n<p>  <\/p>\n<p>\u0412 \u043d\u0430\u0448\u0435\u043c \u043a\u043e\u0434\u0435 \u0435\u0441\u0442\u044c \u0434\u0432\u0435 \u0441\u0441\u044b\u043b\u043a\u0438 \u043d\u0430 <code>ChildClass<\/code>, \u043d\u043e \u0432 \u0440\u0430\u043d\u0442\u0430\u0439\u043c\u0435 \u043d\u0435 \u0443\u0434\u043e\u0432\u043b\u0435\u0442\u0432\u043e\u0440\u0435\u043d\u043e \u043d\u0438 \u043e\u0434\u043d\u043e \u0438\u0437 \u0443\u0441\u043b\u043e\u0432\u0438\u0439 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043a\u043b\u0430\u0441\u0441\u0430 \u0438\u0437 JLS \u00a712.4.1. \u0422\u0435\u043c \u043d\u0435 \u043c\u0435\u043d\u0435\u0435 \u0412\u041c \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u0442 \u043a\u043b\u0430\u0441\u0441, \u0447\u0442\u043e \u043d\u0430 \u043f\u0435\u0440\u0432\u044b\u0439 \u0432\u0437\u0433\u043b\u044f\u0434 \u043b\u0438\u0448\u0435\u043d\u043e \u0432\u0441\u044f\u043a\u043e\u0433\u043e \u0441\u043c\u044b\u0441\u043b\u0430.<\/p>\n<p>  <\/p>\n<p>\u041e\u0442\u0434\u0435\u043b\u044c\u043d\u043e \u043e\u0442\u043c\u0435\u0447\u0443, \u0447\u0442\u043e \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u0431\u0440\u043e\u0448\u0435\u043d\u043e \u0438\u043c\u0435\u043d\u043d\u043e \u0438\u0437 <code>Class.forName(BaseClassReturner.class.getName())<\/code>, \u0432\u044b\u0437\u043e\u0432 <code>Class.forName(ObjectReturner.class.getName())<\/code> \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0431\u0435\u0437 \u043e\u0448\u0438\u0431\u043e\u043a, \u0445\u043e\u0442\u044f \u0438 <code>BaseClassReturner<\/code>, \u0438 <code>ObjectReturner<\/code> \u0441\u0441\u044b\u043b\u0430\u044e\u0442\u0441\u044f \u043d\u0430 <code>ChildClass<\/code>.<\/p>\n<p>  <\/p>\n<p>\u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u043c\u044b \u0432\u0438\u0434\u0438\u043c \u0442\u0440\u0438 \u0441\u0442\u0440\u0430\u043d\u043d\u044b\u0435 \u0432\u0435\u0449\u0438:<\/p>\n<p>  <\/p>\n<ul>\n<li>\u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0443 \u043a\u043b\u0430\u0441\u0441\u0430, \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u044f\u0449\u0443\u044e \u0433\u0434\u0435-\u0442\u043e \u0432 \u043d\u0435\u0434\u0440\u0430\u0445 \u0412\u041c \u0438 \u0432\u044b\u0437\u0432\u0430\u043d\u043d\u0443\u044e \u043d\u0435\u043a\u0438\u043c \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u043e\u043c, \u0441\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u044e\u0449\u0438\u043c \u0434\u0430\u0436\u0435 \u0432 \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0438 \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u044f \u043a \u0446\u0435\u043b\u0435\u0432\u043e\u043c\u0443 \u043a\u043b\u0430\u0441\u0441\u0443 \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u0438\u0441\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f<\/li>\n<li>\u044f\u0432\u043d\u0443\u044e \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044c \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u043a\u043b\u0430\u0441\u0441\u0430 (\u0431\u044b\u0441\u0442\u0440\u0430\u044f\/\u043b\u0435\u043d\u0438\u0432\u0430\u044f) \u043e\u0442 \u0441\u0438\u0433\u043d\u0430\u0442\u0443\u0440\u044b \u043c\u0435\u0442\u043e\u0434\u0430 (\u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0438\u0433\u0434\u0435 \u043d\u0435 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f)<\/li>\n<li>\u0432\u044b\u0431\u0440\u043e\u0441 \u0438\u0437 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u0433\u043e \u043a\u043e\u0434\u0430 <code>NoClassDefFoundError<\/code> (\u0445\u043e\u0442\u044f \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f <code>Class.forName(String)<\/code> \u0435\u0433\u043e \u0432\u043e\u043e\u0431\u0449\u0435 \u043d\u0435 \u043f\u0440\u0435\u0434\u0443\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0435\u0442)<\/li>\n<\/ul>\n<p>  <\/p>\n<p>\u0420\u0430\u0437\u0431\u0435\u0440\u0451\u043c\u0441\u044f. \u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u0443\u043f\u0440\u043e\u0441\u0442\u0438\u043c \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 <code>BaseClassReturner.getObject()<\/code>, \u0441\u0434\u0435\u043b\u0430\u0432 \u0435\u0433\u043e \u043a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0431\u043e\u043b\u0435\u0435 \u043f\u043e\u0445\u043e\u0436\u0438\u043c \u043d\u0430 <code>ObjectReturner.getObject()<\/code>:<\/p>\n<p>  <\/p>\n<pre><code class=\"java\">public static class BaseClassReturner {   static {     System.out.println(\"loaded: \" + BaseClassReturner.class.getName());   }    public BaseClass getObject() {     return new ChildClass();   } }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0411\u0430\u0439\u0442-\u043a\u043e\u0434:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">\/\/ access flags 0x1 public getObject()Lorg\/example\/TestLoading$BaseClass;  L0   LINENUMBER 49 L0   NEW org\/example\/TestLoading$ChildClass   DUP   INVOKESPECIAL org\/example\/TestLoading$ChildClass.&lt;init> ()V   ARETURN  L1   LOCALVARIABLE this Lorg\/example\/TestLoading$BaseClassReturner; L0 L1 0   MAXSTACK = 2   MAXLOCALS = 1<\/code><\/pre>\n<p>  <\/p>\n<p>\u0421\u0440\u0430\u0432\u043d\u0438\u043c \u0441 \u0431\u0430\u0439\u0442-\u043a\u043e\u0434\u043e\u043c <code>ObjectReturner.getObject()<\/code>:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">\/\/ access flags 0x1 public getObject()Ljava\/lang\/Object;  L0   LINENUMBER 43 L0   NEW org\/example\/TestLoading$ChildClass   DUP   INVOKESPECIAL org\/example\/TestLoading$ChildClass.&lt;init> ()V   ARETURN  L1   LOCALVARIABLE this Lorg\/example\/TestLoading$ObjectReturner; L0 L1 0   MAXSTACK = 2   MAXLOCALS = 1<\/code><\/pre>\n<p>  <\/p>\n<p>\u041a\u0440\u043e\u043c\u0435 \u0442\u0438\u043f\u0430 <code>this<\/code> \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u043c \u043e\u0442\u043b\u0438\u0447\u0438\u0435\u043c \u043c\u0435\u0436\u0434\u0443 \u043c\u0435\u0442\u043e\u0434\u0430\u043c\u0438 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0442\u0438\u043f \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0441\u043e\u0441\u0440\u0435\u0434\u043e\u0442\u043e\u0447\u0438\u043c\u0441\u044f \u043d\u0430 \u043d\u0451\u043c.<\/p>\n<p>  <\/p>\n<p>\u0418\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e \u044f \u043f\u043e\u0448\u0451\u043b \u043f\u043e \u043d\u0435\u0432\u0435\u0440\u043d\u043e\u043c\u0443 \u043f\u0443\u0442\u0438, \u0440\u0430\u0437\u043c\u044b\u0448\u043b\u044f\u044f \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0442\u0430\u043a: \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 <code>BaseClassReturner.getObject()<\/code> \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0442\u0438\u043f <code>BaseClass<\/code>, \u0442\u043e \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u0430\u044f \u043c\u0430\u0448\u0438\u043d\u0430 \u0434\u043e\u043b\u0436\u043d\u0430 \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u043d\u0430\u043b\u0438\u0447\u0438\u0435 \u0432\u0441\u0435\u0445 \u0435\u0433\u043e \u043f\u043e\u0442\u043e\u043c\u043a\u043e\u0432 \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0432 \u0438\u0445.<\/p>\n<p>  <\/p>\n<p>\u042d\u0442\u043e \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u044f\u0432\u043d\u043e \u043e\u0448\u0438\u0431\u043e\u0447\u043d\u043e, \u0442.\u043a. \u0432\u043e-\u043f\u0435\u0440\u0432\u044b\u0445 \u043f\u0440\u0438 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0435\/\u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u0430\u044f \u043c\u0430\u0448\u0438\u043d\u0430 \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u0442\/\u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u0442 \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0435 \u043a\u043b\u0430\u0441\u0441\u044b, \u0430 \u043d\u0435 \u0434\u043e\u0447\u0435\u0440\u043d\u0438\u0435, \u0432\u043e-\u0432\u0442\u043e\u0440\u044b\u0445 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0445 \u043f\u0440\u043e\u0432\u0435\u0440\u043e\u043a \u0431\u044b\u043b\u043e \u0431\u044b \u043a\u0440\u0430\u0439\u043d\u0435 \u043d\u0435\u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u044b\u043c \u0438 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0437\u0430\u043c\u0435\u0434\u043b\u0438\u043b\u043e \u0431\u044b \u0440\u0430\u0431\u043e\u0442\u0443 \u0412\u041c, \u0432\u0435\u0434\u044c \u043d\u0430\u0441\u043b\u0435\u0434\u043d\u0438\u043a\u043e\u0432 \u043a\u043b\u0430\u0441\u0441\u0430 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0441\u043a\u043e\u043b\u044c \u0443\u0433\u043e\u0434\u043d\u043e \u043c\u043d\u043e\u0433\u043e \u0438 \u0434\u043b\u044f \u0438\u0445 \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0435\u043d\u0438\u044f \u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u0431\u044b \u0442\u0443\u043f\u043e \u043f\u0435\u0440\u0435\u0431\u0440\u0430\u0442\u044c \u0432\u0435\u0441\u044c classpath.<\/p>\n<p>  <\/p>\n<p>\u042d\u043c\u043f\u0438\u0440\u0438\u0447\u0435\u0441\u043a\u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u043e\u0448\u0438\u0431\u043e\u0447\u043d\u043e\u0441\u0442\u044c \u0433\u0438\u043f\u043e\u0442\u0435\u0437\u044b \u043c\u043e\u0436\u043d\u043e, \u043f\u0435\u0440\u0435\u043f\u0438\u0441\u0430\u0432 \u043a\u043e\u0434 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<p>  <\/p>\n<pre><code class=\"java\">public static class BaseClassReturner {   static {     System.out.println(\"loaded: \" + BaseClassReturner.class.getName());   }    public BaseClass getObject() {     return null;   } }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u043d\u0435 \u0432\u044b\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u0435\u0442\u0441\u044f, \u0447\u0442\u043e \u0434\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0438\u0435\u0440\u0430\u0440\u0445\u0438\u0438 \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u044f.<\/p>\n<p>  <\/p>\n<p>\u041f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f, \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u044b \u043a\u0430\u043a\u0438\u0435-\u0442\u043e \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435. \u0417\u0430\u043f\u0443\u0441\u0442\u0438\u043c \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443 \u0441 \u0444\u043b\u0430\u0433\u0430\u043c\u0438 \u0412\u041c <code>-Xlog:class+init,class+load<\/code> \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e\u0433\u043e \u043b\u043e\u0433\u0430 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0438 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u043a\u043b\u0430\u0441\u0441\u043e\u0432:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">loading: org.example.TestLoading$ObjectReturner... [0.393s][info][class,init] Start class verification for: org.example.TestLoading$ObjectReturner [0.393s][info][class,init] End class verification for: org.example.TestLoading$ObjectReturner [0.393s][info][class,init] 770 Initializing 'org\/example\/TestLoading$ObjectReturner' (0x0000000800067450) loaded: org.example.TestLoading$ObjectReturner [0.397s][info][class,load] org.example.TestLoading$BaseClassReturner source: file:\/C:\/Users\/STsypanov\/IdeaProjects\/test\/target\/classes\/ loading: org.example.TestLoading$BaseClassReturner... [0.397s][info][class,init] Start class verification for: org.example.TestLoading$BaseClassReturner [0.398s][info][class,init] 771 Initializing 'java\/lang\/ReflectiveOperationException'(no method) (0x0000000800004028) [0.398s][info][class,init] 772 Initializing 'java\/lang\/ClassNotFoundException'(no method) (0x0000000800004288) [0.398s][info][class,init] 773 Initializing 'java\/lang\/LinkageError'(no method) (0x00000008000044f8) [0.398s][info][class,init] 774 Initializing 'java\/lang\/NoClassDefFoundError'(no method) (0x0000000800004758) [0.398s][info][class,init] Verification for org.example.TestLoading$BaseClassReturner has exception pending 'java.lang.NoClassDefFoundError org\/example\/TestLoading$ChildClass' [0.398s][info][class,init] End class verification for: org.example.TestLoading$BaseClassReturner [0.398s][info][class,load] java.lang.Throwable$PrintStreamOrWriter source: jrt:\/java.base [0.398s][info][class,load] java.lang.Throwable$WrappedPrintStream source: jrt:\/java.base [0.398s][info][class,init] 775 Initializing 'java\/lang\/Throwable$PrintStreamOrWriter'(no method) (0x00000008000a0ed8) [0.398s][info][class,init] 776 Initializing 'java\/lang\/Throwable$WrappedPrintStream'(no method) (0x00000008000a10f0) java.lang.NoClassDefFoundError: org\/example\/TestLoading$ChildClass [0.399s][info][class,init] 777 Initializing 'java\/lang\/StackTraceElement'(no method) (0x0000000800010858) [0.399s][info][class,load] java.lang.StackTraceElement$HashedModules source: jrt:\/java.base [0.399s][info][class,init] 778 Initializing 'java\/lang\/StackTraceElement$HashedModules' (0x00000008000a1320) at java.base\/java.lang.Class.forName0(Native Method) at java.base\/java.lang.Class.forName(Class.java:315) at org.example.TestLoading.loadMyClass(TestLoading.java:29) at org.example.TestLoading.main(TestLoading.java:23) Caused by: java.lang.ClassNotFoundException: org.example.TestLoading$ChildClass at java.base\/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581) at java.base\/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178) at java.base\/java.lang.ClassLoader.loadClass(ClassLoader.java:522) ... 4 more<\/code><\/pre>\n<p>  <\/p>\n<p>\u0422\u0443\u0442 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u0430 \u0432\u043e\u0442 \u044d\u0442\u0430 \u0447\u0430\u0441\u0442\u044c:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">[0.397s][info][class,load] org.example.TestLoading$BaseClassReturner source: file:\/C:\/Users\/STsypanov\/IdeaProjects\/test\/target\/classes\/ loading: org.example.TestLoading$BaseClassReturner... [0.397s][info][class,init] Start class verification for: org.example.TestLoading$BaseClassReturner [0.398s][info][class,init] 771 Initializing 'java\/lang\/ReflectiveOperationException'(no method) (0x0000000800004028) [0.398s][info][class,init] 772 Initializing 'java\/lang\/ClassNotFoundException'(no method) (0x0000000800004288) [0.398s][info][class,init] 773 Initializing 'java\/lang\/LinkageError'(no method) (0x00000008000044f8) [0.398s][info][class,init] 774 Initializing 'java\/lang\/NoClassDefFoundError'(no method) (0x0000000800004758) [0.398s][info][class,init] Verification for org.example.TestLoading$BaseClassReturner has exception pending 'java.lang.NoClassDefFoundError org\/example\/TestLoading$ChildClass' [0.398s][info][class,init] End class verification for: org.example.TestLoading$BaseClassReturner<\/code><\/pre>\n<p>  <\/p>\n<p>\u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043a\u043b\u0430\u0441\u0441\u0430 \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u0435\u0433\u043e \u0432\u0435\u0440\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438, \u0432 \u0445\u043e\u0434\u0435 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0432\u044b\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u0435\u0442\u0441\u044f <code>NoClassDefFoundError<\/code> \u0438 <code>LinkageError<\/code>. \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f, \u043d\u043e\u0433\u0438 \u0440\u0430\u0441\u0442\u0443\u0442 \u0438\u0437 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430, \u043e\u043f\u0438\u0441\u0430\u043d\u043d\u043e\u0439 \u0432 <a href=\"https:\/\/docs.oracle.com\/javase\/specs\/jvms\/se20\/html\/jvms-4.html#jvms-4.10\" rel=\"nofollow noopener noreferrer\">\u0440\u0430\u0437\u0434\u0435\u043b\u0435 4.10<\/a> \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u043e\u0439 \u043c\u0430\u0448\u0438\u043d\u0430 (JVMS), \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0432 \u0447\u0430\u0441\u0442\u0438 \u043a\u0430\u0441\u0430\u044e\u0449\u0435\u0439\u0441\u044f \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438 <code>areturn<\/code> \u0433\u043b\u0430\u0441\u0438\u0442:<\/p>\n<p>  <\/p>\n<blockquote><p>An <code>areturn<\/code> instruction is type safe iff the enclosing method has a declared return type, <code>ReturnType<\/code>, that is a reference type, and one can validly pop a type matching <code>ReturnType<\/code> off the incoming operand stack.<\/p><\/blockquote>\n<p>\u0422\u0438\u043f \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043e\u043f\u0438\u0441\u0430\u043d \u0442\u0430\u043a:<\/p>\n<p>  <\/p>\n<blockquote><p>If the method returns a reference type, only an <code>areturn<\/code> instruction may be used, and <strong>the type of the returned value must be assignment compatible with the return descriptor of the method<\/strong> (\u00a74.3.3)<\/p><\/blockquote>\n<p>\u0412\u044b\u0445\u043e\u0434\u0438\u0442, \u0434\u0435\u043b\u043e \u0432 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0435 \u0431\u0430\u0439\u0442-\u043a\u043e\u0434\u0430 \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u043c\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430. \u0422\u0435\u043f\u0435\u0440\u044c \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u043c \u0438\u0441\u0445\u043e\u0434\u043d\u0443\u044e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443 \u0441 <code>-noverify<\/code>, \u043e\u0442\u043a\u043b\u044e\u0447\u0430\u044e\u0449\u0438\u043c \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u0443\u044e \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0443. \u0418 \u043e \u0447\u0443\u0434\u043e: \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u0431\u043e\u043b\u044c\u0448\u0435 \u043d\u0435 \u0432\u044b\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u0435\u0442\u0441\u044f.<\/p>\n<p>  <\/p>\n<p>\u0412\u043c\u0435\u0441\u0442\u0435 \u0441 <code>-XX:TieredStopAtLevel=1<\/code> \u044d\u0442\u043e \u0444\u043b\u0430\u0433 \u0432\u044b\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u043f\u0440\u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0435<br \/>  Spring Boot-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439 \u0438\u0437 &#171;\u0418\u0434\u0435\u0438&#187;, \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0443\u0441\u043a\u043e\u0440\u044f\u044f \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435.<\/p>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/webt\/f-\/cw\/td\/f-cwtdohpjr2hqa2uqnx6kustdk.jpeg\" data-src=\"https:\/\/habrastorage.org\/webt\/f-\/cw\/td\/f-cwtdohpjr2hqa2uqnx6kustdk.jpeg\" data-blurred=\"true\"\/><\/p>\n<p>  <\/p>\n<p>\u041f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0432\u044b\u0432\u043e\u0434: \u043d\u0438\u0447\u0442\u043e \u043d\u0435 \u043c\u0435\u0448\u0430\u0435\u0442 \u043d\u0430\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u043e\u0442 \u0444\u0438\u043d\u0442 \u0441 \u0431\u043e\u043b\u044c\u0448\u0438\u043c\u0438 \u0438 \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u044b\u043c\u0438 docker-compose \u0444\u0430\u0439\u043b\u0430\u043c\u0438, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0438\u043c\u0438 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e Java-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439 (\u043a\u0430\u043a \u0441\u0430\u043c\u043e\u043f\u0438\u0441\u043d\u044b\u0445, \u0442\u0430\u043a \u0438 \u0440\u0430\u0437\u043d\u044b\u0445 \u0437\u0443\u043a\u0438\u043f\u0435\u0440\u043e\u0432, \u044d\u0432\u0440\u0438\u043a, \u044d\u043b\u0430\u0441\u0442\u0438\u043a\u043e\u0432 \u0438 \u0442.\u043f.).<\/p>\n<p>  <\/p>\n<p>\u0412 \u043f\u0440\u043e\u0434\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u043e\u0442 \u0444\u043b\u0430\u0433 \u043d\u0443\u0436\u043d\u043e \u043a\u0440\u0430\u0439\u043d\u0435 \u043e\u0441\u0442\u043e\u0440\u043e\u0436\u043d\u043e (\u0438\u043b\u0438 \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432\u043e\u0432\u0441\u0435), \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e<br \/>  \u0435\u0441\u043b\u0438 \u0432 \u0432\u0430\u0448\u0435\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438 \u043c\u043d\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u0441\u043e\u0437\u0434\u0430\u0451\u0442\u0441\u044f &#171;\u043d\u0430 \u043b\u0435\u0442\u0443&#187;, \u043a\u0440\u043e\u043c\u0435 \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u044b\u0445 \u043f\u0440\u043e\u0431\u043b\u0435\u043c \u0441 \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u044c\u044e \u044d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0432\u044b\u0437\u0432\u0430\u0442\u044c \u0432 \u0442.\u0447. <a href=\"https:\/\/stackoverflow.com\/questions\/40321205\/jvm-crash-problematic-frame-canonicalizerdo-if\" rel=\"nofollow noopener noreferrer\">\u043a\u0440\u0430\u0445 \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u043e\u0439 \u043c\u0430\u0448\u0438\u043d\u044b<\/a>.<\/p>\n<p>  <\/p>\n<p>\u0412\u044b\u0432\u043e\u0434\u044b:<\/p>\n<p>  <\/p>\n<ul>\n<li>\u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0430 \u043a\u043b\u0430\u0441\u0441\u0430 \u043d\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 \u0441\u043e\u043f\u0440\u043e\u0432\u043e\u0436\u0434\u0430\u0435\u0442\u0441\u044f \u0435\u0433\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u043e\u0439 \u0438 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0435\u0439<\/li>\n<li>\u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u0431\u0430\u0439\u0442-\u043a\u043e\u0434\u0430 \u043c\u043e\u0436\u0435\u0442 \u0432\u044b\u0437\u0432\u0430\u0442\u044c \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0443 \u043a\u043b\u0430\u0441\u0441\u0430<\/li>\n<li>\u0432 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0443 \u0431\u0430\u0439\u0442-\u043a\u043e\u0434\u0430 \u043c\u043e\u0436\u043d\u043e \u043e\u0442\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u0434\u043b\u044f \u0443\u0441\u043a\u043e\u0440\u0435\u043d\u0438\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f<\/li>\n<\/ul>\n<p>  <\/p>\n<p>\u041e\u0431\u0441\u0443\u0436\u0434\u0435\u043d\u0438\u0435 \u0432 \u0440\u0430\u0441\u0441\u044b\u043b\u043a\u0435 core-libs-dev: <a href=\"https:\/\/mail.openjdk.org\/pipermail\/core-libs-dev\/2023-May\/106219.html\" rel=\"nofollow noopener noreferrer\">https:\/\/mail.openjdk.org\/pipermail\/core-libs-dev\/2023-May\/106219.html<\/a><\/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\/740156\/\"> https:\/\/habr.com\/ru\/articles\/740156\/<\/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-1\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u041f\u0440\u0438\u0432\u0435\u0442, \u0441\u0435\u0433\u043e\u0434\u043d\u044f\u0448\u043d\u044f\u044f \u0441\u0442\u0430\u0442\u044c\u044f \u0431\u0443\u0434\u0435\u0442 \u043e \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0442\u043e\u043d\u043a\u043e\u0441\u0442\u044f\u0445 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u0438 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u0438 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043e \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 (\u0441\u043e\u0432\u0441\u0435\u043c \u0447\u0443\u0442\u044c-\u0447\u0443\u0442\u044c \u0438 \u0432 \u0441\u0430\u043c\u043e\u043c \u043a\u043e\u043d\u0446\u0435).<\/p>\n<p>  <\/p>\n<p>\u041f\u043e\u0432\u043e\u0434\u043e\u043c \u0434\u043b\u044f \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0441\u0442\u0430\u0442\u044c\u0438 \u0441\u0442\u0430\u043b <a href=\"https:\/\/stackoverflow.com\/questions\/76260269\/classes-used-in-method-body-are-loaded-lazily-or-eagerly-depending-on-method-ret\" rel=\"nofollow noopener noreferrer\">\u0432\u043e\u043f\u0440\u043e\u0441<\/a> \u043d\u0430 StackOverflow. \u041e\u0442\u043a\u0440\u043e\u0439\u0442\u0435, \u043d\u043e \u043d\u0435 \u0442\u043e\u0440\u043e\u043f\u0438\u0442\u0435\u0441\u044c \u0447\u0438\u0442\u0430\u0442\u044c \u043e\u0442\u0432\u0435\u0442 \ud83d\ude09<\/p>\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-351143","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/351143","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=351143"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/351143\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=351143"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=351143"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=351143"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}