kryo - Java: How to force upcast? -


i'm using kryo library serialization in java. have problem have no way force upcast. here example situation:

class {} class b extends {}  public save() {     kryo kryo = new kryo();     kryo.setregistrationrequired(true); //force registration     kryo.register(a.class); //register kryo     output output = new output( ... );      b bar = new b();     kryo.writeobject(output, (a) bar); //try cast } 

this causes class not registered error, because bar still instance of b.

is there way force bar cast instance of a, or need new a(bar)?

upcasting doesn't change object itself, type of reference points it. have register b.class.


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -