Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>In <strong>any</strong> modular environment, such as OSGi, it is not sufficient to load a class only by name, because many modules might have a class with that name. Therefore a class must be uniquely identified using the class name <strong>AND</strong> the module that should load it.</p> <p>If you call <code>Class.forName()</code> in its single-arg form then you are failing to provide the module information, so Java falls back to using the caller's class loader. This is no better than just taking a random guess. In your case it just happened to work (it found the class), but only through pure luck!</p> <p>If you call <code>ClassLoader.loadClass()</code> – note this is not a static method – then you are actually providing a class loader. This is much better! Unfortunately you provided the wrong loader, i.e., not the one that actually knows about the class. You didn't specify where you got this loader from so I can only speculate why it was wrong.</p> <p>Better is to use OSGi's <code>Bundle.loadClass()</code> method, which allows you to explicitly load a class from a bundle. Again you need to know which bundle the class is supposed to come from, but that's an inevitable consequence of working in a modular environment.</p> <p>Finally, even better still is to forget about dynamic class loading completely and learn how to use Services. You should never have to use dynamic class loading in OSGi, except when dealing with 3rd party or legacy libraries that require it.</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.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. 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