@Override
        @SuppressWarnings("unchecked")
        public <T> Field<T> create(int number, String name,
                final java.lang.reflect.Field f, IdStrategy strategy)
        {
            final Delegate<Object> delegate = strategy
                    .getDelegate((Class<Object>) f.getType());

            return new Field<T>(FieldType.BYTES, number, name,
                    f.getAnnotation(Tag.class))
            {
                {
                    f.setAccessible(true);
                }

                @Override
                public void mergeFrom(Input input, T message)
                        throws IOException
                {
                    final Object value = delegate.readFrom(input);

                    try
                    {
                        f.set(message, value);
                    }
                    catch (IllegalAccessException e)
                    {
                        throw new RuntimeException(e);
                    }
                    catch (IllegalArgumentException e)
                    {
                        throw new RuntimeException(e);
                    }
                }

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

                    if (value != null)
                        delegate.writeTo(output, number, value, false);
                }

                @Override
                public void transfer(Pipe pipe, Input input, Output output,
                        boolean repeated) throws IOException
                {
                    delegate.transfer(pipe, input, output, number, repeated);
                }
            };
        }
Field factory via plain old reflection api.

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