Re: [Simple-support] obligation of "static public class" ?
Brought to you by:
niallg
|
From: Patrice B. <pat...@sm...> - 2009-04-21 12:17:51
|
Hi (& thanks), I'm getting a NoSuchMethodException (...) <init>(). Just like mentionned in *[Simple-support] Problem deserializing an inner class <http://sourceforge.net/mailarchive/message.php?msg_name=48AF5691.5040103%40znyx.com>* From: Alan Deikman <Alan.Deikman@zn...> - 2008-08-23 00:15 java.lang.NoSuchMethodException: com.test.Outer$Inner.<init>() at java.lang.Class.getConstructor0(Class.java:2706) I don't have my IDE at hand right now so I can't copy/paste, but that's the exception. An I see you answered "The inner class needs to be static. Otherwise it can not be instantiated reflectively." But none of the sample in tutorial have this "public static" attribute for inner classes. And when I do make it public static, I still get the same exception. Niall Gallagher a écrit : > Hi, > > So what exception are you getting? > > Niall > > --- On Tue, 4/21/09, Patrice Bertrand <pat...@sm...> wrote: > > >> From: Patrice Bertrand <pat...@sm...> >> Subject: [Simple-support] obligation of "static public class" ? >> To: sim...@li... >> Date: Tuesday, April 21, 2009, 1:22 AM >> Hello, >> I see some persons mention a similar problem: an >> exception occuring >> when reading a list of elements. And I >> read Niall answering "you must >> declare a 'static public class' for the embedded >> items. So I changed >> my code to have both outer and inner classes in same file, >> with inner >> class declared as static public class within the first >> class, like this: >> >> @Root >> public class PropertyList { >> >> @ElementList >> private List<Entry> list; >> >> @Attribute >> private String name; >> >> public String getName() { >> return name; >> } >> >> public List getProperties() { >> return list; >> } >> >> @Root >> public static class Entry { >> >> @Attribute >> private String key; >> >> @Element >> private String value; >> >> public String getName() { >> return name; >> } >> >> public String getValue() { >> return value; >> } >> } >> >> } >> >> >> (I take this from the tutorial page, but with a minor >> change to embed >> "Entry" into "PropertyList" and make it static.) >> >> However, I still get the same exception when >> reading. What is exactly >> this obligation of a "public static class" and is it >> possible to find >> the rules that apply. The tutorial is VERY >> well done, for giving a >> overview of the possibilities, but is it possible that the >> sample code >> that are in the tutorial would not work ? >> >> Sorry for this beginner's question. I did >> go through the archive >> trying to find the answer (although search function seems >> to be >> unavailable). >> >> >> ------------------------------------------------------------------------------ >> Stay on top of everything new and different, both inside >> and >> around Java (TM) technology - register by April 22, and >> save >> $200 on the JavaOne (SM) conference, June 2-5, 2009, San >> Francisco. >> 300 plus technical and hands-on sessions. Register today. >> Use priority code J9JMT32. http://p.sf.net/sfu/p >> _______________________________________________ >> Simple-support mailing list >> Sim...@li... >> https://lists.sourceforge.net/lists/listinfo/simple-support >> >> > > > > |