Beispiel #1
0
  @Override
  public Value clone(Env env) {
    Object obj = null;

    if (_object != null) {
      if (!(_object instanceof Cloneable)) {
        return env.error(
            L.l("Java class {0} does not implement Cloneable", _object.getClass().getName()));
      }

      Class<?> cls = _classDef.getType();

      try {
        Method method = cls.getMethod("clone", new Class[0]);
        method.setAccessible(true);

        obj = method.invoke(_object);
      } catch (NoSuchMethodException e) {
        throw new QuercusException(e);
      } catch (InvocationTargetException e) {
        throw new QuercusException(e.getCause());
      } catch (IllegalAccessException e) {
        throw new QuercusException(e);
      }
    }

    return new JavaValue(env, obj, _classDef, getQuercusClass());
  }
Beispiel #2
0
  @Override
  protected int getMarshalingCostImpl(Value argValue) {
    Class type = _def.getType();

    if (argValue instanceof JavaValue && type.isAssignableFrom(argValue.toJavaObject().getClass()))
      return Marshal.ZERO;
    else return Marshal.FOUR;
  }
Beispiel #3
0
 @Override
 public final Class getExpectedClass() {
   return _def.getType();
 }
Beispiel #4
0
  private void writeObject(ObjectOutputStream out) throws IOException {
    out.writeObject(_classDef.getType().getCanonicalName());

    out.writeObject(_object);
  }