From: <mi...@hi...> - 2001-03-21 02:07:44
|
I am running into a problem trying to subclass a java class from Jython2.0. The problem lies in the fact that the java class I extend from uses reflection to implement the template method pattern. The methods it is looking for is implemented in my jython class. Here is an example using the JUnit framework which illustrates my problem: ---- example.py ---- import java import junit class MyJavaClassTest(junit.framework.TestCase): def __init__(self, name): junit.framework.TestCase.__init__(self, name) def setUp(self): "@sig public void setUp()" pass def testMyJavaClass(self): "@sig public void testMyJavaClass()" pass junit.textui.TestRunner.run(MyJavaClassTest("testMyJavaClass")) ---- end example.py ---- Running this from the command line I get: $ cmd /c c:/devel/jython-2.1/jython.bat example.py .F Time: 0 There was 1 failure: 1) testMyJavaClass(org.python.proxies.__main__$MyJavaClassTest$1) "Method "testM yJavaClass" not found" FAILURES!!! Tests run: 1, Failures: 1, Errors: 0 As you can see the JUnit TestCase class is using reflection to look for the testMyJavaClass method. Will this example only work if I run jythonc? It looks like the autogenerated proxy class is ignoring the "@sig" information. Also, with the upcoming 2.1 release, will function attributes be used to replace the "@sig" syntax? --mike |