|
From: Updike, C. <Cla...@jh...> - 2004-12-30 15:45:45
|
I'm trying to construct an instance of a java object given a reference
to a=20
method of a java class. It is simple to do it for a jython class:
>>> from org.python.core import PyMethod, PyReflectedFunction
>>> def instanceFromMethod(method):
... if type(method) =3D=3D PyMethod:
... return method.im_class()
... elif type(method) =3D=3D PyReflectedFunction:
... print "Sorry..."
... else:
... raise Exception("Must be a function or a reflected function")
...
>>> class X:
... def f(self):
... pass
...
>>> instanceFromMethod(X.f)
<__main__.X instance at 6814979>
>>>
But I don't know how to do anything similar when it is a java-based
method:
>>> from java.lang import Object
>>> instanceFromMethod(Object.toString)
Sorry...
PyReflectedFunction doesn't seem to expose anything traceable back to
the original
class (or proxy thereof). Does anyone have any ideas?
TIA,
Clark
|