> Well, under the covers the str function applies the java "toString" > method to any passed in object and hence the result could for some > reason be different to the original String object passed in. I think > this could occur if the object subclasses String, but has a different > representation (i.e a different toString method). You can't subclass a String in Java because String is a final class. This is enforced by JVM (not just compiler). I don't know java dynamic proxy well, but would be surprised if it allowed a proxy for a String as it would circumvent JVM's security mechanisms that rely on immutable strings...
Boris > > Are you able to post what s contains when this happens? > You could try printing s in your calling function and then also in the > defmethod, e.g; > > (defmethod t-str String [s] (prn "cls:" (class s) "s:" s "chars:" (vec s)))) > > Maybe that'll shed some light? > > > On Wed, May 13, 2009 at 4:59 AM, tsuraan <tsur...@gmail.com> wrote: >> >>> Maybe there's something about the particular [ s ] object that you're >>> passing in? >> >> I believe that you're right; in general, the getBytes seems to work. >> It is just in this one freakish case that it doesn't, but I have no >> idea how to tell what's special about my string. I'm not exactly >> proficient in Java, and I'm a complete clojure newbie, so I really >> have no idea how to proceed with debugging this. >> >> Under what circumstances would (str s) give something different from >> s, when (.getClass s) gives java.lang.String? >> >> Also, sorry for the horrible subject line; that was my initial guess, >> and I had a big email written up about it, but then I started testing >> my assumptions and they were all garbage. I rewrote the email, but >> forgot about the subject... >> >> > >> > > > > --~--~---------~--~----~------------~-------~--~----~ 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 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 -~----------~----~----~----~------~----~------~--~---