Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>A complete (coded) solution would be a bit beyond a single Stack Overflow answer, so I'll outline the points you need to be aware of instead if you decide to write your own ClassLoader:</p> <ol> <li>The classloader represents (part of) a namespace, and two otherwise identical classes loaded by different classloaders are not "equal". Which means there are a few dangers lurking in classloading, notably singletons suddenly not being so single anymore as well as casts failing unexpectedly.</li> <li>Classloaders (should) work on a pattern of delegating to the "parent" loader before attempting anything themselves (see above).</li> <li>Class loading and linking are two distinct steps (even though example implementations of a classloader such as may be found in blog posts/online Java articles, will combine the two into one for simplicity) Therefore you should not assume that if a parent loader has loaded a class it has also loaded all dependencies ...</li> <li>All this means there is a problem if class A loaded by loader A references a class B which neither loader A nor any of its parents can load: class A may load just fine in loader A but at the point of use it fails because loader A cannot fully resolve (link) it.</li> <li>And you should make sure that your classloader loads classes in a synchronized manner otherwise the issues hinted at in step #1 can leap from duplicates due to classloaders to duplicates from multiple threads using the same classloader as well...</li> </ol> <p>Note: it is <strong>far</strong> easier to just use the <code>-cp</code> switch in some wrapper script/batch file for your program.</p>
    singulars
    1. This table or related slice is empty.
    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. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    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