Reputation: 8487
Since I'm not quite sure what's involved with forking gnu.mail.providers I'd like use reflection to interact with this class.
I think the arithmetic in getMessage is incorrect:
GroupResponse gr = ns.connection.group(name);
first = gr.first;
last = gr.last;
count = gr.count;
// Get article
m = getMessageImpl(msgnum - 1 + first);
// Cache store
articleCache.put(key, m);
return m;
In any event, I'd like to gain access to the GroupResponse object above in the getMessage method. While I know that reflection can do things along these lines, I'm not sure how to get this particular object from this particular method. I've used reflection to gain access to some of the fields (first, last, count), but this seems a little different.
It's the GroupResponse class which seems to hold everything together.
Can I use reflection to write a custom getMessage method and "tack" it onto NNTPFolder? I'm not sure what's possible or advisable.
Upvotes: 2
Views: 1240
Reputation: 12837
Look into Byteman. Using it, you can describe a rule that whenever the method getMessage()
on the affected class is called, your own code will be called.
Upvotes: 1
Reputation: 80603
You cannot use reflection to modify the contents of a method. You cannot use byte code manipulation libraries to modify the contents of a method. With byte code manipulation though, you can intercept the method call and redirect to another method of your choice. That's about as close as you are going to get afaik.
Another option would be to obtain the source of the libraries, make some modifications to suit your needs, and recompile.
Upvotes: 5