Under the osgi framework
This. getclass (). getclassloader () = org. Eclipse. osgi. Internal. baseadaptor. defaultclassloader @ 186c6b2
Thread. currentthread (). getcontextclassloader () = org. Eclipse. Core. runtime. Internal. adaptor. contextfinder @ 16b13c7
Classloader. getsystemclassloader () = sun. Misc. launcher $ appclassloader @ 19821f
In common Java programs
This. getclass (). getclassloader () = sun. Misc. launcher $ appclassloader @ 19821f
Thread. currentthread (). getcontextclassloader () = sun. Misc. launcher $ appclassloader @ 19821f
Classloader. getsystemclassloader () = sun. Misc. launcher $ appclassloader @ 19821f
From this we can see that under the osgi framework, if classes that are not in the bin directory of this bundle are dynamically loaded, only classloader. getsystemclassloader () is used ().
In addition, it is found that in the osgi framework, the other two class loaders are used to load non-bin directories (the default class output path of this bundle), even if the absolute path is given, the system will also encounter an exception where the class cannot be found.
Note that this. getclass (). getclassloader () and thread. currentthread (). getcontextclassloader () can be assigned to a urlclassloader just like a normal Java project, but an exception that cannot be forcibly converted will occur during running. This analysis shows that this. getclass (). getclassloader () and thread. currentthread (). getcontextclassloader () in the osgi framework are different from those in Java. Pay more attention when using it in the future.