if (type == ArrayList.class)
collection = new ArrayList(length);
else
collection = (Collection)newInstance(kryo, type);
com.sun.jdi.InvocationException occurred invoking method.
import de.javakaffee.kryoserializers.ArraysAsListSerializer
kryo.register(Arrays.asList("dummy").getClass, new ArraysAsListSerializer(kryo))
--
You received this message because you are subscribed to the "kryo-users" group.
http://groups.google.com/group/kryo-users
An argument against this (and the reason why I used Arrays.asList in
ArraysAsListSerializer.create) is that Arrays.asList creates a fixed
size list, so that Arrays.asList().add("foo") throws an
UnsupportedOperationException.
If you use a j.u.ArrayList for deserialization behaviour is different
after deserialization.
Cheers,
Martin
Cheers,
Martin
> the java.util.Arrays$__ArrayList, __CollectionSerializer.java:113
>             throws a null pointer exception. Is there a way I can get
>             around it? (perhaps some special serializer?)
> 
>             Thanks.
> 
> 
>             It appears that in the following lines failed when kryo was
>             trying to create a new collection. 
> 
>             if (type == ArrayList.class)
> 
>             collection = new ArrayList(length);
> 
>             else
> 
>             collection = (Collection)newInstance(kryo, type);
> 
> 
> com.sun.jdi.__InvocationException occurred invoking method.
> 
> 
> 
>             --
>             Reynold Xin
>             Algorithms, Machines, People Lab | Database Group
>             Electrical Engineering and Computer Science, UC Berkeley
>             http://www.cs.berkeley.edu/~__rxin/
>             <http://www.cs.berkeley.edu/%7Erxin/>
> 
>         -- 
>         You received this message because you are subscribed to the
>         "kryo-users" group.
>         http://groups.google.com/group/kryo-users
> 
> 
> 
> -- 
> You received this message because you are subscribed to the "kryo-users"
> group.
> http://groups.google.com/group/kryo-users
-- 
Brakhane, Grotzke und Langbehn Informatiker und Physiker PartG
Breitenfelder Str. 13c, 20251 Hamburg
Amtsgericht Hamburg, PR 795
http://inoio.de
> 
> You could use my concise version of ArraysAsListSerializer that extends
> FieldSerializer in kryo-serializers if you like.
I think I'll do that.
Cheers,
Martin
Hi - I'm experiencing a similar issue but am not quite sure how to resolve it. My object is serializing but the deserialization fails withcom.esotericsoftware.kryo.KryoException: java.lang.NullPointerExceptionSerialization trace:_patternList (com.elise.bitoflife.botworld.aiml.Pattern)_pattern (com.elise.bitoflife.botworld.aiml.Category)_categoryList (com.elise.bitoflife.botworld.aiml.Aiml)_aimlList (com.elise.bitoflife.botworld.brain.Brain)at com.esotericsoftware.kryo.serializers.FieldSerializer$ObjectField.read(FieldSerializer.java:536)at com.esotericsoftware.kryo.serializers.FieldSerializer.read(FieldSerializer.java:221)at com.esotericsoftware.kryo.Kryo.readObject(Kryo.java:651)......Caused by: java.lang.NullPointerExceptionat java.util.Arrays$ArrayList.size(Unknown Source)at java.util.AbstractList.add(Unknown Source)at com.esotericsoftware.kryo.serializers.CollectionSerializer.read(CollectionSerializer.java:104)at com.esotericsoftware.kryo.serializers.CollectionSerializer.read(CollectionSerializer.java:18)at com.esotericsoftware.kryo.Kryo.readObject(Kryo.java:651)at com.esotericsoftware.kryo.serializers.FieldSerializer$ObjectField.read(FieldSerializer.java:515)I'm using kryo 2.19 - following the directions from https://code.google.com/p/kryo/;my code looks like:_kryo = new Kryo(); // ReflectionFactorySupport();_kryo.register(Category.class);....output = new Output(new FileOutputStream(resourceLocation));_kryo.writeObject(output, MyClass_ );...input = new Input(new FileInputStream(fileName));b = _kryo.readObject(input, MyClass.class);I've tried (separately)_kryo.setInstantiatorStrategy(new StdInstantiatorStrategy());or_kryo.setInstantiatorStrategy(new SerializingInstantiatorStrategy());but both lead to other, more cryptic errors - and the serialization fails.also, I've tried_kryo.register(Arrays.asList("").getClass(), new ArraysAsListSerializer(_kryo));but that also fails - this class comes from .10 or .9 kryo-serializers
any suggestions as to how to resolve this issue - which appears to be around serializing/deserialziing Arrays$ArraysList (apparently, the size of the list on creation)?Any help appreciated.CF>
kryo-serializers are not yet updated for kryo2, but there's a branch for an older version of kryo2 and forks of that branch that should be more up2date. I'm currently (and the next 4 weeks) on vacation but will work on kryo-serializers when I'm back.
Cheers,
Martin
Hi Nate - my code uses Arrays.toList() in various places - the
question is - does kryo work out of the box serializing/deserializing
uch code? If not, what needs to be done to make it work properly?
I've attached a working example that produces a different error upon
deserialization but still associated with Arrays$ArrayList and perhaps
symptomatic of the general issue:
Please check pull requests and forks of kryo-serializers (they should have set the version of used kryo2 in pom.xml). I'm sorry I can't rule this out for you as I'm on vacation with my phone only (and right now need to get on the road again).
Cheers,
Martin
Hi Nate - I replaced the use of Arrays.ToList(...) throughout the code and added _kryo.setInstantiatorStrategy(new SerializingInstantiatorStrategy());serialization/deserialization now works on some instances of the object type I'm working with but not on other instances - I don't see what could be different that might the cause of the issue. The instances that work however do so consistently, similarly with those that fail.I've attached kryo tracer output for a particular run where the serialization 'worked' but the deserialization fails withException during kryo brain restoration e:Unable to find class:XXXXcom.elise.bitoflife.botworld.aiml.Category
The class name reported has 4 'characters' in front of the 'com' which should not be there - they don't render in the post here (though they render in eclipse console, box with inverted c inside of that means anything to you) - I've just represented them here as 'X' so we can see them. it looks like either the write or the read is corrupt somehow.