Issue1503
Created on 2009-11-13.09:52:02 by MrMeanie, last changed 2010-09-08.07:19:19 by zyasoft.
msg5308 (view) |
Author: Geoffrey French (MrMeanie) |
Date: 2009-11-13.09:52:01 |
|
Currently, any keyword arguments passed to a constructor of a Java class
are used to set bean properties of the specified names, which obviously
adds convenience.
Java methods can receive and process keyword arguments by having the
form MyClass#myMethod(PyObject values[], String names[]); Jython assumes
that the Java method wishes to receive keyword arguments, and passes
them through.
It would be beneficial for constructors to be able to handle keyword
arguments that same way that methods do. Unfortunately, this is not
currently the case, since any keyword arguments are assumed to be bean
property values.
|
msg5309 (view) |
Author: Geoffrey French (MrMeanie) |
Date: 2009-11-13.10:09:33 |
|
Please find attached a patch that addresses this issue, along with some
additional tests to verify its functionality.
Both 'regrtest' and 'javatest' pass with these changes in place.
The following changes have been made:
org.python.core.PyReflectedConstructor#__call__:
Keyword arguments are now handled by:
- If keyword arguments have been passed:
- If a constructor can be found that accepts keyword arguments, it
will be invoked.
- If no keyword arg constructor is found, then the keyword args are
stripped, and the remaining args are passed to a constructor that will
accept them. The keyword args are used as bean property values
- If no keyword arguments have been passed, the arguments are passed to
the constructor as normal.
tests/python/constructorkwargs_test.py: Python part of the test
tests/java/org/python/tests/* Java parts of the test
|
msg6004 (view) |
Author: Jim Baker (zyasoft) |
Date: 2010-08-22.22:40:44 |
|
Useful functionality and a patch exists. Need to review, hopefully we can get this in for 2.5.2 beta 2.
|
msg6048 (view) |
Author: Jim Baker (zyasoft) |
Date: 2010-09-08.07:19:19 |
|
Fixed by r7113
|
|
Date |
User |
Action |
Args |
2010-09-08 07:19:19 | zyasoft | set | status: open -> closed assignee: zyasoft resolution: fixed messages:
+ msg6048 title: Java constructors accepting keyword arguments -> Java constructors should take keyword arguments |
2010-08-22 22:40:44 | zyasoft | set | priority: high messages:
+ msg6004 |
2010-08-15 14:59:54 | zyasoft | set | nosy:
+ zyasoft |
2009-11-13 10:09:36 | MrMeanie | set | files:
+ Issue1503 _constructor_kwargs_v1_20091113.patch keywords:
+ patch messages:
+ msg5309 |
2009-11-13 09:52:02 | MrMeanie | create | |
|