@Override
        @SuppressWarnings("unchecked")
        public <T> Field<T> create(int number, java.lang.String name,
                final java.lang.reflect.Field f, IdStrategy strategy)
        {
            if (pojo(f.getType(), f.getAnnotation(Morph.class), strategy))
                return POJO.create(number, name, f, strategy);

            return new RuntimeDerivativeField<T>((Class<Object>) f.getType(),
                    FieldType.MESSAGE, number, name, false,
                    f.getAnnotation(Tag.class), strategy)
            {
                {
                    f.setAccessible(true);
                }

                public void mergeFrom(Input input, T message)
                        throws IOException
                {
                    final Object value = input.mergeObject(message, schema);
                    if (input instanceof GraphInput
                            && ((GraphInput) input).isCurrentMessageReference())
                    {
                        // a reference from polymorphic+cyclic graph deser
                        try
                        {
                            f.set(message, value);
                        }
                        catch (IllegalAccessException e)
                        {
                            throw new RuntimeException(e);
                        }
                        catch (IllegalArgumentException e)
                        {
                            throw new RuntimeException(e);
                        }
                    }
                }

                public void writeTo(Output output, T message)
                        throws IOException
                {
                    final Object existing;
                    try
                    {
                        existing = f.get(message);
                    }
                    catch (IllegalAccessException e)
                    {
                        throw new RuntimeException(e);
                    }
                    catch (IllegalArgumentException e)
                    {
                        throw new RuntimeException(e);
                    }

                    if (existing != null)
                        output.writeObject(number, existing, schema, false);
                }

                public void transfer(Pipe pipe, Input input, Output output,
                        boolean repeated) throws IOException
                {
                    output.writeObject(number, pipe, schema.pipeSchema, false);
                }

                public void doMergeFrom(Input input, Schema<Object> schema,
                        Object message) throws IOException
                {
                    try
                    {
                        final Object existing = f.get(message);

                        // merge if not null and is same type.
                        final Object value = existing == null
                                || existing.getClass() != schema.typeClass() ? schema
                                .newMessage() : existing;

                        if (input instanceof GraphInput)
                        {
                            // update the actual reference.
                            ((GraphInput) input).updateLast(value, message);
                        }

                        schema.mergeFrom(input, value);
                        f.set(message, value);
                    }
                    catch (IllegalAccessException e)
                    {
                        throw new RuntimeException(e);
                    }
                    catch (IllegalArgumentException e)
                    {
                        throw new RuntimeException(e);
                    }
                }
                
                @Override
                protected Field<T> copy(IdStrategy strategy)
                {
                    return POLYMORPHIC_POJO.create(number, name, f, strategy);
                }
            };
        }
Field factory via plain old reflection api.

@author David Yu
@created Jul 7, 2011
protostuff-runtime/src/main/java/io/protostuff/runtime/RuntimeReflectionFieldFactory.java