From: Kent J. <ke...@td...> - 2006-06-23 10:56:48
|
Diez B. Roggisch wrote: >> I have read some things on Jython now, and I think I understand it's >> cpncept. However I just have one question? Why use Jython when you can >> use Java objects with Reflection? I mean are there any advanteges that >> Jython gives but reflection in Java doesn't. >> >> Please do not take this as an offence, it is just a question to help me >> understand better where jytho enters in the development environment. > > Object target; > Integer argument = new Integer(10); > try { > Class tc = target.getClass(); > Method m = tc.getDeclaredMethod("someMethod", new Class [] {Integer.TYPE}); > Object result = m.invoke(target, new Object [] {argument}); > } catch (Exception ex) { > throw new RuntimeException(ex); > } > > > vs. > > target.someMethod(10) I think you mean getattr(target, "someMethod")(10) but still a great example of how Jython reflection is simpler than Java's. Kent |