Object bean; InputStream serStream;  if (cl == null) { serStream = ClassLoader.getSystemResourceAsStream (beanName.replace ('.','/')+".ser"); } else { serStream = cl.getResourceAsStream (beanName.replace ('.', '/') + ".ser"); }  if (serStream != null) { if(cl == null) { ObjectInputStream ois = new ObjectInputStream(serStream); bean = ois.readObject(); } else { ClassLoaderObjectInputStream ois = new ClassLoaderObjectInputStream (serStream, cl); bean = ois.readObject(); } } else if(cl == null) { Class beanClass = Class.forName(beanName); try { bean = beanClass.newInstance(); } catch(IllegalAccessException E) { bean = null; } catch(InstantiationException E) { bean = null; } } else { Class beanClass = cl.loadClass(beanName); try { bean = beanClass.newInstance(); } catch(IllegalAccessException E) { bean = null; } catch(InstantiationException E) { bean = null; } }  if(bean instanceof Applet) { Applet a = (Applet)bean;   if(serStream == null) { a.init(); } }  return bean; }
return instantiate(cl, beanName, null, null); }
  public static Object instantiate (ClassLoader cl, String beanName)    throws IOException, ClassNotFoundException  {    Object bean;    InputStream serStream;        if (cl == null)      {        serStream = ClassLoader.getSystemResourceAsStream          (beanName.replace ('.','/')+".ser");      }    else      {        serStream = cl.getResourceAsStream (beanName.replace ('.', '/')                                            + ".ser");      }        if (serStream != null)      {        if(cl == null)          {            ObjectInputStream ois = new ObjectInputStream(serStream);            bean = ois.readObject();          }        else          {            ClassLoaderObjectInputStream ois =              new ClassLoaderObjectInputStream (serStream, cl);            bean = ois.readObject();          }      }    else if(cl == null)      {        Class beanClass = Class.forName(beanName);        try          {            bean = beanClass.newInstance();          }        catch(IllegalAccessException E)          {            bean = null;          }        catch(InstantiationException E)          {            bean = null;          }      }    else      {        Class beanClass = cl.loadClass(beanName);        try          {            bean = beanClass.newInstance();          }        catch(IllegalAccessException E)          {            bean = null;          }        catch(InstantiationException E)          {            bean = null;          }      }    if(bean instanceof Applet)      {        Applet a = (Applet)bean;        //a.setAppletContext(???);        //a.setStub(???);        if(serStream == null)          {            a.init();          }      }    return bean;  }