If this question is still actual there is question on stackoverflow http://stackoverflow.com/questions/1584054/declare-member-variables-with-gen-class-in-clojure
:state option to genclass is probably what you need http://clojure.github.com/clojure/clojure.core-api.html#clojure.core/gen-class On Mon, Feb 25, 2013 at 10:05 PM, Mingli Yuan <mingli.y...@gmail.com> wrote: > When using a java machine-learning package - mallet, we failed to > serialize the class we generated by gen-class. > > Exception is as below: > > Exception in thread "Thread-8" java.io.InvalidClassException: > lancelot.SegmentorPipe; local class incompatible: stream classdesc > serialVersionUID = 2583852145887230781, local class serialVersionUID = > -2255006751011717591 at > java.io.ObjectStreamClass.initNonProxy(ObjectStreamClass.java:579) at > java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1601) at > java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1514) at > java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1750) > at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1347) at > java.io.ObjectInputStream.readObject(ObjectInputStream.java:369) > > * > * > Code snippet: > * > * > > (gen-class > :name lancelot.Instance > :extends cc.mallet.types.Instance) > (gen-class > :name lancelot.FilterPipe > :extends cc.mallet.pipe.Pipe > :prefix "-filter-" > :methods [[pipe [cc.mallet.types.Instance] lancelot.Instance]]) > (defn -filter-pipe [this ^cc.mallet.types.Instance inst] > (.setData inst (clojure.string/join " " > (filter normal-word? (clojure.string/split (.getData inst) #"\s+")))) > inst) > (gen-class > :name lancelot.SegmentorPipe > :extends cc.mallet.pipe.Pipe > :prefix "-segmentor-" > :methods [[pipe [cc.mallet.types.Instance] lancelot.Instance]]) > (defn -segmentor-pipe [this ^cc.mallet.types.Instance inst] > (.setData inst (seg/seg (.getData inst))) > inst) > > * > * > The problem is that serialVersionUID need to be static and final, but it > seems that gen-class can only generate instance level final field. > * > * > I posted this question on > SO<http://stackoverflow.com/q/15062179/210629?sem=2>, > but it seems none answered it, so I reposted it here. > > Thanks a lot for your help. > > > -- > -- > You received this message because you are subscribed to the Google > Groups "Clojure" group. > To post to this group, send email to clojure@googlegroups.com > Note that posts from new members are moderated - please be patient with > your first post. > To unsubscribe from this group, send email to > clojure+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/clojure?hl=en > --- > You received this message because you are subscribed to the Google Groups > "Clojure" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to clojure+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/groups/opt_out. > > > -- Petr Gladkikh -- -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.