@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()); }
@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; }
@Override public final Class getExpectedClass() { return _def.getType(); }
private void writeObject(ObjectOutputStream out) throws IOException { out.writeObject(_classDef.getType().getCanonicalName()); out.writeObject(_object); }