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

How can I add a seperate action listener to all 14 of my buttons at once that can determine player turn?(java) -

php - Sorting an multidimension array using usort fails -

Simple file compression in C -