This content has been marked as final. Show 4 replies
Parent-first loaders try the parent classloader before deciding they need to do the loading themselves. This complies with the specification. Parent-last loaders do the opposite, and do not comply. They therefore shouldn't even exist, although I wrote one myself about 14 years ago.
Thanks EJP, For example lets take JVM class loaders, we have bootstrap class loader which is a parent which inturn loads the extension and system class loaders.
Now I have a set my .class file in the system classpath. Which is supposed to be loaded by the System classloader. But before the system classloader loads the .class it will verify its cache to see whether the .class is loaded before, if it is not there in the cache it will send a request to its parent classloader for the respective .class file. If it is not able to find that then he child classloader will load it. This is parent first. The examples are class.forName() and customClassloader.loadClass() will follow this approach. Where customClassLoader.defineClass() will follow different approach where instead of checking with the parent class loader for the .class file, the current classloader will load the file explictly. Whether this is Parent last?
What is the advantages of these approaches? Please clarify.
any response to it?
customClassLoader.defineClass() will follow different approachWill it? Why? If it doesn't call the parent first it is not compliant. I've explained all that.
where instead of checking with the parent class loader for the .class file, the current classloader will load the file explictly. Whether this is Parent last?It's parent first if it calls the parent first. It's parent last if it calls the parent last. This is not rocket science and doesn't need to be explained and beaten to death over and over again. What you are describing here sounds like neither, as it doesn't seem to call the parent at all, so it won't work, as it cannot load application classes that depend on system classes.
What is the advantages of these approaches?The advantage of parent first is that it complies with the Specification. The others don't, and the one you just described won't even work. There's no 'advantage' in techniques that don't comply with the specified contract.
Please clarify.There is nothing to clarify. You're just asking me to repeat myself, and to 'clarify' a concept that is self-evident from its name.
You also seem to be expecting 7x24-hour service. Not everyone is in your time zone.