Thursday, 15 May 2014

floating point - Java msgpack class with floats crashes -



floating point - Java msgpack class with floats crashes -

i have simple java class represents 2d vector. yet when run code serialize message pack, creates runtime error. serializing class should basic behaviour , should work, right? found no 1 else has similar problems.

the code , exceptions below. using java 1.7 sdk on windows 7 in eclipse , tried message pack 1.6.6 , 1.6.7 maven.

import org.jbox2d.common.vec2; import org.msgpack.annotation.message; @message public class servec2 { public float x,y; public servec2(vec2 v) { this.x = v.x; this.y = v.y; } public vec2 tov() { homecoming new vec2(x,y); } } void somewhereelse(servec2 sv) { messagepack msgpack = new messagepack(); byte[] bytes = msgpack.write(sv); }

the runtime error:

feb 18, 2013 8:48:49 org.msgpack.template.builder.buildcontext build severe: builder: { if (!$3 && $1.tryskipnil()) { homecoming null; } skylights.util.servec2 _$$_t; if ($2 == null) { _$$_t = new skylights.util.servec2(); } else { _$$_t = (skylights.util.servec2) $2; } $1.readarraybegin(); _$$_t.x = $1.readfloat(); _$$_t.y = $1.readfloat(); $1.readarrayend(); homecoming _$$_t; } org.msgpack.messagetypeexception: org.msgpack.template.builder.templatebuildexception: cannot compile: { if (!$3 && $1.tryskipnil()) { homecoming null; } skylights.util.servec2 _$$_t; if ($2 == null) { _$$_t = new skylights.util.servec2(); } else { _$$_t = (skylights.util.servec2) $2; } $1.readarraybegin(); _$$_t.x = $1.readfloat(); _$$_t.y = $1.readfloat(); $1.readarrayend(); homecoming _$$_t; } @ org.msgpack.template.templateregistry.buildandregister(templateregistry.java:516) @ org.msgpack.template.templateregistry.lookupafterbuilding(templateregistry.java:413) @ org.msgpack.template.templateregistry.lookup(templateregistry.java:246) @ org.msgpack.template.builder.javassisttemplatebuilder.totemplate(javassisttemplatebuilder.java:128) @ org.msgpack.template.builder.javassisttemplatebuilder.buildtemplate(javassisttemplatebuilder.java:116) @ org.msgpack.template.builder.abstracttemplatebuilder.buildtemplate(abstracttemplatebuilder.java:61) @ org.msgpack.template.templateregistry.buildandregister(templateregistry.java:503) @ org.msgpack.template.templateregistry.lookupafterbuilding(templateregistry.java:413) @ org.msgpack.template.templateregistry.lookup(templateregistry.java:246) @ org.msgpack.messagepack.write(messagepack.java:195) @ skylights.core.entity.savetobytes(entity.java:260) @ skylights.level.level.savetofile(level.java:106) @ skylights.core.gui.keyhandler.keypressed(keyhandler.java:29) @ skylights.core.game.keypressed(game.java:219) @ org.newdawn.slick.input.poll(input.java:1182) @ org.newdawn.slick.gamecontainer.updateandrender(gamecontainer.java:656) @ org.newdawn.slick.appgamecontainer.gameloop(appgamecontainer.java:456) @ org.newdawn.slick.appgamecontainer.start(appgamecontainer.java:361) @ skylights.core.game.run(game.java:264) @ skylights.core.game.main(game.java:287) caused by: org.msgpack.template.builder.templatebuildexception: cannot compile: { if (!$3 && $1.tryskipnil()) { homecoming null; } skylights.util.servec2 _$$_t; if ($2 == null) { _$$_t = new skylights.util.servec2(); } else { _$$_t = (skylights.util.servec2) $2; } $1.readarraybegin(); _$$_t.x = $1.readfloat(); _$$_t.y = $1.readfloat(); $1.readarrayend(); homecoming _$$_t; } @ org.msgpack.template.builder.buildcontext.build(buildcontext.java:73) @ org.msgpack.template.builder.defaultbuildcontext.buildtemplate(defaultbuildcontext.java:56) @ org.msgpack.template.builder.javassisttemplatebuilder.buildtemplate(javassisttemplatebuilder.java:118) @ org.msgpack.template.builder.abstracttemplatebuilder.buildtemplate(abstracttemplatebuilder.java:61) @ org.msgpack.template.templateregistry.buildandregister(templateregistry.java:503) ... 19 more caused by: javassist.cannotcompileexception: [source error] no such constructor @ javassist.ctbehavior.setbody(ctbehavior.java:417) @ javassist.ctbehavior.setbody(ctbehavior.java:383) @ javassist.ctnewmethod.make(ctnewmethod.java:138) @ org.msgpack.template.builder.buildcontext.buildreadmethod(buildcontext.java:144) @ org.msgpack.template.builder.buildcontext.build(buildcontext.java:65) ... 23 more caused by: compile error: no such constructor @ javassist.compiler.membercodegen.atmethodcallcore2(membercodegen.java:593) @ javassist.compiler.membercodegen.atmethodcallcore(membercodegen.java:575) @ javassist.compiler.membercodegen.atnewexpr(membercodegen.java:302) @ javassist.compiler.ast.newexpr.accept(newexpr.java:73) @ javassist.compiler.codegen.atassigncore(codegen.java:860) @ javassist.compiler.codegen.atvariableassign(codegen.java:793) @ javassist.compiler.codegen.atassignexpr(codegen.java:747) @ javassist.compiler.codegen.atstmnt(codegen.java:332) @ javassist.compiler.ast.stmnt.accept(stmnt.java:50) @ javassist.compiler.codegen.atstmnt(codegen.java:351) @ javassist.compiler.ast.stmnt.accept(stmnt.java:50) @ javassist.compiler.codegen.atifstmnt(codegen.java:391) @ javassist.compiler.codegen.atstmnt(codegen.java:355) @ javassist.compiler.ast.stmnt.accept(stmnt.java:50) @ javassist.compiler.codegen.atstmnt(codegen.java:351) @ javassist.compiler.ast.stmnt.accept(stmnt.java:50) @ javassist.compiler.codegen.atmethodbody(codegen.java:292) @ javassist.compiler.javac.compilebody(javac.java:223) @ javassist.ctbehavior.setbody(ctbehavior.java:409) ... 27 more

to reply own question: default contructor missing servec. able serialize, messagepack needs default constructor available.

java floating-point runtime-error msgpack messagepack

No comments:

Post a Comment