title: Jmockit with Custom Class Loader: System class loader does not support adding JAR file to system class path during the live phase
body: <p>I am using a custom class loader like this:</p>
  
  <pre><code>public class MyClassLoader extends URLClassLoader {
      public MyClassLoader(ClassLoader parent) {
          super(((URLClassLoader) parent).getURLs(), parent);
      }
  }
  </code></pre>
  
  <p>and I'm using jmockit too. for example consider this code:</p>
  
  <pre><code>public static void main(String[] args) throws Exception {
          new MockUp&lt;Main&gt;(){
  
          };
      }
  </code></pre>
  
  <p>when I run the app with 
  -Djava.system.class.loader=app.MyClassLoader it throws this exception:</p>
  
  <pre><code>Exception in thread "main" java.lang.ExceptionInInitializerError
      at app.Main.main(Main.java:12)
  Caused by: java.lang.IllegalStateException: com.sun.tools.attach.AgentLoadException: Unable to add JAR file to system class path
      at mockit.internal.startup.AgentLoader.loadAgentAndDetachFromRunningVM(AgentLoader.java:150)
      at mockit.internal.startup.AgentLoader.loadAgent(AgentLoader.java:56)
      at mockit.internal.startup.Startup.verifyInitialization(Startup.java:172)
      at mockit.MockUp.&lt;clinit&gt;(MockUp.java:94)
      ... 1 more
  Caused by: com.sun.tools.attach.AgentLoadException: Unable to add JAR file to system class path
      at sun.tools.attach.HotSpotVirtualMachine.loadAgent(HotSpotVirtualMachine.java:119)
      at mockit.internal.startup.AgentLoader.loadAgentAndDetachFromRunningVM(AgentLoader.java:146)
      ... 4 more
  System class loader does not support adding JAR file to system class path during the live phase!
  Unable to add C:\Users\hmdha\.m2\repository\org\jmockit\jmockit\1.23\jmockit-1.23.jar to system class path - not supported by system class loader or configuration error!
  </code></pre>
  
  <p>should I add anything to my Class Loader to prevent this error?</p>