My previous post is not exactly true...From the java docs:

"Returns an unmodifiable view of the specified list. ... .Query operations on the returned list "read through" to the specified list and attempts to modify the returned list, whether direct or via its iterator, result in an UnsupportedOperationException."

Elements are NOT copied to the unmodified list.
So yes, it seems that Clojure lists are the culprit after all...I would use vectors until this is sorted. :-)

Jim

On 10/10/12 15:26, Jim foo.bar wrote:
Hmmm...It turns out this is not exclusive to Clojure...

user=> (java.util.Collections/unmodifiableList '(1 2 3 4 5))
#<UnmodifiableList (1 2 3 4 5)>
user=> (def l *1)
#'user/l
user=> l
#<UnmodifiableList (1 2 3 4 5)>
user=> (serialize! l  "TEST5")
nil
user=>  (.hashCode (deserialize! "TEST5.ser"))
0

Jim



On 10/10/12 15:16, Jim foo.bar wrote:
Lazy-seqs also seem to behave:

user=> (serialize! (map inc [1 2 3 4]) "TEST4")
nil
user=> (.hashCode (deserialize! "TEST4.ser"))
986115

Jim

On 10/10/12 15:14, Jim foo.bar wrote:
I can confirm I am seeing the behavior you describe under Clojure 1.4...

user=> (serialize! [1 2 3 4 5] "TEST")
nil
user=> (.hashCode (deserialize! "TEST.ser"))
29615266
user=> (serialize! ["a" "b" "c" "d"] "TEST2")
nil
user=> (.hashCode (deserialize! "TEST2.ser"))
3910595
user=> (serialize! '("a" "b" "c" "d") "TEST3")
nil
user=> (.hashCode (deserialize! "TEST3.ser"))
0

Can you not use vectors instead if lists? Vectors seem to behave...


(defn serialize!
"Serialize the object b on to the disk using Java serialization.
 Filename needs no extension - it will be appended (.ser)."
[b fname]
(with-open [oout (java.io.ObjectOutputStream.
                 (java.io.FileOutputStream. (str fname ".ser")))]
                 (.writeObject oout b)))

(defn deserialize!
"Deserializes the object in file f from the disk using Java serialization."
[fname]
(let [upb (promise)] ;waiting for the value shortly
  (with-open [oin (java.io.ObjectInputStream.
                  (java.io.FileInputStream. fname))]
                  (deliver upb (.readObject oin)))
       @upb))

Jim



On 10/10/12 14:55, N8Dawgrr wrote:
I don't think that's a realistic option for me. I have java objects embedded in the Clojure forms, and the graph is pretty big.

On Wednesday, October 10, 2012 2:02:45 PM UTC+1, Stuart Sierra wrote:

    I would recommend serializing as strings via pr/read over Java
    serialization, but this still sounds like a legitimate bug.
    -S

--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your first post.
To unsubscribe from this group, send email to
[email protected]
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 post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to