Why does Preon give a java.lang.InstantiationException for references to inner classes? -
this modified version of imagetest file embeds image class inside main class , produces instantiationexception. i'm wondering why runtime exception being thrown , if there's away work around without splitting out inner class separate file...
/* * copyright (c) 2009-2010 wilfred springer * * file part of preon. * * preon free software; can redistribute and/or modify under * terms of gnu general public license published free software * foundation; either version 2, or (at option) later version. * * preon distributed in hope useful, without * warranty; without implied warranty of merchantability or fitness * particular purpose. see gnu general public license more details. * * should have received copy of gnu general public license along * preon; see file copying. if not, write free software * foundation, inc., 51 franklin street, fifth floor, boston, ma 02110-1301 usa. * * linking library statically or dynamically other modules making * combined work based on library. thus, terms , conditions of * gnu general public license cover whole combination. * * special exception, copyright holders of library give * permission link library independent modules produce * executable, regardless of license terms of these independent modules, , * copy , distribute resulting executable under terms of choice, * provided meet, each linked independent module, terms * , conditions of license of module. independent module * module not derived or based on library. if modify * library, may extend exception version of library, * not obligated so. if not wish so, delete * exception statement version. */ import org.codehaus.preon.codecs; import org.codehaus.preon.codec; import org.codehaus.preon.decodingexception; import org.codehaus.preon.annotation.boundlist; import org.codehaus.preon.annotation.boundnumber; import org.codehaus.preon.buffer.byteorder; import org.codehaus.preon.el.importstatic; public class embeddedimageruntimetest { public class embeddedimage { @boundnumber(byteorder = byteorder.bigendian) private int height; @boundnumber(byteorder = byteorder.bigendian) private int width; @boundlist(size = "height*width") private color[] pixels; public int getheight() { return height; } public int getwidth() { return width; } public color[] getpixels() { return pixels; } } public static void main(string[] args) throws decodingexception { codec<embeddedimage> codec = codecs.create(embeddedimage.class); byte[] buffer = new byte[]{ 0, 0, 0, 1, 0, 0, 0, 1, 1, 2, 3 }; embeddedimage image = codecs.decode(codec, buffer); system.out.println("embeddedimage image: " + image); } }
Comments
Post a Comment