How to use the protostuff schema for Object[]

166 views
Skip to first unread message

yanchuan2026

unread,
Feb 5, 2018, 12:10:50 PM2/5/18
to protostuff
Hi,

I'm having troubles  when get schema use Object[]


Caused by: java.lang.RuntimeException: The root object can neither be an abstract class nor interface: "[Ljava.lang.Object;

at io.protostuff.runtime.RuntimeSchema.createFrom(RuntimeSchema.java:214)

at io.protostuff.runtime.RuntimeSchema.createFrom(RuntimeSchema.java:187)

at io.protostuff.runtime.IdStrategy.newSchema(IdStrategy.java:116)

at io.protostuff.runtime.DefaultIdStrategy$Lazy.getSchema(DefaultIdStrategy.java:709)

at io.protostuff.runtime.RuntimeSchema.getSchema(RuntimeSchema.java:149)

at io.protostuff.runtime.RuntimeSchema.getSchema(RuntimeSchema.java:140)


How to use the protostuff schema for Object[]?


Thanks

David Yu

unread,
Feb 5, 2018, 12:13:52 PM2/5/18
to protostuff
Use a generic wrapper object.  E.g.

public class Wrapper {
  public Object obj;
}

Use the wrapper's schema to serialize/deserialize.



Thanks

--
You received this message because you are subscribed to the Google Groups "protostuff" group.
To unsubscribe from this group and stop receiving emails from it, send an email to protostuff+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
When the cat is away, the mouse is alone.
dyuproject.com

chenzhe...@gmail.com

unread,
Mar 7, 2018, 4:25:37 AM3/7/18
to protostuff
I am sorry to ask you a question here. I have already post a topic but I can not see my question on the list.

I try to serialize generated AST information from Eclipse-JDT parser.  The exception message is shown

Exception in thread "main" java.lang.RuntimeException: Not able to map any fields from class net.core.dom.NodeEventHandler.  All fields are either transient/static.
at com.dyuproject.protostuff.runtime.RuntimeSchema.createFrom(RuntimeSchema.java:245)
at com.dyuproject.protostuff.runtime.RuntimeSchema.createFrom(RuntimeSchema.java:156)
at com.dyuproject.protostuff.runtime.IdStrategy.newSchema(IdStrategy.java:129)
at com.dyuproject.protostuff.runtime.DefaultIdStrategy$Lazy.getSchema(DefaultIdStrategy.java:630)
at com.dyuproject.protostuff.runtime.RuntimeMessageField.getSchema(RuntimeMessageField.java:52)
at com.dyuproject.protostuff.runtime.RuntimeUnsafeFieldFactory$13$1.writeTo(RuntimeUnsafeFieldFactory.java:793)
at com.dyuproject.protostuff.runtime.MappedSchema.writeTo(MappedSchema.java:203)
at com.dyuproject.protostuff.ProtostuffOutput.writeObject(ProtostuffOutput.java:373)
at com.dyuproject.protostuff.runtime.RuntimeUnsafeFieldFactory$13$1.writeTo(RuntimeUnsafeFieldFactory.java:793)
at com.dyuproject.protostuff.runtime.MappedSchema.writeTo(MappedSchema.java:203)
at com.dyuproject.protostuff.ProtostuffIOUtil.toByteArray(ProtostuffIOUtil.java:183)
at net.ProtostuffTest.decode(ProtostuffTest.java:16)
at net.ProtostuffTest.main(ProtostuffTest.java:31)

However, the NodeEventHandler class is full of default implementation methods that do nothing.

Reply all
Reply to author
Forward
0 new messages