Interop with strange java type: java.lang.String
I'm having to do some interop with a proprietary - and erroneously documented - Java SDK. There's a class C with a method described as 'translate(java.lang.String). Trying to call the method with a Clojure on an object of class C I got a 'no matching method found' error. So I used the following snippet from stack overflow to print out the entire collection of methods on the object (useful enough to repeat here): (ns ... (:require [clojure.reflect :as r] [clojure.pprint :refer [print-table])) (print-table (sort-by :name (filter :exception-types (:members (r/reflect (type my-object)) What I discovered was that the translate method had a signature reported as 'translate(java.lang.String)', not a mere quirk of the reflection process - there were plenty of other methods taking the usual java.lang.String method as well. Does anyone know how how to create a java.lang.String ? Ideally how to convert a Clojure some string which is a java.lang.String to a java.lang.String. Also, although this is merely idle curiosity on my part, does anyone know what a java.lang.String actually is? The suggests a generic, but java.lang.String is not a container - although the is empty of course. -- 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/d/optout.
Re: Interop with strange java type: java.lang.String
I suspect this is it. Also, remember that internally a varargs string method will take an Array of String as its last arg. On Thursday, August 20, 2015 at 9:35:19 AM UTC-7, squeegee wrote: On Aug 20, 2015, at 3:32 AM, Andy Dwelly andyd...@gmail.com javascript: wrote: Does anyone know how how to create a java.lang.String ? Ideally how to convert a Clojure some string which is a java.lang.String to a java.lang.String. Also, although this is merely idle curiosity on my part, does anyone know what a java.lang.String actually is? The suggests a generic, but java.lang.String is not a container - although the is empty of course. I don’t have a complete answer, but maybe these references will help: I recall seeing a in this post: http://tech.puredanger.com/2011/08/12/subclassing-in-clojure/ and I see it mentioned here: http://dishevelled.net/Tricky-uses-of-Clojure-gen-class-and-AOT-compilation.html Maybe that argument is an array of Object where the objects are Strings. In other contexts I have seen the class name for an array of Strings displayed as “class [Ljava.lang.String”, but perhaps it’s printed differently by this reflection API. —Steve -- 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/d/optout.
Re: Interop with strange java type: java.lang.String
On Aug 20, 2015, at 3:32 AM, Andy Dwelly andydwe...@gmail.com wrote: Does anyone know how how to create a java.lang.String ? Ideally how to convert a Clojure some string which is a java.lang.String to a java.lang.String. Also, although this is merely idle curiosity on my part, does anyone know what a java.lang.String actually is? The suggests a generic, but java.lang.String is not a container - although the is empty of course. I don’t have a complete answer, but maybe these references will help: I recall seeing a in this post: http://tech.puredanger.com/2011/08/12/subclassing-in-clojure/ http://tech.puredanger.com/2011/08/12/subclassing-in-clojure/ and I see it mentioned here: http://dishevelled.net/Tricky-uses-of-Clojure-gen-class-and-AOT-compilation.html http://dishevelled.net/Tricky-uses-of-Clojure-gen-class-and-AOT-compilation.html Maybe that argument is an array of Object where the objects are Strings. In other contexts I have seen the class name for an array of Strings displayed as “class [Ljava.lang.String”, but perhaps it’s printed differently by this reflection API. —Steve -- 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/d/optout.