@JRubyMethod public IRubyObject marshal_dump() { if ( ! Serializable.class.isAssignableFrom(object.getClass()) ) { throw getRuntime().newTypeError("Java type is not serializable, cannot be marshaled " + getJavaClass()); } try { ByteArrayOutputStream bytes = new ByteArrayOutputStream(); new ObjectOutputStream(bytes).writeObject(object); return getRuntime().newString(new ByteList(bytes.toByteArray(), false)); } catch (IOException ex) { throw getRuntime().newTypeError("Java type is not serializable: " + ex.getMessage()); } }
@JRubyMethod public IRubyObject marshal_dump() { if ( ! Serializable.class.isAssignableFrom(object.getClass()) ) { throw getRuntime().newTypeError("Java type is not serializable, cannot be marshaled " + getJavaClass()); } try { ByteArrayOutputStream bytes = new ByteArrayOutputStream(); new ObjectOutputStream(bytes).writeObject(object); return getRuntime().newString(new ByteList(bytes.toByteArray(), false)); } catch (IOException ex) { throw getRuntime().newTypeError("Java type is not serializable: " + ex.getMessage()); } }
@JRubyMethod public IRubyObject marshal_dump() { if (Serializable.class.isAssignableFrom(object.getClass())) { try { ByteArrayOutputStream baos = new ByteArrayOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(baos); oos.writeObject(object); return getRuntime().newString(new ByteList(baos.toByteArray())); } catch (IOException ioe) { throw getRuntime().newTypeError("Java type is not serializable: " + ioe.getMessage()); } } else { throw getRuntime().newTypeError("Java type is not serializable, cannot be marshaled " + getJavaClass()); } }
@JRubyMethod public IRubyObject marshal_dump() { if (Serializable.class.isAssignableFrom(object.getClass())) { try { ByteArrayOutputStream baos = new ByteArrayOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(baos); oos.writeObject(object); return getRuntime().newString(new ByteList(baos.toByteArray())); } catch (IOException ioe) { throw getRuntime().newTypeError("Java type is not serializable: " + ioe.getMessage()); } } else { throw getRuntime().newTypeError("Java type is not serializable, cannot be marshaled " + getJavaClass()); } }
private static void findFields(ThreadContext context, RubyModule topModule, IRubyObject args[], boolean asReader, boolean asWriter) { Map<String, String> fieldMap = getFieldListFromArgs(args); for (RubyModule module = topModule; module != null; module = module.getSuperClass()) { Class<?> javaClass = getJavaClass(context, module); // Hit a non-java proxy class (included Modules can be a cause of this...skip) if (javaClass == null) continue; Field[] fields = JavaClass.getDeclaredFields(javaClass); for (int j = 0; j < fields.length; j++) { installField(context, fieldMap, fields[j], module, asReader, asWriter); } } // We could not find all of them print out first one (we could print them all?) if (!fieldMap.isEmpty()) { throw JavaClass.undefinedFieldError(context.runtime, topModule.getName(), fieldMap.keySet().iterator().next()); } }
private static void findFields(ThreadContext context, RubyModule topModule, IRubyObject args[], boolean asReader, boolean asWriter) { Map<String, String> fieldMap = getFieldListFromArgs(args); for (RubyModule module = topModule; module != null; module = module.getSuperClass()) { Class<?> javaClass = getJavaClass(context, module); // Hit a non-java proxy class (included Modules can be a cause of this...skip) if (javaClass == null) continue; Field[] fields = JavaClass.getDeclaredFields(javaClass); for (int j = 0; j < fields.length; j++) { installField(context, fieldMap, fields[j], module, asReader, asWriter); } } // We could not find all of them print out first one (we could print them all?) if (!fieldMap.isEmpty()) { throw JavaClass.undefinedFieldError(context.runtime, topModule.getName(), fieldMap.keySet().iterator().next()); } }