Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I found the following, valid reasons to create custom classloaders:</p> <ol> <li><p>You want to load a class from an unconventional source (For example, the bytecode for one class is stored in a database, across the network or <a href="http://www.ietf.org/rfc/rfc1149.txt?number=1149" rel="noreferrer">carried as 0 and 1s by pidgeons</a> - MessengerPidgeonClassLoader). There is some ClassLoader implementations already in the API for such cases, such as <a href="http://java.sun.com/j2se/1.4.2/docs/api/java/net/URLClassLoader.html" rel="noreferrer">URLClassLoader</a>.</p></li> <li><p>You need to define a different hierarchy to load classes. Default implementations of the ClassLoader delegate the search first to the parent, then they try to load the class themselves. Maybe you want a different hierarchy. This is the reason why OSGI and Eclipse have its own ClassLoaders as the Manifest .MF files define all types of weird hierarchy paths (buddy-classloading, for example). All Eclipse classloaders implement the BundleClassLoader interface and have some extra code to find resources within Eclipse Plugins.</p></li> <li><p>You need to do some modification to the bytecode. Maybe the bytecode is encrypted, and you will unencrypt it on the fly (<a href="http://www.javaworld.com/javaworld/javaqa/2003-05/01-qa-0509-jcrypt.html" rel="noreferrer">Not that it helps, really, but has been tried</a>). Maybe you want to "patch" the classes loaded on the fly (A la JDO bytecode enhancement).</p></li> </ol> <p>Using a different classloader than the System Classloader is required if you need to unload classes from memory, or to load classes than could change their definition at runtime. A typical case is an application that generates a class on the fly from an XML file, for example, and then tries to reload this class. Once a class is in the System Classloader, there is no way to unload it and have a new definition.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload