title: Equivalent of ObjectOutputStream, saving not only its state but the whole object?
body: <p>I'm letting the user import plugin-like classes from a remote location using URLClassLoader, so these imported classes do NOT exist in the build path (however, they all implement an interface <em>IPlugin</em> which is included). </p>
  
  <p>I assumed one could simply use ObjectOutputStream to save all the loaded plugins to file, and later read these with ObjectInputStream. That doesn't seem to be the case though, since all it saves is the state of the object, not the containing logic (i.e. methods). </p>
  
  <p>What I'd hope to do is to save the list of loaded plugins (activePlugins) with ObjectOutputStream:</p>
  
  <pre><code>ObjectOutputStream oos = new ObjectOutputStream(*fileoutputstream*);
  oos.writeObject(activePlugins);
  oos.close();
  </code></pre>
  
  <p>Then at another runtime, load/restore all these plugins with ObjectInputStream:</p>
  
  <pre><code>ObjectInputStream ois = new ObjectInputStream(*fileinputstream*);
  activePlugins = (ArrayList&lt;IPlugin&gt;) ois.readObject();
  </code></pre>
  
  <p>But since the actual object classes are not available in the build path (they are somewhere else on the harddrive), it goes haywire. What I'm after is some way of loading objects without having the classes available, i.e. loading objects with states and without dependencies.</p>