Re: Java interop: Can't call public method of non-public class
Hey Sean, Your attempt worked because in Netty 4.0.0.Alpha8 AbstractBootstraphttps://github.com/netty/netty/commit/23438de66f82c72720b092c539bb430995722d2d#transport/src/main/java/io/netty/bootstrap/AbstractBootstrap.java was still public.. Try it out with 4.0.0.Beta2.. Thanks! On Wednesday, March 13, 2013 4:15:51 AM UTC+2, Sean Corfield wrote: On Tue, Mar 12, 2013 at 5:46 PM, shlomi...@gmail.com javascript: wrote: In my case i am trying to get clojure working with netty 4, here is the code: (def #^AbstractBootstrap b (ServerBootstrap.)) (.channel ^AbstractBootstrap b ^Class io.netty.channel.socket.nio.NioServerSocketChannel) which returns the error: java.lang.IllegalArgumentException: Can't call public method of non-public class: public io.netty.bootstrap.AbstractBootstrap io.netty.bootstrap.AbstractBootstrap.channel(java.lang.Class) at clojure.lang.Reflector.invokeMatchingMethod (Reflector.java:88) I can't reproduce this (with Clojure 1.5.1, Netty 4.0.0.Alpha8): user= (set! *warn-on-reflection* true) true user= (import '(io.netty.bootstrap AbstractBootstrap ServerBootstrap)) io.netty.bootstrap.ServerBootstrap user= (def b (ServerBootstrap.)) #'user/b user= (.channel ^AbstractBootstrap b ^Class io.netty.channel.socket.nio.NioServerSocketChannel) #ServerBootstrap ServerBootstrap(factory: NioServerSocketChannel.class) user= *clojure-version* {:major 1, :minor 5, :incremental 1, :qualifier nil} user= Can you provide more detail? -- Sean A Corfield -- (904) 302-SEAN An Architect's View -- http://corfield.org/ World Singles, LLC. -- http://worldsingles.com/ Perfection is the enemy of the good. -- Gustave Flaubert, French realist novelist (1821-1880) -- -- 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/groups/opt_out.
Re: Java interop: Can't call public method of non-public class
When you annotate, is it a runtime or a compile-time error? I would be very surprised if it happened at runtime (when the function is actuall called). On Wednesday, March 13, 2013 1:26:00 AM UTC+1, Shlomi Vaknin wrote: hey, I have a similar problem, even when i type annotate with clojure 1.5 i still get that error.. any suggestions? -- -- 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/groups/opt_out.
Re: Java interop: Can't call public method of non-public class
yes you are right, it is a compile-time error.. On Wednesday, March 13, 2013 11:19:25 AM UTC+2, Marko Topolnik wrote: When you annotate, is it a runtime or a compile-time error? I would be very surprised if it happened at runtime (when the function is actuall called). On Wednesday, March 13, 2013 1:26:00 AM UTC+1, Shlomi Vaknin wrote: hey, I have a similar problem, even when i type annotate with clojure 1.5 i still get that error.. any suggestions? -- -- 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/groups/opt_out.
Re: Java interop: Can't call public method of non-public class
here is the full exception when compiling: Exception in thread main java.lang.IllegalArgumentException: Can't call public method of non-public class: public io.netty.bootstrap.AbstractBootstrap io.netty.bootstrap.AbstractBootstrap.channel(java.lang.Class), compiling:(netty.clj:31:1) at clojure.lang.Compiler$InstanceMethodExpr.eval(Compiler.java:1453) at clojure.lang.Compiler.compile1(Compiler.java:7153) at clojure.lang.Compiler.compile(Compiler.java:7219) at clojure.lang.RT.compile(RT.java:398) at clojure.lang.RT.load(RT.java:438) at clojure.lang.RT.load(RT.java:411) at clojure.core$load$fn__5018.invoke(core.clj:5530) at clojure.core$load.doInvoke(core.clj:5529) at clojure.lang.RestFn.invoke(RestFn.java:408) at clojure.core$load_one.invoke(core.clj:5336) at clojure.core$compile$fn__5023.invoke(core.clj:5541) at clojure.core$compile.invoke(core.clj:5540) at user$eval7.invoke(NO_SOURCE_FILE:1) at clojure.lang.Compiler.eval(Compiler.java:6619) at clojure.lang.Compiler.eval(Compiler.java:6609) at clojure.lang.Compiler.eval(Compiler.java:6582) at clojure.core$eval.invoke(core.clj:2852) at clojure.main$eval_opt.invoke(main.clj:308) at clojure.main$initialize.invoke(main.clj:327) at clojure.main$null_opt.invoke(main.clj:362) at clojure.main$main.doInvoke(main.clj:440) at clojure.lang.RestFn.invoke(RestFn.java:421) at clojure.lang.Var.invoke(Var.java:419) at clojure.lang.AFn.applyToHelper(AFn.java:163) at clojure.lang.Var.applyTo(Var.java:532) at clojure.main.main(main.java:37) Caused by: java.lang.IllegalArgumentException: Can't call public method of non-public class: public io.netty.bootstrap.AbstractBootstrap io.netty.bootstrap.AbstractBootstrap.channel(java.lang.Class) On Wednesday, March 13, 2013 11:21:40 AM UTC+2, shlomi...@gmail.com wrote: yes you are right, it is a compile-time error.. On Wednesday, March 13, 2013 11:19:25 AM UTC+2, Marko Topolnik wrote: When you annotate, is it a runtime or a compile-time error? I would be very surprised if it happened at runtime (when the function is actuall called). On Wednesday, March 13, 2013 1:26:00 AM UTC+1, Shlomi Vaknin wrote: hey, I have a similar problem, even when i type annotate with clojure 1.5 i still get that error.. any suggestions? -- -- 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/groups/opt_out.
Re: Java interop: Can't call public method of non-public class
It is almost certain that the method you want to call is inherited from a public ancestor. Annotate the call with that ancestor and it will work. On Wednesday, March 13, 2013 10:23:31 AM UTC+1, shlomi...@gmail.com wrote: here is the full exception when compiling: Exception in thread main java.lang.IllegalArgumentException: Can't call public method of non-public class: public io.netty.bootstrap.AbstractBootstrap io.netty.bootstrap.AbstractBootstrap.channel(java.lang.Class), compiling:(netty.clj:31:1) at clojure.lang.Compiler$InstanceMethodExpr.eval(Compiler.java:1453) at clojure.lang.Compiler.compile1(Compiler.java:7153) at clojure.lang.Compiler.compile(Compiler.java:7219) Caused by: java.lang.IllegalArgumentException: Can't call public method of non-public class: public io.netty.bootstrap.AbstractBootstrap io.netty.bootstrap.AbstractBootstrap.channel(java.lang.Class) On Wednesday, March 13, 2013 11:21:40 AM UTC+2, shlomi...@gmail.com wrote: yes you are right, it is a compile-time error.. On Wednesday, March 13, 2013 11:19:25 AM UTC+2, Marko Topolnik wrote: When you annotate, is it a runtime or a compile-time error? I would be very surprised if it happened at runtime (when the function is actuall called). On Wednesday, March 13, 2013 1:26:00 AM UTC+1, Shlomi Vaknin wrote: hey, I have a similar problem, even when i type annotate with clojure 1.5 i still get that error.. any suggestions? -- -- 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/groups/opt_out.
Re: Java interop: Can't call public method of non-public class
hey we dont need to be almost certain, we can just look at the code : https://github.com/netty/netty/blob/master/transport/src/main/java/io/netty/bootstrap/AbstractBootstrap.java and see that it is not a public ancestor. more then that, i annotated the code and it didnt work. here is a repl dump, same as Sean did: ; nREPL 0.1.6-preview user (set! *warn-on-reflection* true) true user (import '(io.netty.bootstrap AbstractBootstrap ServerBootstrap)) io.netty.bootstrap.ServerBootstrap user (def b (ServerBootstrap.)) #'user/b user (.channel ^AbstractBootstrap b ^Class io.netty.channel.socket.nio.NioServerSocketChannel) Reflection warning, NO_SOURCE_PATH:1:1 - call to channel can't be resolved. IllegalArgumentException Can't call public method of non-public class: public io.netty.bootstrap.AbstractBootstrap io.netty.bootstrap.AbstractBootstrap.channel(java.lang.Class) clojure.lang.Reflector.invokeMatchingMethod (Reflector.java:88) user *clojure-version* {:major 1, :minor 5, :incremental 1, :qualifier nil} On Wednesday, March 13, 2013 11:34:33 AM UTC+2, Marko Topolnik wrote: It is almost certain that the method you want to call is inherited from a public ancestor. Annotate the call with that ancestor and it will work. On Wednesday, March 13, 2013 10:23:31 AM UTC+1, shlomi...@gmail.com wrote: here is the full exception when compiling: Exception in thread main java.lang.IllegalArgumentException: Can't call public method of non-public class: public io.netty.bootstrap.AbstractBootstrap io.netty.bootstrap.AbstractBootstrap.channel(java.lang.Class), compiling:(netty.clj:31:1) at clojure.lang.Compiler$InstanceMethodExpr.eval(Compiler.java:1453) at clojure.lang.Compiler.compile1(Compiler.java:7153) at clojure.lang.Compiler.compile(Compiler.java:7219) Caused by: java.lang.IllegalArgumentException: Can't call public method of non-public class: public io.netty.bootstrap.AbstractBootstrap io.netty.bootstrap.AbstractBootstrap.channel(java.lang.Class) On Wednesday, March 13, 2013 11:21:40 AM UTC+2, shlomi...@gmail.comwrote: yes you are right, it is a compile-time error.. On Wednesday, March 13, 2013 11:19:25 AM UTC+2, Marko Topolnik wrote: When you annotate, is it a runtime or a compile-time error? I would be very surprised if it happened at runtime (when the function is actuall called). On Wednesday, March 13, 2013 1:26:00 AM UTC+1, Shlomi Vaknin wrote: hey, I have a similar problem, even when i type annotate with clojure 1.5 i still get that error.. any suggestions? -- -- 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/groups/opt_out.
Re: Java interop: Can't call public method of non-public class
It does have a public descendant, though. It is not acceptable for you to annotate with ServerBootstrap? It really is bad practice to annotate with non-public classes. On Wednesday, March 13, 2013 10:43:35 AM UTC+1, shlomi...@gmail.com wrote: hey we dont need to be almost certain, we can just look at the code : https://github.com/netty/netty/blob/master/transport/src/main/java/io/netty/bootstrap/AbstractBootstrap.java and see that it is not a public ancestor. more then that, i annotated the code and it didnt work. here is a repl dump, same as Sean did: ; nREPL 0.1.6-preview user (set! *warn-on-reflection* true) true user (import '(io.netty.bootstrap AbstractBootstrap ServerBootstrap)) io.netty.bootstrap.ServerBootstrap user (def b (ServerBootstrap.)) #'user/b user (.channel ^AbstractBootstrap b ^Class io.netty.channel.socket.nio.NioServerSocketChannel) Reflection warning, NO_SOURCE_PATH:1:1 - call to channel can't be resolved. IllegalArgumentException Can't call public method of non-public class: public io.netty.bootstrap.AbstractBootstrap io.netty.bootstrap.AbstractBootstrap.channel(java.lang.Class) clojure.lang.Reflector.invokeMatchingMethod (Reflector.java:88) user *clojure-version* {:major 1, :minor 5, :incremental 1, :qualifier nil} On Wednesday, March 13, 2013 11:34:33 AM UTC+2, Marko Topolnik wrote: It is almost certain that the method you want to call is inherited from a public ancestor. Annotate the call with that ancestor and it will work. On Wednesday, March 13, 2013 10:23:31 AM UTC+1, shlomi...@gmail.comwrote: here is the full exception when compiling: Exception in thread main java.lang.IllegalArgumentException: Can't call public method of non-public class: public io.netty.bootstrap.AbstractBootstrap io.netty.bootstrap.AbstractBootstrap.channel(java.lang.Class), compiling:(netty.clj:31:1) at clojure.lang.Compiler$InstanceMethodExpr.eval(Compiler.java:1453) at clojure.lang.Compiler.compile1(Compiler.java:7153) at clojure.lang.Compiler.compile(Compiler.java:7219) Caused by: java.lang.IllegalArgumentException: Can't call public method of non-public class: public io.netty.bootstrap.AbstractBootstrap io.netty.bootstrap.AbstractBootstrap.channel(java.lang.Class) On Wednesday, March 13, 2013 11:21:40 AM UTC+2, shlomi...@gmail.comwrote: yes you are right, it is a compile-time error.. On Wednesday, March 13, 2013 11:19:25 AM UTC+2, Marko Topolnik wrote: When you annotate, is it a runtime or a compile-time error? I would be very surprised if it happened at runtime (when the function is actuall called). On Wednesday, March 13, 2013 1:26:00 AM UTC+1, Shlomi Vaknin wrote: hey, I have a similar problem, even when i type annotate with clojure 1.5 i still get that error.. any suggestions? -- -- 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/groups/opt_out.
Re: Java interop: Can't call public method of non-public class
I fully agree with you, only it doesnt work.. ServerBootstrap does not override that specific method, which is what causing this pain, so i dont know what other options i have. here is my attempt: user (.channel ^ServerBootstrap b ^Class io.netty.channel.socket.nio.NioServerSocketChannel) Reflection warning, NO_SOURCE_PATH:1:1 - call to channel can't be resolved. IllegalArgumentException Can't call public method of non-public class: public io.netty.bootstrap.AbstractBootstrap io.netty.bootstrap.AbstractBootstrap.channel(java.lang.Class) clojure.lang.Reflector.invokeMatchingMethod (Reflector.java:88) On Wednesday, March 13, 2013 11:58:06 AM UTC+2, Marko Topolnik wrote: It does have a public descendant, though. It is not acceptable for you to annotate with ServerBootstrap? It really is bad practice to annotate with non-public classes. On Wednesday, March 13, 2013 10:43:35 AM UTC+1, shlomi...@gmail.com wrote: hey we dont need to be almost certain, we can just look at the code : https://github.com/netty/netty/blob/master/transport/src/main/java/io/netty/bootstrap/AbstractBootstrap.java and see that it is not a public ancestor. more then that, i annotated the code and it didnt work. here is a repl dump, same as Sean did: ; nREPL 0.1.6-preview user (set! *warn-on-reflection* true) true user (import '(io.netty.bootstrap AbstractBootstrap ServerBootstrap)) io.netty.bootstrap.ServerBootstrap user (def b (ServerBootstrap.)) #'user/b user (.channel ^AbstractBootstrap b ^Class io.netty.channel.socket.nio.NioServerSocketChannel) Reflection warning, NO_SOURCE_PATH:1:1 - call to channel can't be resolved. IllegalArgumentException Can't call public method of non-public class: public io.netty.bootstrap.AbstractBootstrap io.netty.bootstrap.AbstractBootstrap.channel(java.lang.Class) clojure.lang.Reflector.invokeMatchingMethod (Reflector.java:88) user *clojure-version* {:major 1, :minor 5, :incremental 1, :qualifier nil} On Wednesday, March 13, 2013 11:34:33 AM UTC+2, Marko Topolnik wrote: It is almost certain that the method you want to call is inherited from a public ancestor. Annotate the call with that ancestor and it will work. On Wednesday, March 13, 2013 10:23:31 AM UTC+1, shlomi...@gmail.comwrote: here is the full exception when compiling: Exception in thread main java.lang.IllegalArgumentException: Can't call public method of non-public class: public io.netty.bootstrap.AbstractBootstrap io.netty.bootstrap.AbstractBootstrap.channel(java.lang.Class), compiling:(netty.clj:31:1) at clojure.lang.Compiler$InstanceMethodExpr.eval(Compiler.java:1453) at clojure.lang.Compiler.compile1(Compiler.java:7153) at clojure.lang.Compiler.compile(Compiler.java:7219) Caused by: java.lang.IllegalArgumentException: Can't call public method of non-public class: public io.netty.bootstrap.AbstractBootstrap io.netty.bootstrap.AbstractBootstrap.channel(java.lang.Class) On Wednesday, March 13, 2013 11:21:40 AM UTC+2, shlomi...@gmail.comwrote: yes you are right, it is a compile-time error.. On Wednesday, March 13, 2013 11:19:25 AM UTC+2, Marko Topolnik wrote: When you annotate, is it a runtime or a compile-time error? I would be very surprised if it happened at runtime (when the function is actuall called). On Wednesday, March 13, 2013 1:26:00 AM UTC+1, Shlomi Vaknin wrote: hey, I have a similar problem, even when i type annotate with clojure 1.5 i still get that error.. any suggestions? -- -- 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/groups/opt_out.
Re: Java interop: Can't call public method of non-public class
I see, that's very unfortunate then. It fails even when it is not actually making the reflective call. Your last recourse is writing your own code against the Java Reflection API, using *setAccesible(true)* if necessary. On Wednesday, March 13, 2013 11:03:50 AM UTC+1, shlomi...@gmail.com wrote: I fully agree with you, only it doesnt work.. ServerBootstrap does not override that specific method, which is what causing this pain, so i dont know what other options i have. here is my attempt: user (.channel ^ServerBootstrap b ^Class io.netty.channel.socket.nio.NioServerSocketChannel) Reflection warning, NO_SOURCE_PATH:1:1 - call to channel can't be resolved. IllegalArgumentException Can't call public method of non-public class: public io.netty.bootstrap.AbstractBootstrap io.netty.bootstrap.AbstractBootstrap.channel(java.lang.Class) clojure.lang.Reflector.invokeMatchingMethod (Reflector.java:88) On Wednesday, March 13, 2013 11:58:06 AM UTC+2, Marko Topolnik wrote: It does have a public descendant, though. It is not acceptable for you to annotate with ServerBootstrap? It really is bad practice to annotate with non-public classes. On Wednesday, March 13, 2013 10:43:35 AM UTC+1, shlomi...@gmail.comwrote: hey we dont need to be almost certain, we can just look at the code : https://github.com/netty/netty/blob/master/transport/src/main/java/io/netty/bootstrap/AbstractBootstrap.java and see that it is not a public ancestor. more then that, i annotated the code and it didnt work. here is a repl dump, same as Sean did: ; nREPL 0.1.6-preview user (set! *warn-on-reflection* true) true user (import '(io.netty.bootstrap AbstractBootstrap ServerBootstrap)) io.netty.bootstrap.ServerBootstrap user (def b (ServerBootstrap.)) #'user/b user (.channel ^AbstractBootstrap b ^Class io.netty.channel.socket.nio.NioServerSocketChannel) Reflection warning, NO_SOURCE_PATH:1:1 - call to channel can't be resolved. IllegalArgumentException Can't call public method of non-public class: public io.netty.bootstrap.AbstractBootstrap io.netty.bootstrap.AbstractBootstrap.channel(java.lang.Class) clojure.lang.Reflector.invokeMatchingMethod (Reflector.java:88) user *clojure-version* {:major 1, :minor 5, :incremental 1, :qualifier nil} On Wednesday, March 13, 2013 11:34:33 AM UTC+2, Marko Topolnik wrote: It is almost certain that the method you want to call is inherited from a public ancestor. Annotate the call with that ancestor and it will work. On Wednesday, March 13, 2013 10:23:31 AM UTC+1, shlomi...@gmail.comwrote: here is the full exception when compiling: Exception in thread main java.lang.IllegalArgumentException: Can't call public method of non-public class: public io.netty.bootstrap.AbstractBootstrap io.netty.bootstrap.AbstractBootstrap.channel(java.lang.Class), compiling:(netty.clj:31:1) at clojure.lang.Compiler$InstanceMethodExpr.eval(Compiler.java:1453) at clojure.lang.Compiler.compile1(Compiler.java:7153) at clojure.lang.Compiler.compile(Compiler.java:7219) Caused by: java.lang.IllegalArgumentException: Can't call public method of non-public class: public io.netty.bootstrap.AbstractBootstrap io.netty.bootstrap.AbstractBootstrap.channel(java.lang.Class) On Wednesday, March 13, 2013 11:21:40 AM UTC+2, shlomi...@gmail.comwrote: yes you are right, it is a compile-time error.. On Wednesday, March 13, 2013 11:19:25 AM UTC+2, Marko Topolnik wrote: When you annotate, is it a runtime or a compile-time error? I would be very surprised if it happened at runtime (when the function is actuall called). On Wednesday, March 13, 2013 1:26:00 AM UTC+1, Shlomi Vaknin wrote: hey, I have a similar problem, even when i type annotate with clojure 1.5 i still get that error.. any suggestions? -- -- 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/groups/opt_out.
Re: Java interop: Can't call public method of non-public class
hmmm, that what i was afraid of :) ill take my chances harassing the netty people now before i go down that path.. On Wednesday, March 13, 2013 12:09:44 PM UTC+2, Marko Topolnik wrote: I see, that's very unfortunate then. It fails even when it is not actually making the reflective call. Your last recourse is writing your own code against the Java Reflection API, using *setAccesible(true)* if necessary. On Wednesday, March 13, 2013 11:03:50 AM UTC+1, shlomi...@gmail.com wrote: I fully agree with you, only it doesnt work.. ServerBootstrap does not override that specific method, which is what causing this pain, so i dont know what other options i have. here is my attempt: user (.channel ^ServerBootstrap b ^Class io.netty.channel.socket.nio.NioServerSocketChannel) Reflection warning, NO_SOURCE_PATH:1:1 - call to channel can't be resolved. IllegalArgumentException Can't call public method of non-public class: public io.netty.bootstrap.AbstractBootstrap io.netty.bootstrap.AbstractBootstrap.channel(java.lang.Class) clojure.lang.Reflector.invokeMatchingMethod (Reflector.java:88) On Wednesday, March 13, 2013 11:58:06 AM UTC+2, Marko Topolnik wrote: It does have a public descendant, though. It is not acceptable for you to annotate with ServerBootstrap? It really is bad practice to annotate with non-public classes. On Wednesday, March 13, 2013 10:43:35 AM UTC+1, shlomi...@gmail.comwrote: hey we dont need to be almost certain, we can just look at the code : https://github.com/netty/netty/blob/master/transport/src/main/java/io/netty/bootstrap/AbstractBootstrap.java and see that it is not a public ancestor. more then that, i annotated the code and it didnt work. here is a repl dump, same as Sean did: ; nREPL 0.1.6-preview user (set! *warn-on-reflection* true) true user (import '(io.netty.bootstrap AbstractBootstrap ServerBootstrap)) io.netty.bootstrap.ServerBootstrap user (def b (ServerBootstrap.)) #'user/b user (.channel ^AbstractBootstrap b ^Class io.netty.channel.socket.nio.NioServerSocketChannel) Reflection warning, NO_SOURCE_PATH:1:1 - call to channel can't be resolved. IllegalArgumentException Can't call public method of non-public class: public io.netty.bootstrap.AbstractBootstrap io.netty.bootstrap.AbstractBootstrap.channel(java.lang.Class) clojure.lang.Reflector.invokeMatchingMethod (Reflector.java:88) user *clojure-version* {:major 1, :minor 5, :incremental 1, :qualifier nil} On Wednesday, March 13, 2013 11:34:33 AM UTC+2, Marko Topolnik wrote: It is almost certain that the method you want to call is inherited from a public ancestor. Annotate the call with that ancestor and it will work. On Wednesday, March 13, 2013 10:23:31 AM UTC+1, shlomi...@gmail.comwrote: here is the full exception when compiling: Exception in thread main java.lang.IllegalArgumentException: Can't call public method of non-public class: public io.netty.bootstrap.AbstractBootstrap io.netty.bootstrap.AbstractBootstrap.channel(java.lang.Class), compiling:(netty.clj:31:1) at clojure.lang.Compiler$InstanceMethodExpr.eval(Compiler.java:1453) at clojure.lang.Compiler.compile1(Compiler.java:7153) at clojure.lang.Compiler.compile(Compiler.java:7219) Caused by: java.lang.IllegalArgumentException: Can't call public method of non-public class: public io.netty.bootstrap.AbstractBootstrap io.netty.bootstrap.AbstractBootstrap.channel(java.lang.Class) On Wednesday, March 13, 2013 11:21:40 AM UTC+2, shlomi...@gmail.comwrote: yes you are right, it is a compile-time error.. On Wednesday, March 13, 2013 11:19:25 AM UTC+2, Marko Topolnik wrote: When you annotate, is it a runtime or a compile-time error? I would be very surprised if it happened at runtime (when the function is actuall called). On Wednesday, March 13, 2013 1:26:00 AM UTC+1, Shlomi Vaknin wrote: hey, I have a similar problem, even when i type annotate with clojure 1.5 i still get that error.. any suggestions? -- -- 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/groups/opt_out.
Re: Java interop: Can't call public method of non-public class
The netty people are not to blame; harass Rich instead :) On Wednesday, March 13, 2013 11:11:46 AM UTC+1, shlomi...@gmail.com wrote: hmmm, that what i was afraid of :) ill take my chances harassing the netty people now before i go down that path.. On Wednesday, March 13, 2013 12:09:44 PM UTC+2, Marko Topolnik wrote: I see, that's very unfortunate then. It fails even when it is not actually making the reflective call. Your last recourse is writing your own code against the Java Reflection API, using *setAccesible(true)* if necessary. On Wednesday, March 13, 2013 11:03:50 AM UTC+1, shlomi...@gmail.comwrote: I fully agree with you, only it doesnt work.. ServerBootstrap does not override that specific method, which is what causing this pain, so i dont know what other options i have. here is my attempt: user (.channel ^ServerBootstrap b ^Class io.netty.channel.socket.nio.NioServerSocketChannel) Reflection warning, NO_SOURCE_PATH:1:1 - call to channel can't be resolved. IllegalArgumentException Can't call public method of non-public class: public io.netty.bootstrap.AbstractBootstrap io.netty.bootstrap.AbstractBootstrap.channel(java.lang.Class) clojure.lang.Reflector.invokeMatchingMethod (Reflector.java:88) On Wednesday, March 13, 2013 11:58:06 AM UTC+2, Marko Topolnik wrote: It does have a public descendant, though. It is not acceptable for you to annotate with ServerBootstrap? It really is bad practice to annotate with non-public classes. On Wednesday, March 13, 2013 10:43:35 AM UTC+1, shlomi...@gmail.comwrote: hey we dont need to be almost certain, we can just look at the code : https://github.com/netty/netty/blob/master/transport/src/main/java/io/netty/bootstrap/AbstractBootstrap.java and see that it is not a public ancestor. more then that, i annotated the code and it didnt work. here is a repl dump, same as Sean did: ; nREPL 0.1.6-preview user (set! *warn-on-reflection* true) true user (import '(io.netty.bootstrap AbstractBootstrap ServerBootstrap)) io.netty.bootstrap.ServerBootstrap user (def b (ServerBootstrap.)) #'user/b user (.channel ^AbstractBootstrap b ^Class io.netty.channel.socket.nio.NioServerSocketChannel) Reflection warning, NO_SOURCE_PATH:1:1 - call to channel can't be resolved. IllegalArgumentException Can't call public method of non-public class: public io.netty.bootstrap.AbstractBootstrap io.netty.bootstrap.AbstractBootstrap.channel(java.lang.Class) clojure.lang.Reflector.invokeMatchingMethod (Reflector.java:88) user *clojure-version* {:major 1, :minor 5, :incremental 1, :qualifier nil} On Wednesday, March 13, 2013 11:34:33 AM UTC+2, Marko Topolnik wrote: It is almost certain that the method you want to call is inherited from a public ancestor. Annotate the call with that ancestor and it will work. On Wednesday, March 13, 2013 10:23:31 AM UTC+1, shlomi...@gmail.comwrote: here is the full exception when compiling: Exception in thread main java.lang.IllegalArgumentException: Can't call public method of non-public class: public io.netty.bootstrap.AbstractBootstrap io.netty.bootstrap.AbstractBootstrap.channel(java.lang.Class), compiling:(netty.clj:31:1) at clojure.lang.Compiler$InstanceMethodExpr.eval(Compiler.java:1453) at clojure.lang.Compiler.compile1(Compiler.java:7153) at clojure.lang.Compiler.compile(Compiler.java:7219) Caused by: java.lang.IllegalArgumentException: Can't call public method of non-public class: public io.netty.bootstrap.AbstractBootstrap io.netty.bootstrap.AbstractBootstrap.channel(java.lang.Class) On Wednesday, March 13, 2013 11:21:40 AM UTC+2, shlomi...@gmail.comwrote: yes you are right, it is a compile-time error.. On Wednesday, March 13, 2013 11:19:25 AM UTC+2, Marko Topolnik wrote: When you annotate, is it a runtime or a compile-time error? I would be very surprised if it happened at runtime (when the function is actuall called). On Wednesday, March 13, 2013 1:26:00 AM UTC+1, Shlomi Vaknin wrote: hey, I have a similar problem, even when i type annotate with clojure 1.5 i still get that error.. any suggestions? -- -- 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/groups/opt_out.
Re: Java interop: Can't call public method of non-public class
That is very true. is here the right place? is there a a different group/forum for the language developers? should i file a bug on github? On Wednesday, March 13, 2013 12:17:45 PM UTC+2, Marko Topolnik wrote: The netty people are not to blame; harass Rich instead :) On Wednesday, March 13, 2013 11:11:46 AM UTC+1, shlomi...@gmail.com wrote: hmmm, that what i was afraid of :) ill take my chances harassing the netty people now before i go down that path.. On Wednesday, March 13, 2013 12:09:44 PM UTC+2, Marko Topolnik wrote: I see, that's very unfortunate then. It fails even when it is not actually making the reflective call. Your last recourse is writing your own code against the Java Reflection API, using *setAccesible(true)* if necessary. On Wednesday, March 13, 2013 11:03:50 AM UTC+1, shlomi...@gmail.comwrote: I fully agree with you, only it doesnt work.. ServerBootstrap does not override that specific method, which is what causing this pain, so i dont know what other options i have. here is my attempt: user (.channel ^ServerBootstrap b ^Class io.netty.channel.socket.nio.NioServerSocketChannel) Reflection warning, NO_SOURCE_PATH:1:1 - call to channel can't be resolved. IllegalArgumentException Can't call public method of non-public class: public io.netty.bootstrap.AbstractBootstrap io.netty.bootstrap.AbstractBootstrap.channel(java.lang.Class) clojure.lang.Reflector.invokeMatchingMethod (Reflector.java:88) On Wednesday, March 13, 2013 11:58:06 AM UTC+2, Marko Topolnik wrote: It does have a public descendant, though. It is not acceptable for you to annotate with ServerBootstrap? It really is bad practice to annotate with non-public classes. On Wednesday, March 13, 2013 10:43:35 AM UTC+1, shlomi...@gmail.comwrote: hey we dont need to be almost certain, we can just look at the code : https://github.com/netty/netty/blob/master/transport/src/main/java/io/netty/bootstrap/AbstractBootstrap.java and see that it is not a public ancestor. more then that, i annotated the code and it didnt work. here is a repl dump, same as Sean did: ; nREPL 0.1.6-preview user (set! *warn-on-reflection* true) true user (import '(io.netty.bootstrap AbstractBootstrap ServerBootstrap)) io.netty.bootstrap.ServerBootstrap user (def b (ServerBootstrap.)) #'user/b user (.channel ^AbstractBootstrap b ^Class io.netty.channel.socket.nio.NioServerSocketChannel) Reflection warning, NO_SOURCE_PATH:1:1 - call to channel can't be resolved. IllegalArgumentException Can't call public method of non-public class: public io.netty.bootstrap.AbstractBootstrap io.netty.bootstrap.AbstractBootstrap.channel(java.lang.Class) clojure.lang.Reflector.invokeMatchingMethod (Reflector.java:88) user *clojure-version* {:major 1, :minor 5, :incremental 1, :qualifier nil} On Wednesday, March 13, 2013 11:34:33 AM UTC+2, Marko Topolnik wrote: It is almost certain that the method you want to call is inherited from a public ancestor. Annotate the call with that ancestor and it will work. On Wednesday, March 13, 2013 10:23:31 AM UTC+1, shlomi...@gmail.comwrote: here is the full exception when compiling: Exception in thread main java.lang.IllegalArgumentException: Can't call public method of non-public class: public io.netty.bootstrap.AbstractBootstrap io.netty.bootstrap.AbstractBootstrap.channel(java.lang.Class), compiling:(netty.clj:31:1) at clojure.lang.Compiler$InstanceMethodExpr.eval(Compiler.java:1453) at clojure.lang.Compiler.compile1(Compiler.java:7153) at clojure.lang.Compiler.compile(Compiler.java:7219) Caused by: java.lang.IllegalArgumentException: Can't call public method of non-public class: public io.netty.bootstrap.AbstractBootstrap io.netty.bootstrap.AbstractBootstrap.channel(java.lang.Class) On Wednesday, March 13, 2013 11:21:40 AM UTC+2, shlomi...@gmail.comwrote: yes you are right, it is a compile-time error.. On Wednesday, March 13, 2013 11:19:25 AM UTC+2, Marko Topolnik wrote: When you annotate, is it a runtime or a compile-time error? I would be very surprised if it happened at runtime (when the function is actuall called). On Wednesday, March 13, 2013 1:26:00 AM UTC+1, Shlomi Vaknin wrote: hey, I have a similar problem, even when i type annotate with clojure 1.5 i still get that error.. any suggestions? -- -- 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
Re: Java interop: Can't call public method of non-public class
You should first make a minimal example that reproduces this. I've just failed to do so with the following: abstract class AbstractParent { public void x() { System.out.println(x); } } public class ConcreteChild extends AbstractParent { } user (set! *warn-on-reflection* true) true user (.x (test.ConcreteChild.)) nil user (.x ^test.AbstractParent (test.ConcreteChild.)) nil user (def cc (test.ConcreteChild.)) #'user/cc user (.x cc) Reflection warning, NO_SOURCE_PATH:1:1 - reference to field x can't be resolved. nil user What must I add to break it? On Wednesday, March 13, 2013 11:23:17 AM UTC+1, shlomi...@gmail.com wrote: That is very true. is here the right place? is there a a different group/forum for the language developers? should i file a bug on github? On Wednesday, March 13, 2013 12:17:45 PM UTC+2, Marko Topolnik wrote: The netty people are not to blame; harass Rich instead :) On Wednesday, March 13, 2013 11:11:46 AM UTC+1, shlomi...@gmail.comwrote: hmmm, that what i was afraid of :) ill take my chances harassing the netty people now before i go down that path.. On Wednesday, March 13, 2013 12:09:44 PM UTC+2, Marko Topolnik wrote: I see, that's very unfortunate then. It fails even when it is not actually making the reflective call. Your last recourse is writing your own code against the Java Reflection API, using *setAccesible(true)* if necessary. On Wednesday, March 13, 2013 11:03:50 AM UTC+1, shlomi...@gmail.comwrote: I fully agree with you, only it doesnt work.. ServerBootstrap does not override that specific method, which is what causing this pain, so i dont know what other options i have. here is my attempt: user (.channel ^ServerBootstrap b ^Class io.netty.channel.socket.nio.NioServerSocketChannel) Reflection warning, NO_SOURCE_PATH:1:1 - call to channel can't be resolved. IllegalArgumentException Can't call public method of non-public class: public io.netty.bootstrap.AbstractBootstrap io.netty.bootstrap.AbstractBootstrap.channel(java.lang.Class) clojure.lang.Reflector.invokeMatchingMethod (Reflector.java:88) On Wednesday, March 13, 2013 11:58:06 AM UTC+2, Marko Topolnik wrote: It does have a public descendant, though. It is not acceptable for you to annotate with ServerBootstrap? It really is bad practice to annotate with non-public classes. On Wednesday, March 13, 2013 10:43:35 AM UTC+1, shlomi...@gmail.comwrote: hey we dont need to be almost certain, we can just look at the code : https://github.com/netty/netty/blob/master/transport/src/main/java/io/netty/bootstrap/AbstractBootstrap.java and see that it is not a public ancestor. more then that, i annotated the code and it didnt work. here is a repl dump, same as Sean did: ; nREPL 0.1.6-preview user (set! *warn-on-reflection* true) true user (import '(io.netty.bootstrap AbstractBootstrap ServerBootstrap)) io.netty.bootstrap.ServerBootstrap user (def b (ServerBootstrap.)) #'user/b user (.channel ^AbstractBootstrap b ^Class io.netty.channel.socket.nio.NioServerSocketChannel) Reflection warning, NO_SOURCE_PATH:1:1 - call to channel can't be resolved. IllegalArgumentException Can't call public method of non-public class: public io.netty.bootstrap.AbstractBootstrap io.netty.bootstrap.AbstractBootstrap.channel(java.lang.Class) clojure.lang.Reflector.invokeMatchingMethod (Reflector.java:88) user *clojure-version* {:major 1, :minor 5, :incremental 1, :qualifier nil} On Wednesday, March 13, 2013 11:34:33 AM UTC+2, Marko Topolnik wrote: It is almost certain that the method you want to call is inherited from a public ancestor. Annotate the call with that ancestor and it will work. On Wednesday, March 13, 2013 10:23:31 AM UTC+1, shlomi...@gmail.comwrote: here is the full exception when compiling: Exception in thread main java.lang.IllegalArgumentException: Can't call public method of non-public class: public io.netty.bootstrap.AbstractBootstrap io.netty.bootstrap.AbstractBootstrap.channel(java.lang.Class), compiling:(netty.clj:31:1) at clojure.lang.Compiler$InstanceMethodExpr.eval(Compiler.java:1453) at clojure.lang.Compiler.compile1(Compiler.java:7153) at clojure.lang.Compiler.compile(Compiler.java:7219) Caused by: java.lang.IllegalArgumentException: Can't call public method of non-public class: public io.netty.bootstrap.AbstractBootstrap io.netty.bootstrap.AbstractBootstrap.channel(java.lang.Class) On Wednesday, March 13, 2013 11:21:40 AM UTC+2, shlomi...@gmail.com wrote: yes you are right, it is a compile-time error.. On Wednesday, March 13, 2013 11:19:25 AM UTC+2, Marko Topolnik wrote: When you annotate, is it a runtime or a compile-time error? I would be very surprised if it happened at runtime (when the function is actuall called). On Wednesday, March 13, 2013 1:26:00 AM UTC+1, Shlomi Vaknin wrote: hey, I have a similar problem, even when i type annotate
Re: Java interop: Can't call public method of non-public class
I did it: the method must be final. Apparently without that the child is compiled with an overriding method that I didn't even define! On Wednesday, March 13, 2013 11:27:55 AM UTC+1, Marko Topolnik wrote: You should first make a minimal example that reproduces this. I've just failed to do so with the following: abstract class AbstractParent { public void x() { System.out.println(x); } } public class ConcreteChild extends AbstractParent { } user (set! *warn-on-reflection* true) true user (.x (test.ConcreteChild.)) nil user (.x ^test.AbstractParent (test.ConcreteChild.)) nil user (def cc (test.ConcreteChild.)) #'user/cc user (.x cc) Reflection warning, NO_SOURCE_PATH:1:1 - reference to field x can't be resolved. nil user What must I add to break it? -- -- 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/groups/opt_out.
Re: Java interop: Can't call public method of non-public class
Detailed finding: it *doesn't* fail at compile time; it always fails at runtime. Reason: at compile time there is a *reflection warning*, which means that the method wasn't found and a reflective call was emited by the compiler. On Wednesday, March 13, 2013 11:31:08 AM UTC+1, Marko Topolnik wrote: I did it: the method must be final. Apparently without that the child is compiled with an overriding method that I didn't even define! On Wednesday, March 13, 2013 11:27:55 AM UTC+1, Marko Topolnik wrote: You should first make a minimal example that reproduces this. I've just failed to do so with the following: abstract class AbstractParent { public void x() { System.out.println(x); } } public class ConcreteChild extends AbstractParent { } user (set! *warn-on-reflection* true) true user (.x (test.ConcreteChild.)) nil user (.x ^test.AbstractParent (test.ConcreteChild.)) nil user (def cc (test.ConcreteChild.)) #'user/cc user (.x cc) Reflection warning, NO_SOURCE_PATH:1:1 - reference to field x can't be resolved. nil user What must I add to break it? -- -- 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/groups/opt_out.
Re: Java interop: Can't call public method of non-public class
You didn't recompile everything, that's the reason. I got the same error the first time, that's how I realized that the child had overridden the method. This is an interesting finding in itself: javac provides the override precisely to avoid pitfalls such as this one. If the parent was public, this wouldn't have happened. Anyway, to make it really minimal, put all the java code into a single ConcreteChild.java. On Wednesday, March 13, 2013 11:36:05 AM UTC+1, Shlomi Vaknin wrote: are you getting the same error? i was getting clojure.lang.Compiler$CompilerException: java.lang.VerifyError: class Test overrides final method methodA.()I, compiling:(NO_SOURCE_PATH:2) what is your code? On Wed, Mar 13, 2013 at 12:31 PM, Marko Topolnik marko.t...@gmail.comjavascript: wrote: I did it: the method must be final. Apparently without that the child is compiled with an overriding method that I didn't even define! -- -- 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/groups/opt_out.
Re: Java interop: Can't call public method of non-public class
very interesting.. are you getting the same error as i originally got? On Wednesday, March 13, 2013 12:38:26 PM UTC+2, Marko Topolnik wrote: Detailed finding: it *doesn't* fail at compile time; it always fails at runtime. Reason: at compile time there is a *reflection warning*, which means that the method wasn't found and a reflective call was emited by the compiler. On Wednesday, March 13, 2013 11:31:08 AM UTC+1, Marko Topolnik wrote: I did it: the method must be final. Apparently without that the child is compiled with an overriding method that I didn't even define! On Wednesday, March 13, 2013 11:27:55 AM UTC+1, Marko Topolnik wrote: You should first make a minimal example that reproduces this. I've just failed to do so with the following: abstract class AbstractParent { public void x() { System.out.println(x); } } public class ConcreteChild extends AbstractParent { } user (set! *warn-on-reflection* true) true user (.x (test.ConcreteChild.)) nil user (.x ^test.AbstractParent (test.ConcreteChild.)) nil user (def cc (test.ConcreteChild.)) #'user/cc user (.x cc) Reflection warning, NO_SOURCE_PATH:1:1 - reference to field x can't be resolved. nil user What must I add to break it? -- -- 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/groups/opt_out.
Re: Java interop: Can't call public method of non-public class
Yes, the error is there. I also created a *lein new app* project, which by default creates a gen-classed main namespace: (ns call-test.core (:gen-class)) (set! *warn-on-reflection* true) (defn -main [ args] (.x (test.ConcreteChild.))) Now try *lein do clean, uberjar. *It will report a reflection warning while AOT-compiling. Then do *java -jar target/call-test-0.1.0-SNAPSHOT-standalone.jar *and see it fail. This cleanly separates compile time from runtime. On Wednesday, March 13, 2013 11:44:05 AM UTC+1, shlomi...@gmail.com wrote: very interesting.. are you getting the same error as i originally got? On Wednesday, March 13, 2013 12:38:26 PM UTC+2, Marko Topolnik wrote: Detailed finding: it *doesn't* fail at compile time; it always fails at runtime. Reason: at compile time there is a *reflection warning*, which means that the method wasn't found and a reflective call was emited by the compiler. On Wednesday, March 13, 2013 11:31:08 AM UTC+1, Marko Topolnik wrote: I did it: the method must be final. Apparently without that the child is compiled with an overriding method that I didn't even define! On Wednesday, March 13, 2013 11:27:55 AM UTC+1, Marko Topolnik wrote: You should first make a minimal example that reproduces this. I've just failed to do so with the following: abstract class AbstractParent { public void x() { System.out.println(x); } } public class ConcreteChild extends AbstractParent { } user (set! *warn-on-reflection* true) true user (.x (test.ConcreteChild.)) nil user (.x ^test.AbstractParent (test.ConcreteChild.)) nil user (def cc (test.ConcreteChild.)) #'user/cc user (.x cc) Reflection warning, NO_SOURCE_PATH:1:1 - reference to field x can't be resolved. nil user What must I add to break it? -- -- 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/groups/opt_out.
Re: Java interop: Can't call public method of non-public class
right, i managed to reproduce it here, thanks! so i am opening a bug and linking back here On Wednesday, March 13, 2013 12:48:43 PM UTC+2, Marko Topolnik wrote: Yes, the error is there. I also created a *lein new app* project, which by default creates a gen-classed main namespace: (ns call-test.core (:gen-class)) (set! *warn-on-reflection* true) (defn -main [ args] (.x (test.ConcreteChild.))) Now try *lein do clean, uberjar. *It will report a reflection warning while AOT-compiling. Then do *java -jar target/call-test-0.1.0-SNAPSHOT-standalone.jar *and see it fail. This cleanly separates compile time from runtime. On Wednesday, March 13, 2013 11:44:05 AM UTC+1, shlomi...@gmail.com wrote: very interesting.. are you getting the same error as i originally got? On Wednesday, March 13, 2013 12:38:26 PM UTC+2, Marko Topolnik wrote: Detailed finding: it *doesn't* fail at compile time; it always fails at runtime. Reason: at compile time there is a *reflection warning*, which means that the method wasn't found and a reflective call was emited by the compiler. On Wednesday, March 13, 2013 11:31:08 AM UTC+1, Marko Topolnik wrote: I did it: the method must be final. Apparently without that the child is compiled with an overriding method that I didn't even define! On Wednesday, March 13, 2013 11:27:55 AM UTC+1, Marko Topolnik wrote: You should first make a minimal example that reproduces this. I've just failed to do so with the following: abstract class AbstractParent { public void x() { System.out.println(x); } } public class ConcreteChild extends AbstractParent { } user (set! *warn-on-reflection* true) true user (.x (test.ConcreteChild.)) nil user (.x ^test.AbstractParent (test.ConcreteChild.)) nil user (def cc (test.ConcreteChild.)) #'user/cc user (.x cc) Reflection warning, NO_SOURCE_PATH:1:1 - reference to field x can't be resolved. nil user What must I add to break it? -- -- 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/groups/opt_out.
Re: Java interop: Can't call public method of non-public class
here is the bug report: http://dev.clojure.org/jira/browse/CLJ-1183 Thanks! On Wednesday, March 13, 2013 1:02:25 PM UTC+2, shlomi...@gmail.com wrote: right, i managed to reproduce it here, thanks! so i am opening a bug and linking back here On Wednesday, March 13, 2013 12:48:43 PM UTC+2, Marko Topolnik wrote: Yes, the error is there. I also created a *lein new app* project, which by default creates a gen-classed main namespace: (ns call-test.core (:gen-class)) (set! *warn-on-reflection* true) (defn -main [ args] (.x (test.ConcreteChild.))) Now try *lein do clean, uberjar. *It will report a reflection warning while AOT-compiling. Then do *java -jar target/call-test-0.1.0-SNAPSHOT-standalone.jar *and see it fail. This cleanly separates compile time from runtime. On Wednesday, March 13, 2013 11:44:05 AM UTC+1, shlomi...@gmail.comwrote: very interesting.. are you getting the same error as i originally got? On Wednesday, March 13, 2013 12:38:26 PM UTC+2, Marko Topolnik wrote: Detailed finding: it *doesn't* fail at compile time; it always fails at runtime. Reason: at compile time there is a *reflection warning*, which means that the method wasn't found and a reflective call was emited by the compiler. On Wednesday, March 13, 2013 11:31:08 AM UTC+1, Marko Topolnik wrote: I did it: the method must be final. Apparently without that the child is compiled with an overriding method that I didn't even define! On Wednesday, March 13, 2013 11:27:55 AM UTC+1, Marko Topolnik wrote: You should first make a minimal example that reproduces this. I've just failed to do so with the following: abstract class AbstractParent { public void x() { System.out.println(x); } } public class ConcreteChild extends AbstractParent { } user (set! *warn-on-reflection* true) true user (.x (test.ConcreteChild.)) nil user (.x ^test.AbstractParent (test.ConcreteChild.)) nil user (def cc (test.ConcreteChild.)) #'user/cc user (.x cc) Reflection warning, NO_SOURCE_PATH:1:1 - reference to field x can't be resolved. nil user What must I add to break it? -- -- 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/groups/opt_out.
Re: Java interop: Can't call public method of non-public class
Hm. You shouldn't have made ConcreteChild a nested class, that is a distraction that may set people on a wrong trail. In Java you are allowed to have as many package-private classes as you wish; the constraint is only on one *public* class. If you had ConcreteChild.java with this in it: abstract class AbstractParent { public final int x() { return 6; } } public class ConcreteChild extends AbstractParent {} it would have compiled. On Wednesday, March 13, 2013 12:16:10 PM UTC+1, shlomi...@gmail.com wrote: here is the bug report: http://dev.clojure.org/jira/browse/CLJ-1183 Thanks! On Wednesday, March 13, 2013 1:02:25 PM UTC+2, shlomi...@gmail.com wrote: right, i managed to reproduce it here, thanks! so i am opening a bug and linking back here On Wednesday, March 13, 2013 12:48:43 PM UTC+2, Marko Topolnik wrote: Yes, the error is there. I also created a *lein new app* project, which by default creates a gen-classed main namespace: (ns call-test.core (:gen-class)) (set! *warn-on-reflection* true) (defn -main [ args] (.x (test.ConcreteChild.))) Now try *lein do clean, uberjar. *It will report a reflection warning while AOT-compiling. Then do *java -jar target/call-test-0.1.0-SNAPSHOT-standalone.jar *and see it fail. This cleanly separates compile time from runtime. On Wednesday, March 13, 2013 11:44:05 AM UTC+1, shlomi...@gmail.comwrote: very interesting.. are you getting the same error as i originally got? On Wednesday, March 13, 2013 12:38:26 PM UTC+2, Marko Topolnik wrote: Detailed finding: it *doesn't* fail at compile time; it always fails at runtime. Reason: at compile time there is a *reflection warning*, which means that the method wasn't found and a reflective call was emited by the compiler. On Wednesday, March 13, 2013 11:31:08 AM UTC+1, Marko Topolnik wrote: I did it: the method must be final. Apparently without that the child is compiled with an overriding method that I didn't even define! On Wednesday, March 13, 2013 11:27:55 AM UTC+1, Marko Topolnik wrote: You should first make a minimal example that reproduces this. I've just failed to do so with the following: abstract class AbstractParent { public void x() { System.out.println(x); } } public class ConcreteChild extends AbstractParent { } user (set! *warn-on-reflection* true) true user (.x (test.ConcreteChild.)) nil user (.x ^test.AbstractParent (test.ConcreteChild.)) nil user (def cc (test.ConcreteChild.)) #'user/cc user (.x cc) Reflection warning, NO_SOURCE_PATH:1:1 - reference to field x can't be resolved. nil user What must I add to break it? -- -- 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/groups/opt_out.
Re: Java interop: Can't call public method of non-public class
oh, right. thats a good point. ill re-post that correction on the bug report.. thanks for the review! On Wednesday, March 13, 2013 1:42:51 PM UTC+2, Marko Topolnik wrote: Hm. You shouldn't have made ConcreteChild a nested class, that is a distraction that may set people on a wrong trail. In Java you are allowed to have as many package-private classes as you wish; the constraint is only on one *public* class. If you had ConcreteChild.java with this in it: abstract class AbstractParent { public final int x() { return 6; } } public class ConcreteChild extends AbstractParent {} it would have compiled. On Wednesday, March 13, 2013 12:16:10 PM UTC+1, shlomi...@gmail.com wrote: here is the bug report: http://dev.clojure.org/jira/browse/CLJ-1183 Thanks! On Wednesday, March 13, 2013 1:02:25 PM UTC+2, shlomi...@gmail.com wrote: right, i managed to reproduce it here, thanks! so i am opening a bug and linking back here On Wednesday, March 13, 2013 12:48:43 PM UTC+2, Marko Topolnik wrote: Yes, the error is there. I also created a *lein new app* project, which by default creates a gen-classed main namespace: (ns call-test.core (:gen-class)) (set! *warn-on-reflection* true) (defn -main [ args] (.x (test.ConcreteChild.))) Now try *lein do clean, uberjar. *It will report a reflection warning while AOT-compiling. Then do *java -jar target/call-test-0.1.0-SNAPSHOT-standalone.jar *and see it fail. This cleanly separates compile time from runtime. On Wednesday, March 13, 2013 11:44:05 AM UTC+1, shlomi...@gmail.comwrote: very interesting.. are you getting the same error as i originally got? On Wednesday, March 13, 2013 12:38:26 PM UTC+2, Marko Topolnik wrote: Detailed finding: it *doesn't* fail at compile time; it always fails at runtime. Reason: at compile time there is a *reflection warning*, which means that the method wasn't found and a reflective call was emited by the compiler. On Wednesday, March 13, 2013 11:31:08 AM UTC+1, Marko Topolnik wrote: I did it: the method must be final. Apparently without that the child is compiled with an overriding method that I didn't even define! On Wednesday, March 13, 2013 11:27:55 AM UTC+1, Marko Topolnik wrote: You should first make a minimal example that reproduces this. I've just failed to do so with the following: abstract class AbstractParent { public void x() { System.out.println(x); } } public class ConcreteChild extends AbstractParent { } user (set! *warn-on-reflection* true) true user (.x (test.ConcreteChild.)) nil user (.x ^test.AbstractParent (test.ConcreteChild.)) nil user (def cc (test.ConcreteChild.)) #'user/cc user (.x cc) Reflection warning, NO_SOURCE_PATH:1:1 - reference to field x can't be resolved. nil user What must I add to break it? -- -- 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/groups/opt_out.
Re: Java interop: Can't call public method of non-public class
hey, I have a similar problem, even when i type annotate with clojure 1.5 i still get that error.. any suggestions? -- -- 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/groups/opt_out.
Re: Java interop: Can't call public method of non-public class
I meant to post this as a reply to https://groups.google.com/d/msg/clojure/jYfEKVH5GsQ/3Hq5hU0u6UQJ In my case i am trying to get clojure working with netty 4, here is the code: (def #^AbstractBootstrap b (ServerBootstrap.)) (.channel ^AbstractBootstraphttps://github.com/netty/netty/blob/master/transport/src/main/java/io/netty/bootstrap/AbstractBootstrap.java#L84b ^Class io.netty.channel.socket.nio.NioServerSocketChannel) which returns the error: java.lang.IllegalArgumentException: Can't call public method of non-public class: public io.netty.bootstrap.AbstractBootstrap io.netty.bootstrap.AbstractBootstrap.channel(java.lang.Class) at clojure.lang.Reflector.invokeMatchingMethod (Reflector.java:88) why does it still use the reflector even though its fully annotated, and how do i get over that non-public class issue?.. On Wednesday, March 13, 2013 2:26:00 AM UTC+2, Shlomi Vaknin wrote: hey, I have a similar problem, even when i type annotate with clojure 1.5 i still get that error.. any suggestions? -- -- 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/groups/opt_out.
Re: Java interop: Can't call public method of non-public class
On Tue, Mar 12, 2013 at 5:46 PM, shlomivak...@gmail.com wrote: In my case i am trying to get clojure working with netty 4, here is the code: (def #^AbstractBootstrap b (ServerBootstrap.)) (.channel ^AbstractBootstrap b ^Class io.netty.channel.socket.nio.NioServerSocketChannel) which returns the error: java.lang.IllegalArgumentException: Can't call public method of non-public class: public io.netty.bootstrap.AbstractBootstrap io.netty.bootstrap.AbstractBootstrap.channel(java.lang.Class) at clojure.lang.Reflector.invokeMatchingMethod (Reflector.java:88) I can't reproduce this (with Clojure 1.5.1, Netty 4.0.0.Alpha8): user= (set! *warn-on-reflection* true) true user= (import '(io.netty.bootstrap AbstractBootstrap ServerBootstrap)) io.netty.bootstrap.ServerBootstrap user= (def b (ServerBootstrap.)) #'user/b user= (.channel ^AbstractBootstrap b ^Class io.netty.channel.socket.nio.NioServerSocketChannel) #ServerBootstrap ServerBootstrap(factory: NioServerSocketChannel.class) user= *clojure-version* {:major 1, :minor 5, :incremental 1, :qualifier nil} user= Can you provide more detail? -- Sean A Corfield -- (904) 302-SEAN An Architect's View -- http://corfield.org/ World Singles, LLC. -- http://worldsingles.com/ Perfection is the enemy of the good. -- Gustave Flaubert, French realist novelist (1821-1880) -- -- 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/groups/opt_out.
Re: Java interop: Can't call public method of non-public class
I found the following work-around since I have access to the java code I am calling: I had the package-visible ABC Bytes implement a (public) interface declaring the toHexString method. This placated the compiler. On Monday, March 4, 2013, Vladimir Tsichevski wrote: I think not. But upgrading to clojure 1.5 will do. On Friday, March 1, 2013 1:20:57 PM UTC+4, Marko Topolnik wrote: I'd say it's a bug. You are invoking a public class's method, which happens to be inherited from a package-private class. Clojure's reflective code accesses the superclass method directly so there's no distinction between direct invocation and invocation through inheritance. If you are interseted in a workaround, type-hinting the code will work (my guess). On Friday, March 1, 2013 10:13:57 AM UTC+1, bsmith.occs wrote: Simplified, from a more complex example: abstract class Bytes { public toHexString() { return ...; } Bytes { } } public class Hash extends Bytes { public Hash() { super(); } } This works in Java: new Hash().toHexString(); This fails in Clojure: (.toHexString (Hash.)) IllegalArgumentException Can't call public method of non-public class: public final java.lang.String at.gv.brz.bjuvj.hashpass.**Bytes.toHexString() clojure.lang.Reflector.**invokeMatchingMethod (Reflector.java:88) Bug? // ben -- -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.comjavascript:_e({}, 'cvml', '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 javascript:_e({}, 'cvml', 'clojure%2bunsubscr...@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 javascript:_e({}, 'cvml', 'clojure%2bunsubscr...@googlegroups.com');. For more options, visit https://groups.google.com/groups/opt_out. -- -- 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/groups/opt_out.
Re: Java interop: Can't call public method of non-public class
I think not. But upgrading to clojure 1.5 will do. On Friday, March 1, 2013 1:20:57 PM UTC+4, Marko Topolnik wrote: I'd say it's a bug. You are invoking a public class's method, which happens to be inherited from a package-private class. Clojure's reflective code accesses the superclass method directly so there's no distinction between direct invocation and invocation through inheritance. If you are interseted in a workaround, type-hinting the code will work (my guess). On Friday, March 1, 2013 10:13:57 AM UTC+1, bsmith.occs wrote: Simplified, from a more complex example: abstract class Bytes { public toHexString() { return ...; } Bytes { } } public class Hash extends Bytes { public Hash() { super(); } } This works in Java: new Hash().toHexString(); This fails in Clojure: (.toHexString (Hash.)) IllegalArgumentException Can't call public method of non-public class: public final java.lang.String at.gv.brz.bjuvj.hashpass.Bytes.toHexString() clojure.lang.Reflector.invokeMatchingMethod (Reflector.java:88) Bug? // ben -- -- 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/groups/opt_out.
Java interop: Can't call public method of non-public class
Simplified, from a more complex example: abstract class Bytes { public toHexString() { return ...; } Bytes { } } public class Hash extends Bytes { public Hash() { super(); } } This works in Java: new Hash().toHexString(); This fails in Clojure: (.toHexString (Hash.)) IllegalArgumentException Can't call public method of non-public class: public final java.lang.String at.gv.brz.bjuvj.hashpass.Bytes.toHexString() clojure.lang.Reflector.invokeMatchingMethod (Reflector.java:88) Bug? // ben -- -- 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/groups/opt_out.
Re: Java interop: Can't call public method of non-public class
I'd say it's a bug. You are invoking a public class's method, which happens to be inherited from a package-private class. Clojure's reflective code accesses the superclass method directly so there's no distinction between direct invocation and invocation through inheritance. If you are interseted in a workaround, type-hinting the code will work (my guess). On Friday, March 1, 2013 10:13:57 AM UTC+1, bsmith.occs wrote: Simplified, from a more complex example: abstract class Bytes { public toHexString() { return ...; } Bytes { } } public class Hash extends Bytes { public Hash() { super(); } } This works in Java: new Hash().toHexString(); This fails in Clojure: (.toHexString (Hash.)) IllegalArgumentException Can't call public method of non-public class: public final java.lang.String at.gv.brz.bjuvj.hashpass.Bytes.toHexString() clojure.lang.Reflector.invokeMatchingMethod (Reflector.java:88) Bug? // ben -- -- 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/groups/opt_out.
Re: Can't call public method of non-public class
Is this it? http://www.assembla.com/spaces/clojure/tickets/259 On Mar 23, 8:26 pm, Mark J. Reed markjr...@gmail.com wrote: As far as I can tell, you're doing nothing wrong and just hitting a bug in Clojure. Which is still in 1.2.0-master... On Tue, Mar 23, 2010 at 11:43 AM, Konstantin Barskiy zuftw...@gmail.com wrote: I'm trying to reproduce ProcessBuilder example from java documentation http://java.sun.com/javase/6/docs/api/java/lang/ProcessBuilder.html This is that example: ProcessBuilder pb = new ProcessBuilder(myCommand, myArg1, myArg2); MapString, String env = pb.environment(); env.put(VAR1, myValue); env.remove(OTHERVAR); env.put(VAR2, env.get(VAR1) + suffix); pb.directory(new File(myDir)); Process p = pb.start(); I'm typing folowing in clojure repl: D:\Users\Konstantinjava -jar clojure.jar Clojure 1.1.0 user= (def pb (new ProcessBuilder [myCommand myArg])) #'user/pb user= (def env (.environment pb)) #'user/env user= (.put env VAR1, myValue) java.lang.IllegalArgumentException: Can't call public method of non- public class: public java.lang.String java.lang.ProcessEnvironment.put(java.lang.String,java.lang.String) (NO_SOURCE_FILE:0) What does this error mean and what i am doing wrong? -- 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 To unsubscribe from this group, send email to clojure+unsubscribegooglegroups.com or reply to this email with the words REMOVE ME as the subject. -- Mark J. Reed markjr...@gmail.com -- 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 To unsubscribe from this group, send email to clojure+unsubscribegooglegroups.com or reply to this email with the words REMOVE ME as the subject.
Re: Can't call public method of non-public class
That's the one. But the solution given by the bug reporter doesn't address the case that came up on this thread, since it's not the class of the invocant but the types of the parameters that prevent the match from being found. On Thu, Mar 25, 2010 at 7:06 AM, atucker agjf.tuc...@googlemail.com wrote: Is this it? http://www.assembla.com/spaces/clojure/tickets/259 On Mar 23, 8:26 pm, Mark J. Reed markjr...@gmail.com wrote: As far as I can tell, you're doing nothing wrong and just hitting a bug in Clojure. Which is still in 1.2.0-master... On Tue, Mar 23, 2010 at 11:43 AM, Konstantin Barskiy zuftw...@gmail.com wrote: I'm trying to reproduce ProcessBuilder example from java documentation http://java.sun.com/javase/6/docs/api/java/lang/ProcessBuilder.html This is that example: ProcessBuilder pb = new ProcessBuilder(myCommand, myArg1, myArg2); MapString, String env = pb.environment(); env.put(VAR1, myValue); env.remove(OTHERVAR); env.put(VAR2, env.get(VAR1) + suffix); pb.directory(new File(myDir)); Process p = pb.start(); I'm typing folowing in clojure repl: D:\Users\Konstantinjava -jar clojure.jar Clojure 1.1.0 user= (def pb (new ProcessBuilder [myCommand myArg])) #'user/pb user= (def env (.environment pb)) #'user/env user= (.put env VAR1, myValue) java.lang.IllegalArgumentException: Can't call public method of non- public class: public java.lang.String java.lang.ProcessEnvironment.put(java.lang.String,java.lang.String) (NO_SOURCE_FILE:0) What does this error mean and what i am doing wrong? -- 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 To unsubscribe from this group, send email to clojure+unsubscribegooglegroups.com or reply to this email with the words REMOVE ME as the subject. -- Mark J. Reed markjr...@gmail.com -- 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 To unsubscribe from this group, send email to clojure+unsubscribegooglegroups.com or reply to this email with the words REMOVE ME as the subject. -- Mark J. Reed markjr...@gmail.com -- 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 To unsubscribe from this group, send email to clojure+unsubscribegooglegroups.com or reply to this email with the words REMOVE ME as the subject.
Re: Can't call public method of non-public class
On Tue, Mar 23, 2010 at 7:38 PM, Stuart Campbell stuart.william.campb...@gmail.com wrote: From JDK docs (http://java.sun.com/j2se/1.5.0/docs/api/java/lang/ProcessBuilder.html#environment%28%29): The behavior of the returned map is system-dependent. A system may not allow modifications to environment variables or may forbid certain variable names or values. For this reason, attempts to modify the map may fail with UnsupportedOperationException or IllegalArgumentException if the modification is not permitted by the operating system. Sure, but that's not the problem here; Clojure is not even getting as far as compiling the code because its reflection code is too strict when matching methods to candidates. I submit the attached patch as a more general solution than Armando's, although whether it's worthwhile I'll leave up to Rich and company... -- Mark J. Reed markjr...@gmail.com -- 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 To unsubscribe from this group, send email to clojure+unsubscribegooglegroups.com or reply to this email with the words REMOVE ME as the subject. Reflector.patch.gz Description: GNU Zip compressed data
Re: Can't call public method of non-public class
This looks like the old type erasure problem - the returned map is of a private class, so clojure looks for a public version of the put method in one of the interfaces/base classes - but does an exact comparison on parameter types, so put(String, String) doesn't match put(Object, Object) and the search fails. You might think that the Reflection API would provide a way of looking for methods that you could call with the types given, instead of just exact match, but using getMethod() or getDeclaredMethod() instead of looping and comparing manually yields the same result. However, as mentioned at http://christerblog.wordpress.com/2010/02/27/java-reflection-matching-formal-parameter-list-to-actual-parameter-list/ , the Coherence Common Incubator project has a ReflectorHelper module that provides a solution (at least in the case of constructors); I''m thinking Clojure could adapt/adopt that solution. On Tue, Mar 23, 2010 at 4:26 PM, Mark J. Reed markjr...@gmail.com wrote: As far as I can tell, you're doing nothing wrong and just hitting a bug in Clojure. Which is still in 1.2.0-master... On Tue, Mar 23, 2010 at 11:43 AM, Konstantin Barskiy zuftw...@gmail.com wrote: I'm trying to reproduce ProcessBuilder example from java documentation http://java.sun.com/javase/6/docs/api/java/lang/ProcessBuilder.html This is that example: ProcessBuilder pb = new ProcessBuilder(myCommand, myArg1, myArg2); MapString, String env = pb.environment(); env.put(VAR1, myValue); env.remove(OTHERVAR); env.put(VAR2, env.get(VAR1) + suffix); pb.directory(new File(myDir)); Process p = pb.start(); I'm typing folowing in clojure repl: D:\Users\Konstantinjava -jar clojure.jar Clojure 1.1.0 user= (def pb (new ProcessBuilder [myCommand myArg])) #'user/pb user= (def env (.environment pb)) #'user/env user= (.put env VAR1, myValue) java.lang.IllegalArgumentException: Can't call public method of non- public class: public java.lang.String java.lang.ProcessEnvironment.put(java.lang.String,java.lang.String) (NO_SOURCE_FILE:0) What does this error mean and what i am doing wrong? -- 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 To unsubscribe from this group, send email to clojure+unsubscribegooglegroups.com or reply to this email with the words REMOVE ME as the subject. -- Mark J. Reed markjr...@gmail.com -- Mark J. Reed markjr...@gmail.com -- 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 To unsubscribe from this group, send email to clojure+unsubscribegooglegroups.com or reply to this email with the words REMOVE ME as the subject.
Re: Can't call public method of non-public class
Thanks a lot! Is there way to do the same thing using 'doto'? e.g. (doto (.environment pb) (.put Var1 myValue)) I can't figure out where to place #^Map hint... On Mar 24, 5:19 am, Armando Blancas armando_blan...@yahoo.com wrote: You want Clojure to treat 'env' as a Map instead of its implementation class, which is not public. Just add the type hint #^Map to 'env''s def: user= (def pb (new ProcessBuilder [myCommand myArg])) #'user/pb user= (def #^Map env (.environment pb)) #'user/env user= (.put env VAR1, myValue) myValue -- 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 To unsubscribe from this group, send email to clojure+unsubscribegooglegroups.com or reply to this email with the words REMOVE ME as the subject.
Re: Can't call public method of non-public class
As far as I can tell, you're doing nothing wrong and just hitting a bug in Clojure. Which is still in 1.2.0-master... On Tue, Mar 23, 2010 at 11:43 AM, Konstantin Barskiy zuftw...@gmail.com wrote: I'm trying to reproduce ProcessBuilder example from java documentation http://java.sun.com/javase/6/docs/api/java/lang/ProcessBuilder.html This is that example: ProcessBuilder pb = new ProcessBuilder(myCommand, myArg1, myArg2); MapString, String env = pb.environment(); env.put(VAR1, myValue); env.remove(OTHERVAR); env.put(VAR2, env.get(VAR1) + suffix); pb.directory(new File(myDir)); Process p = pb.start(); I'm typing folowing in clojure repl: D:\Users\Konstantinjava -jar clojure.jar Clojure 1.1.0 user= (def pb (new ProcessBuilder [myCommand myArg])) #'user/pb user= (def env (.environment pb)) #'user/env user= (.put env VAR1, myValue) java.lang.IllegalArgumentException: Can't call public method of non- public class: public java.lang.String java.lang.ProcessEnvironment.put(java.lang.String,java.lang.String) (NO_SOURCE_FILE:0) What does this error mean and what i am doing wrong? -- 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 To unsubscribe from this group, send email to clojure+unsubscribegooglegroups.com or reply to this email with the words REMOVE ME as the subject. -- Mark J. Reed markjr...@gmail.com -- 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 To unsubscribe from this group, send email to clojure+unsubscribegooglegroups.com or reply to this email with the words REMOVE ME as the subject.
Re: Can't call public method of non-public class
You probably can't. I think hints only go in binding declarations. I'd use 'env', as you're probably doing already. But let's keep an eye on Mark's patch, as it'd be much better to avoid an explicit upcasting. On Mar 23, 7:38 pm, Konstantin Barskiy zuftw...@gmail.com wrote: Thanks a lot! Is there way to do the same thing using 'doto'? e.g. (doto (.environment pb) (.put Var1 myValue)) I can't figure out where to place #^Map hint... -- 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 To unsubscribe from this group, send email to clojure+unsubscribegooglegroups.com or reply to this email with the words REMOVE ME as the subject.
Can't call public method of non-public class
I'm trying to reproduce ProcessBuilder example from java documentation http://java.sun.com/javase/6/docs/api/java/lang/ProcessBuilder.html This is that example: ProcessBuilder pb = new ProcessBuilder(myCommand, myArg1, myArg2); MapString, String env = pb.environment(); env.put(VAR1, myValue); env.remove(OTHERVAR); env.put(VAR2, env.get(VAR1) + suffix); pb.directory(new File(myDir)); Process p = pb.start(); I'm typing folowing in clojure repl: D:\Users\Konstantinjava -jar clojure.jar Clojure 1.1.0 user= (def pb (new ProcessBuilder [myCommand myArg])) #'user/pb user= (def env (.environment pb)) #'user/env user= (.put env VAR1, myValue) java.lang.IllegalArgumentException: Can't call public method of non- public class: public java.lang.String java.lang.ProcessEnvironment.put(java.lang.String,java.lang.String) (NO_SOURCE_FILE:0) What does this error mean and what i am doing wrong? -- 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 To unsubscribe from this group, send email to clojure+unsubscribegooglegroups.com or reply to this email with the words REMOVE ME as the subject.
Re: Can't call public method of non-public class
Hi Konstantin, From JDK docs ( http://java.sun.com/j2se/1.5.0/docs/api/java/lang/ProcessBuilder.html#environment%28%29 ): The behavior of the returned map is system-dependent. A system may not allow modifications to environment variables or may forbid certain variable names or values. For this reason, attempts to modify the map may fail with UnsupportedOperationExceptionhttp://java.sun.com/j2se/1.5.0/docs/api/java/lang/UnsupportedOperationException.htmlor IllegalArgumentExceptionhttp://java.sun.com/j2se/1.5.0/docs/api/java/lang/IllegalArgumentException.htmlif the modification is not permitted by the operating system. Regards, Stuart On 24 March 2010 02:43, Konstantin Barskiy zuftw...@gmail.com wrote: I'm trying to reproduce ProcessBuilder example from java documentation http://java.sun.com/javase/6/docs/api/java/lang/ProcessBuilder.html This is that example: ProcessBuilder pb = new ProcessBuilder(myCommand, myArg1, myArg2); MapString, String env = pb.environment(); env.put(VAR1, myValue); env.remove(OTHERVAR); env.put(VAR2, env.get(VAR1) + suffix); pb.directory(new File(myDir)); Process p = pb.start(); I'm typing folowing in clojure repl: D:\Users\Konstantinjava -jar clojure.jar Clojure 1.1.0 user= (def pb (new ProcessBuilder [myCommand myArg])) #'user/pb user= (def env (.environment pb)) #'user/env user= (.put env VAR1, myValue) java.lang.IllegalArgumentException: Can't call public method of non- public class: public java.lang.String java.lang.ProcessEnvironment.put(java.lang.String,java.lang.String) (NO_SOURCE_FILE:0) What does this error mean and what i am doing wrong? -- 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.comclojure%2bunsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en To unsubscribe from this group, send email to clojure+ unsubscribegooglegroups.com or reply to this email with the words REMOVE ME as 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 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 To unsubscribe from this group, send email to clojure+unsubscribegooglegroups.com or reply to this email with the words REMOVE ME as the subject.
Re: Can't call public method of non-public class
You want Clojure to treat 'env' as a Map instead of its implementation class, which is not public. Just add the type hint #^Map to 'env''s def: user= (def pb (new ProcessBuilder [myCommand myArg])) #'user/pb user= (def #^Map env (.environment pb)) #'user/env user= (.put env VAR1, myValue) myValue -- 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 To unsubscribe from this group, send email to clojure+unsubscribegooglegroups.com or reply to this email with the words REMOVE ME as the subject.
Re: Can't call public method of non-public class
Whoops... I completely glazed over the fact that the equivalent Java code worked perfectly :( On 24 March 2010 11:19, Armando Blancas armando_blan...@yahoo.com wrote: You want Clojure to treat 'env' as a Map instead of its implementation class, which is not public. Just add the type hint #^Map to 'env''s def: user= (def pb (new ProcessBuilder [myCommand myArg])) #'user/pb user= (def #^Map env (.environment pb)) #'user/env user= (.put env VAR1, myValue) myValue -- 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.comclojure%2bunsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en To unsubscribe from this group, send email to clojure+ unsubscribegooglegroups.com or reply to this email with the words REMOVE ME as 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 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 To unsubscribe from this group, send email to clojure+unsubscribegooglegroups.com or reply to this email with the words REMOVE ME as the subject.