Issue2702
Created on 2018-09-05.10:28:57 by ucguy, last changed 2018-09-10.22:00:17 by stefan.richthofer.
msg12092 (view) |
Author: ucguy (ucguy) |
Date: 2018-09-05.10:28:56 |
|
I get this error when I am doing following :
return (T) object.__tojava__(clazz);
and clazz is MyEnum[].class and MyEnum is an Java Enum.
Note that it works for String[] but not for Enum array.
As a workaround, I used String[] and some reflection bits to make it work but it would be good to listen about this.
|
msg12093 (view) |
Author: Stefan Richthofer (stefan.richthofer) |
Date: 2018-09-06.20:10:24 |
|
This might be related to ideas discussed in http://bugs.jython.org/issue2558.
ucguy, your description reads somewhat cryptic to me. While I can roughly guess what you try to do I would prefer an explicit description.
Please provide an - ideally runnable - code example, the output you get and the output you expect or would hope for.
That said, I think that Jython's automatic conversion does not support enums as of this writing. What Python object would you expect as a result? AFAIK enums are not part of standard Python, one needs a special module, e.g. https://pypi.org/project/enum34/ to enable enums in Python. Jython cannot support in terms of automatic coercion all sorts of non-standard modules arround.
|
msg12098 (view) |
Author: ucguy (ucguy) |
Date: 2018-09-10.08:44:51 |
|
Apologies for not making my post a bit descriptive earlier.
As you correctly sensed, I am trying to convert a Python string array (which is supposed to have enum constants) to Java Enum array.
I believe I got my answer as enums are not part of the standard python so I shouldn't expect an enum array as a result of automatic conversion in Jython.
As a workaround, now I am getting Java String[] from Python array and then I am converting it to Enum[] using reflection.
Thanks for mentioning the useful references. This can now be closed.
|
msg12099 (view) |
Author: Stefan Richthofer (stefan.richthofer) |
Date: 2018-09-10.22:00:17 |
|
Alright. From time to time I reason whether there is a way to support enums in Jython somewhat consistently (e.g. simply convert them to a dict or so). I never looked into https://pypi.org/project/enum34/ in detail but maybe it can be supported indirectly in kind of a duck typing approach. However this stuff has no notably priority in foreseeable future. So I'll close this now as won't fix.
|
|
Date |
User |
Action |
Args |
2018-09-10 22:00:17 | stefan.richthofer | set | status: open -> closed severity: major -> minor type: crash -> behaviour messages:
+ msg12099 priority: low assignee: stefan.richthofer resolution: wont fix |
2018-09-10 08:44:52 | ucguy | set | messages:
+ msg12098 |
2018-09-06 20:10:25 | stefan.richthofer | set | nosy:
+ stefan.richthofer messages:
+ msg12093 |
2018-09-05 10:28:57 | ucguy | create | |
|