Not sure about the other info you're looking for, but I think I can help
explain what's going on. All methods have an extra argument passed in
representing the object itself (usually called "this").
In your example, what you want is:
(ns p.C (:gen-class :methods [[m [Object] void]]))
(defn -m [this o] (println (.. o getClass getName)))
Hope that helps,
Chris
On Wed, Dec 10, 2008 at 10:17 PM, Michiel de Mare <[EMAIL PROTECTED]> wrote:
>
> I'm trying to generate a Java class from Clojure with gen-class, but
> without much success. I've got the following code:
>
> (ns p.C (:gen-class :methods [[m [Object] void]]))
> (defn -m [o] (println (.. o getClass getName)))
>
> The signature of the m method is correct:
>
> javap p.C
> public class p.C extends java.lang.Object{
> public static {};
> public p.C();
> public int hashCode();
> public boolean equals(java.lang.Object);
> public java.lang.String toString();
> public java.lang.Object clone();
> public void m(java.lang.Object);
> public static void main(java.lang.String[]);
> }
>
> But when I try to call the method, I get the following exception:
>
> NativeException: java.lang.IllegalArgumentException: Wrong number of
> args passed to: C$-m
> from clojure/lang/AFn.java:469:in `throwArity'
> from clojure/lang/AFn.java:76:in `invoke'
> from p.C:-1:in `m'
> from sun/reflect/NativeMethodAccessorImpl.java:-2:in `invoke0'
> from sun/reflect/NativeMethodAccessorImpl.java:39:in `invoke'
> from sun/reflect/DelegatingMethodAccessorImpl.java:25:in `invoke'
> from java/lang/reflect/Method.java:597:in `invoke'
> ...
>
> What's going on?
>
> Also, can somebody give an example of a gen-class call that specifies:
> - a static method
> - a method with an array among the parameters.
>
> Cheers,
>
> Michiel de Mare
> >
>
--
"An ideal world is left as an exercise to the reader."
- Paul Graham, On Lisp
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Clojure" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---