google-code-export / protostuff

Automatically exported from code.google.com/p/protostuff
Apache License 2.0
1 stars 1 forks source link

RuntimeSchema.getSchema() throws NPE on fields with type Object #46

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Create a class with a field of type Object
2. Try to create a schema for it using Runtime.getSchema().

What is the expected output? What do you see instead?

I expect it to work.  It throws an NPE instead.

What version of the product are you using? On what operating system?

1.0.0.M7

Please provide any additional information below.

Original issue reported on code.google.com by dnd1...@gmail.com on 27 Jan 2011 at 4:23

Attachments:

GoogleCodeExporter commented 9 years ago
Yep this is in the works (trunk).  Funny how I've an impl for this yesterday 
and was not able to finish it.

Thanks for reporting.

Original comment by david.yu...@gmail.com on 27 Jan 2011 at 11:06

GoogleCodeExporter commented 9 years ago
Btw, since you want immutability (final modifier), see 
http://groups.google.com/group/protostuff/browse_thread/thread/2bd1299985224d9a

Original comment by david.yu...@gmail.com on 27 Jan 2011 at 11:10

GoogleCodeExporter commented 9 years ago
The impl for this is somewhat finished for pojos and inline (scalar) values.
Dynamic complex types like collections and maps can be implemented but it will 
not be efficient(creating collection schemas on the fly just to serialize the 
dynamic type)

So I'm against supporting it.  The responsibility will be left to the developer 
by using a pojo (cached schema) that wraps the collection/map.

Btw, I didn't expect any of your attached file to work.  The 
clazz.newInstance() would've been thrown.

Original comment by david.yu...@gmail.com on 30 Jan 2011 at 11:11

GoogleCodeExporter commented 9 years ago
I'm not sure what you mean that you didn't expect it to work?  It works fine, 
except for the NPE.

Original comment by dnd1...@gmail.com on 31 Jan 2011 at 10:05

GoogleCodeExporter commented 9 years ago
I meant that your pojos had final fields, unless you probably used 
sun.reflect.ReflectionFactory.getReflectionFactory().newConstructorForSerializat
ion()?

Original comment by david.yu...@gmail.com on 31 Jan 2011 at 10:38

GoogleCodeExporter commented 9 years ago
Nevermind .. didn't take a closer look at the source (clearly).

Original comment by david.yu...@gmail.com on 31 Jan 2011 at 3:27

GoogleCodeExporter commented 9 years ago
Implemented with support for complex types (multi-dimensional array, maps, 
collections, etc)

Original comment by david.yu...@gmail.com on 7 Feb 2011 at 12:31