title: Need to load some class by bootstrap Classloader
body: <p>I've the following scenario:</p>
  
  <p>I've a <code>byte[]</code> that contains the <code>.class</code> data of a class (loaded from the file system)</p>
  
  <p>And I have another <code>byte[]</code> of this some object of this class that was previously Serialized to some other stream.</p>
  
  <p>First do load the <code>byte[]</code> of the <code>.class</code> file with my custom class loader which is:</p>
  
  <pre><code>public class MainSearchClassLoader extends ClassLoader
  {
  
      public MainSearchClassLoader()
      {
          super(MainSearchClassLoader.class.getClassLoader());
      }
  
      public Class&lt;?&gt; findClass(String name) throws ClassNotFoundException
      {
          try
          {
              byte[] bytecode = FileUtil.readClassByteCode();
              return super.defineClass(ReflectionUtil.getStubBinaryClassName() , bytecode, 0, bytecode.length);
          } catch (IOException e)
          {
              e.printStackTrace();
          }
          return null;
      }
  }
  </code></pre>
  
  <p>Then I am trying to de-serialize this instance using the following code:</p>
  
  <pre><code>public static Object getObjectFromBytes(final byte[] bytes)
      {
          Object object = null;
          try
          {
              object = new ObjectInputStream(new ByteArrayInputStream(bytes)).readObject();
          } catch (final Exception ioe)
          {
              ioe.printStackTrace();
          }
          return object;
      }
  </code></pre>
  
  <p>That takes the serialized bytes and supposed to return instance (of the pre-loaded class using my custom class loader) .. I got the following exception:</p>
  
  <pre><code>11/03/06 14:23:27 oracle.classloader.util.AnnotatedClassNotFoundException: 
  
        Missing class: mainSearchObjects.dc_index
  
      Dependent class: java.io.ObjectInputStream
               Loader: jre.bootstrap:1.5.0_06
          Code-Source: unknown
        Configuration: jre bootstrap
  
  This load was initiated at MainSearch.web.MainSearch:0.0.0 using the Class.forName() method.
  
  The missing class is not available from any code-source or loader in the system.
  11/03/06 14:23:27   at oracle.classloader.PolicyClassLoader.handleClassNotFound (PolicyClassLoader.java:2068) [/D:/jdevstudio10134/j2ee/home/lib/pcl.jar (from system property java.class.path), by sun.misc.Launcher$AppClassLoader@14916158]
      at oracle.classloader.PolicyClassLoader.internalLoadClass (PolicyClassLoader.java:1679) [/D:/jdevstudio10134/j2ee/home/lib/pcl.jar (from system property java.class.path), by sun.misc.Launcher$AppClassLoader@14916158]
      at oracle.classloader.PolicyClassLoader.loadClass (PolicyClassLoader.java:1635) [/D:/jdevstudio10134/j2ee/home/lib/pcl.jar (from system property java.class.path), by sun.misc.Launcher$AppClassLoader@14916158]
      at oracle.classloader.PolicyClassLoader.loadClass (PolicyClassLoader.java:1620) [/D:/jdevstudio10134/j2ee/home/lib/pcl.jar (from system property java.class.path), by sun.misc.Launcher$AppClassLoader@14916158]
      at java.lang.ClassLoader.loadClassInternal (ClassLoader.java:319) [jre bootstrap, by jre.bootstrap:1.5.0_06]
      at java.lang.Class.forName0 (Native method) [unknown, by unknown]
      at java.lang.Class.forName (Class.java:242) [jre bootstrap, by jre.bootstrap:1.5.0_06]
      at java.io.ObjectInputStream.resolveClass (ObjectInputStream.java:574) [jre bootstrap, by jre.bootstrap:1.5.0_06]
      at java.io.ObjectInputStream.readNonProxyDesc (ObjectInputStream.java:1538) [jre bootstrap, by jre.bootstrap:1.5.0_06]
      at java.io.ObjectInputStream.readClassDesc (ObjectInputStream.java:1460) [jre bootstrap, by jre.bootstrap:1.5.0_06]
      at java.io.ObjectInputStream.readOrdinaryObject (ObjectInputStream.java:1693) [jre bootstrap, by jre.bootstrap:1.5.0_06]
      at java.io.ObjectInputStream.readObject0 (ObjectInputStream.java:1299) [jre bootstrap, by jre.bootstrap:1.5.0_06]
      at java.io.ObjectInputStream.readObject (ObjectInputStream.java:339) [jre bootstrap, by jre.bootstrap:1.5.0_06]
  ...........
  </code></pre>
  
  <p>I understood that.. The bootstrap class loader that is used by the de-serization code cannot see the class loaded by one of its children (my class loader) and I think this is a correct behaiour, isn't it?</p>
  
  <p>So, Isn't a solution to this problem??</p>