taoensso / nippy

The fastest serialization library for Clojure
https://www.taoensso.com/nippy
Eclipse Public License 1.0
1.04k stars 60 forks source link

Unfreezing fn when AOT #61

Closed etherny closed 9 years ago

etherny commented 9 years ago

When i compile my code in AOT mode, i can't freeze data if i use fn as hashmap value. If i remove AOT compilation. all work fine.

ptaoussanis commented 9 years ago

Hi there, I'm afraid that's to be expected: Clojure fns aren't the easiest thing to serialize (for one - they may involve closures, etc.). They do implement Java's Serializable interface (which is why Nippy is successfully freezing/thawing them at all) - but that tends to be error prone (e.g. across JVMs) and will definitely fail with AOT afaik.

Only real solution is to avoid needing to serialize a whole fn, unfortunately.

Sorry I couldn't offer anything more helpful!