Closed smee closed 7 years ago
If I replace the line in https://github.com/ptaoussanis/nippy/blob/master/src/taoensso/nippy.clj#L1100 with
(let [class (clojure.lang.RT/classForName class-name)
I get a thawed instance of the redefined record. Transcript:
user> (in-ns 'taoensso.nippy)
;; => #namespace[taoensso.nippy]
taoensso.nippy> (defn- read-record [in class-name]
(let [content (thaw-from-in! in)]
(try
(let [class (clojure.lang.RT/classForName class-name)
method (.getMethod class "create" class-method-sig)]
(.invoke method class (into-array Object [content])))
(catch Exception e
{:type :record
:throwable e
:nippy/unthawable {:class-name class-name :content content}}))))
;; => #'taoensso.nippy/read-record
taoensso.nippy> (in-ns 'user)
;; => #namespace[user]
user> (str (taoensso.nippy/thaw frozen))
;; => redefined
Hi Steffen, appreciate the clear example - and for digging into this!
That looks like a promising modification. Will investigate further and get a change up if there's no unexpected issues.
Much thanks, cheers! :-)
You are welcome! Thanks for this great library.
Just pushed [com.taoensso/nippy "2.14.0-alpha1"]
to Clojars with this change, cheers!
I have the same problem as the original submitter of ticket #44. Somehow nippy seems to keep the old class definition of records when thawing an instance. As a demonstration please see here: I create a simple record with a custom
toString
method so we can see which version of the record we have:I'm using clojure 1.9.0-alpha14 and nippy 2.12.2