Issue1503

classification
Title: Java constructors accepting keyword arguments
Type: Severity: normal
Components: Versions:
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: MrMeanie
Priority: Keywords: patch

Created on 2009-11-13.09:52:02 by MrMeanie, last changed 2009-11-13.10:09:35 by MrMeanie.

Files
File name Uploaded Description Edit Remove
Issue1503 _constructor_kwargs_v1_20091113.patch MrMeanie, 2009-11-13.10:09:34 Patch to latest SVN (rev 6942)
Messages
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
History
Date User Action Args
2009-11-13 10:09:36MrMeaniesetfiles: + Issue1503 _constructor_kwargs_v1_20091113.patch
keywords: + patch
messages: + msg5309
2009-11-13 09:52:02MrMeaniecreate