filmov
tv
Java Interview Question And Answer What is Java Class Loader And CustomClass Loader DefineClass

Показать описание
Java ClassLoader :-
Every Java developer knows that compiler compiles source code and converts it into byte code , and then JVM executes this byte code.In java every class is declared in it's own class file.JVM loads classes on demand .Whenever JVM needs class ,it asks ClassLoader.ClassLoader returns Class Object representing required class.
CustomClassLoader :-
When default ClassLoader is available then why do we need to write our own ClassLoader. Default ClassLoader will try to load file from local System.But Java language has feature to load raw bytes and convert them to Class object on the fly.In case of Java Applets , our browser has it's own customized class Loader which reads raw byte streams on web,in short it fetches raw bytes and on fly creates Class objects and loads classes for further execution.
So customizedClassLoader can be used for below purposes
1. For security purpose for e.g verifying digital signature
2. For archiving
3. Create class on the fly satisfying customer requirement. defineClass converts an array of bytes into an instance of class