Title: Java constructors should take keyword arguments
Type: Severity: normal
Components: Versions:
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: zyasoft Nosy List: MrMeanie, zyasoft
Priority: high Keywords: patch

Created on 2009-11-13.09:52:02 by MrMeanie, last changed 2010-09-08.07:19:19 by zyasoft.

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)
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:

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/ 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:19zyasoftsetstatus: 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:44zyasoftsetpriority: high
messages: + msg6004
2010-08-15 14:59:54zyasoftsetnosy: + zyasoft
2009-11-13 10:09:36MrMeaniesetfiles: + Issue1503 _constructor_kwargs_v1_20091113.patch
keywords: + patch
messages: + msg5309
2009-11-13 09:52:02MrMeaniecreate