java - Confusion in class loading styles -


As I have found in a thread that Class.forName () will always use the caller's classloader Class loader .loadClass () can specify a different class loader

  System.out.println (Class.ForName ("test.Employee"). GetClassLoader ()); Println (ClassLoader.getSystemClassLoader () loadClass ("test.Employee") getClassLoader () ..);   

But the same result above two lines are printing

  sun.misc.Launcher$AppClassLoader@7ced01 sun.misc.Launcher $ AppClassLoader @ 7ced01   

Please tell the reason.

There is no difference for you using your existing class SystemClassLoader which was loaded < code> sun.misc.Launcher$AppClassLoader@7ced01 .

When you use a different classloader to load a class, both aproaches will use different class loaders used in that category that you have loaded with a different class loader.

Comments

Popular posts from this blog

Java - Error: no suitable method found for add(int, java.lang.String) -

c# - passing input text from view to contoller with FacebookContext using Facebook app -

Calling a C++ function from C# by passing a string with variable size to it -