/**
  *
  * @param ReflectionClass $customSerializer
  * @param MappedClass $instanceClass
  * @return Object
  * @throws InstantiationException
  * @throws IllegalAccessException
  * @throws IllegalArgumentException
  * @throws InvocationTargetException
  */
 private function instantiate(ReflectionClass $customSerializer = null, MappedClass $instanceClass)
 {
     if ($customSerializer != null) {
         try {
             /*ReflectionMethod*/
             $instantiate = $customSerializer->getMethod('instantiate');
             //, SerializationStreamReader.class);
             return $instantiate->invoke(null, $this);
         } catch (ReflectionException $ex) {
             // purposely ignored
         }
     }
     if ($instanceClass->isArray()) {
         $length = $this->readInt();
         /*MappedClass*/
         $componentType = $instanceClass->getComponentType();
         require_once GWTPHP_DIR . '/util/ArrayUtil.class.php';
         return ArrayUtil::initArrayWithSize($length);
         //Array.newInstance(componentType, length);
     } else {
         return $instanceClass->newInstance();
     }
 }
 /**
  *
  * @param ReflectionClass $customSerializer
  * @param MappedClass $instanceClass
  * @return Object
  * @throws InstantiationException
  * @throws IllegalAccessException
  * @throws IllegalArgumentException
  * @throws InvocationTargetException
  */
 private function instantiate(ReflectionClass $customSerializer = null, MappedClass $instanceClass)
 {
     if ($customSerializer != null) {
         try {
             /*ReflectionMethod*/
             //TODO gwt-1.5 costumeserializer nie musi miec metody instantiate, wiec trzeba wziac zbadac zadeklarowane metody i jesli nie ma instantiate to idziemy dalej (teraz bedzie error gdy brak)
             $instantiate = $customSerializer->getMethod('instantiate');
             //, SerializationStreamReader.class);
             return $instantiate->invoke(null, $this);
         } catch (ReflectionException $ex) {
             // purposely ignored
         }
     }
     if ($instanceClass->isArray()) {
         $length = $this->readInt();
         /*MappedClass*/
         //TODO: gwt-1.5
         $componentType = $instanceClass->getComponentType();
         // We don't pre-allocate the array; this prevents an allocation attack
         return new BoundedList($componentType, $length);
         //removed require_once (GWTPHP_DIR . '/util/ArrayUtil.class.php');
         //removed return ArrayUtil::initArrayWithSize ( $length ); //Array.newInstance(componentType, length);
     } else {
         return $instanceClass->newInstance();
     }
 }