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.
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.