Saturday, 17 August 2013

Why Write a ClassLoader?

JVM has a Inbuilt  class loader which loads all the class files  into the run time environment . Then why do we need to develop a class loader? Good question. The default ClassLoader only knows how to load class files from the local filesystem. This is fine for regular situations, when you have your Java program fully compiled and waiting on your computer.But one of the most innovative things about the Java language is that it makes it easy for the JVM to get classes from places other than the local hard drive or network. For example,browsers use a custom ClassLoader to load executable content from a Web site.There are many other ways to get class files. Besides simply loading files from the local disk or from a network, you can use a custom ClassLoader to:
* Automatically verify a digital signature before executing untrusted code
* Transparently decrypt code with a user-supplied password
* Create dynamically built classes customized to the user's specific needs
Anything you can think of to write that can generate Java bytecode can be integrated into

your application.

No comments:

Post a Comment