That's surprising, but good to know. Thanks. On Tue, Jul 31, 2018 at 9:56 AM, Renzo Borgatti <rebor...@gmail.com> wrote:
> Hey Mark, it's lein-virgil interfering. As of why, better opening an issue > there. > > Renzo > > > On 30 Jul 2018, at 11:50, Mark Engelberg <mark.engelb...@gmail.com> > wrote: > > > > OK, I just pushed the repo (work in progress) to github. > https://github.com/Engelberg/mister-rogers > > At the bottom of mister-rogers.wrappers I tacked on the three lines > we've been discussing. > > https://github.com/Engelberg/mister-rogers/blob/ > 523fc29f8827193fa9ea6ae2e82649e2933e6ae3/src/clj/mister_ > rogers/wrappers.clj#L80 > > > > > > Here's a REPL interaction: > > > > C:\devel\Clojure\mister-rogers>lein repl > > > > recompiling all files in ["C:\\devel\\Clojure\\mister- > rogers\\src\\java"] > > :reloading (mister-rogers.core mister-rogers.protocols > mister-rogers.problem mister-rogers.wrappers mister-rogers.core-test) > > > > recompiling all files in ["C:\\devel\\Clojure\\mister- > rogers\\src\\java"] > > :reloading (mister-rogers.core mister-rogers.protocols > mister-rogers.problem mister-rogers.wrappers mister-rogers.core-test) > > nREPL server started on port 49492 on host 127.0.0.1 - nrepl:// > 127.0.0.1:49492 > > REPL-y 0.3.7, nREPL 0.2.12 > > Clojure 1.9.0 > > Java HotSpot(TM) 64-Bit Server VM 1.8.0_66-b18 > > Docs: (doc function-name-here) > > (find-doc "part-of-name-here") > > Source: (source function-name-here) > > Javadoc: (javadoc java-object-or-class-here) > > Exit: Control+D or (exit) or (quit) > > Results: Stored in vars *1, *2, *3, an exception in *e > > > > user=> (in-ns 'mister-rogers.wrappers) > > #namespace[mister-rogers.wrappers] > > mister-rogers.wrappers=> (get-test p) > > > > ClassCastException mister_rogers.wrappers.proxy$ > java.lang.Object$Interface$7e434bc9 cannot be cast to > mister_rogers.wrappers.Interface mister-rogers.wrappers/get-test > (wrappers.clj:82) > > > > > > Thanks for looking at this. > > > > > > On Mon, Jul 30, 2018 at 3:43 AM, Nicola Mometto <brobro...@gmail.com> > wrote: > > Can you paste an entire repl session, starting from how you launch it > (e.g. lein repl vs clj -- ideally not from a project) reproducing this? > > I'm interested in taking a look but I simply cannot repro :/ > > > >> On 30 Jul 2018, at 11:40, Mark Engelberg <mark.engelb...@gmail.com> > wrote: > >> > >> Yes, it is in a fresh environment. > >> > >> I find that the problematic example does work in the user namespace, > but it doesn't work in my segmented namespace (ns mister-rogers.wrappers, > to be really specific). > >> > >> On Mon, Jul 30, 2018 at 3:34 AM, Nicola Mometto <brobro...@gmail.com> > wrote: > >> No, I just tested this on 1.9.0 and 1.8.0 and I get no reflection, as > I'd expect. > >> > >> Are you testing this in a fresh environment? > >> > >> > >>> On 30 Jul 2018, at 11:31, Mark Engelberg <mark.engelb...@gmail.com> > wrote: > >>> > >>> I'm using 1.9.0. Is this a behavior that recently changed? > >>> > >>> On Mon, Jul 30, 2018 at 3:28 AM, Nicola Mometto <brobro...@gmail.com> > wrote: > >>> Which version of clojure? This works fine in 1.10 > >>> > >>> Clojure 1.10.0-master-SNAPSHOT > >>> user=> (set! *warn-on-reflection* true) > >>> true > >>> user=> (definterface Interface (test [])) > >>> user.Interface > >>> user=> (def p (proxy [Object Interface] [] (test [] 1))) > >>> #'user/p > >>> user=> (defn get-test [o] (.test ^Interface o)) > >>> #'user/get-test > >>> user=> (get-test p) > >>> 1 > >>> > >>> > >>>> On 30 Jul 2018, at 11:26, Mark Engelberg <mark.engelb...@gmail.com> > wrote: > >>>> > >>>> Those fishy things were errors I made when simplifying and > transcribing the proxy to post, but I have it correct in my own code. > >>>> > >>>> Here's a more precise, tested minimal example: > >>>> > >>>> (definterface Interface (test [])) > >>>> (def p (proxy [Object Interface] [] (test [] 1))) > >>>> (defn get-test [o] (.test ^Interface o)) > >>>> > >>>> => (get-test p) > >>>> This throws an error that it can't cast the proxy to Interface. > >>>> > >>>> If you remove the ^Interface type hint, then get-test will work but > will trigger reflection. > >>>> > >>>> Thanks for looking at this. It seems like it should work, but it > doesn't. > >>>> > >>>> > >>>> On Mon, Jul 30, 2018 at 3:06 AM, Nicola Mometto <brobro...@gmail.com> > wrote: > >>>> That's exactly what you should do and it does work, e.g.: > >>>> > >>>> user=> (set! *warn-on-reflection* true) > >>>> true > >>>> user=> (.meta ^clojure.lang.IMeta (proxy [clojure.lang.IMeta] [] > (meta [] {:a 1}))) > >>>> {:a 1} > >>>> > >>>> In your small example you have two errors that might be fishy: a > missing arg vector to pass to the super ctor and an extra `this` parameter > in the method impl (proxy, unlike reify, is anaphoric and binds `this` for > you) > >>>> > >>>> > >>>>> On 30 Jul 2018, at 10:56, Mark Engelberg <mark.engelb...@gmail.com> > wrote: > >>>>> > >>>>> Let's say I have a proxy object: > >>>>> > >>>>> (def p (proxy [MyClass MyInterface] (interfaceMethod [this] ...))) > >>>>> > >>>>> Now, I want to call (.interfaceMethod p). How do I do this without > reflection? > >>>>> I would have thought that (.interfaceMethod ^MyInterface p) would > work, but this results in an error message that this proxy object cannot be > cast to MyInterface. > >>>>> > >>>>> > >>>>> > >>>>> -- > >>>>> 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. > >>>> > >>>> > >>>> -- > >>>> 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. > >>>> > >>>> > >>>> -- > >>>> 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. > >>> > >>> > >>> -- > >>> 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. > >>> > >>> > >>> -- > >>> 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. > >> > >> > >> -- > >> 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. > >> > >> > >> -- > >> 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. > > > > > > -- > > 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. > > > > > > -- > > 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. > > -- > 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. > -- 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.