From: Oti <oh...@ya...> - 2002-07-08 05:48:14
|
[ Finn Bock ] > Hi, > > A couple of time users has asked for a way to make a dynamicly > generated > proxy class more java like when the proxy is inspected with java > reflection. That is what jythonc's @sig feature does. > > We can add something slightly similar to the dynamic proxy generator. > In > the snippet below I have decorated the functions with a .sig > attribute > that contains return type, a list of argument types and a list of > exception classes. > > The decoration could also be some instance instead of a tuple or > something else entirely, but the decoration will *never* be in the > form > if a textual @sig string in the doc string! Resolving the classnames > in > the @sig string is way to magical to be used dynamicly. Adding new > syntax to the python language is also unacceptable. > > I'm still undecided if doing something like this is a good idea at > all. > > regards, > finn > > > import junit > from java import lang, util > > class A(junit.framework.TestCase): > def __init__(self, name): > pass > def testAdd(self): > print "testAdd" > testAdd.sig = (lang.Void.TYPE, [], []) > > def testMul(self): > print "testMul" > testMul.sig = (lang.Void.TYPE, [], []) > > def myJavaMethod(self, a, b, c): > print a, b, c > return 5 > myJavaMethod.sig = (lang.Integer.TYPE, > [lang.String, lang.Integer, util.Date], > [lang.Exception]) > > junit.textui.TestRunner.run(A) Hello Finn, i think this would be very useful ! Below is the 'test' for you if i understood it correctly: Take an abstract java class with overloaded methods, one of these overloaded methods being abstract. Extend this class in Jython and implement the 'missing' method. Then you are - currently - lucky if the appropriate method is being called from Jython. My feeling is that such a sig mechanism could be a great help calling overloaded java methods - in general. Best wishes, Oti. __________________________________________________ Do You Yahoo!? Sign up for SBC Yahoo! Dial - First Month Free http://sbc.yahoo.com |