Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Maybe you have your JAR in your initial class loader. URLClassLoader will check existing class in parent class loader before checking in its own space.</p> <p>1) You can extend and modify this behavior:</p> <pre><code>package com.mytool; import java.net.URL; import java.net.URLClassLoader; import java.net.URLStreamHandlerFactory; import java.util.HashMap; import java.util.Map; public class MyURLClassLoader extends URLClassLoader { private final Map&lt;String, Class&lt;?&gt;&gt; ourClasses = new HashMap&lt;&gt;(); public MyURLClassLoader(URL[] urls, ClassLoader parent) { super(urls, parent); } public MyURLClassLoader(URL[] urls) { super(urls); } public MyURLClassLoader(URL[] urls, ClassLoader parent, URLStreamHandlerFactory factory) { super(urls, parent, factory); } @Override protected Class&lt;?&gt; loadClass(String name, boolean resolve) throws ClassNotFoundException { synchronized (getClassLoadingLock(name)) { // First, check if the class has already been loaded Class&lt;?&gt; c = ourClasses.get(name); if (c == null) { // search in our paths try { c = findClass(name); ourClasses.put(name, c); } catch (ClassNotFoundException e) { // ignore } } if (c == null) { c = findLoadedClass(name); } if (c != null) { if (resolve) { resolveClass(c); } return c; } // default search return super.loadClass(name, resolve); } } } </code></pre> <p>2) Or you can try to move our JAR and not load it at JVM start.</p> <p><strong>Note:</strong> Instead of using a full reflexivity, I'll use an interface loaded only by the initial classloader. Your object could implements it, and you'll be able to cast to this interface. If you do this with MyURLClassLoader, please don't add this interface in our dynamic loaded JAR!</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