after some more debugging, the issue seems more subtle: the method that has declaringClass target.getClass is apparantly of signature (Lcom/sun/jdi/ReferenceType)V;
Though both are methods of interface MethodEntryRequest: http://java.sun.com/javase/6/docs/jdk/api/jpda/jdi/com/sun/jdi/request/MethodEntryRequest.html So there is a more subtle bug than taking the last method which is in the class walking at getAsMethodOfPublicBase(m.getDeclaringClass(), m) - taking the getDeclaringClass of the found method might lead to the wrong assumption that the target class does not inmplement or extend any public type that defines that method. Why not take target.getClass for finding a matching public type anyways? like: getAsMethodOfPublicBase(target.getClass(), m) It works with type hinting, this is not orthogonal behaviour. -- Jakob On Jan 11, 10:55 pm, jpraher <j...@hapra.at> wrote: > Hi all, > > first of all kudos to clojure. Especially the clojure-swank in > combination with leinigen is a nice environment to work with. > > Now to my problem: > I am playing with JDI to intercept events of an attached JVM via > clojure. Since there are a lot of siblings eventrequest subinterfaces, > which can be obtained by working with a factory called > eventrequestmanager, I am using a construct like the following: > > (def METHOD_ENTRY 'createMethodEntryRequest) > > (defmacro create-request > [event-manager kind] > (let [k (eval kind)] > `(. ~event-manager ~k))) > > ; the usage is something like: > (let [event-request (create-request my-event-manager METHOD_ENTRY)] > (.addClassFilter event-request "some.package.*") > (.enable event-request)) > > ; now the problem is that addClassFilter is defined in a public > interface, yet is implemented is an anonymous inner class, that is > apparently non-public > ; so I get the following exception: > > Can't call public method of non-public class: public synchronized void > com.sun.tools.jdi.EventRequestManagerImpl > $ClassVisibleEventRequestImpl.addClassFilter(java.lang.String) > [Thrown class java.lang.IllegalArgumentException] > > Backtrace: > 0: clojure.lang.Reflector.invokeMatchingMethod(Reflector.java:85) > 1: clojure.lang.Reflector.invokeInstanceMethod(Reflector.java:28) > ... > > By using type hints I can circumvent the problem, see below. > > I do not know how to use type hinting whithin the above macro, since > the return type is specified indirectly in the parameter that is given > (this provides the method to be invoked). So I cannot declare a static > return type of a macro (would this be possible at all?). I tried > (cast) but this does not help either. What should I do? > > To summarize: > > user> (def *method-entry* (debug/create-request (debug/event-request- > manager *vm*) debug/METHOD_ENTRY)) > #'user/*method-entry* > > ; static workaround: declare the type of the variable to be the public > interface > user> (def #^{:tag com.sun.jdi.request.MethodEntryRequest} me *method- > entry*) > #'user/me > > ; addClassFilter does not work with the raw instance returned > user> (.addClassFilter *method-entry* "test") > ; Evaluation aborted. > > ; addClassFilter does however work with a type hinted to be the > interface type. > user> (.addClassFilter me "test") > nil > > What would u suggest? > Thanks for help. > -- Jakob
-- 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