Replies: 3 comments 2 replies
-
The code you are showing is certainly bad practice, but there are work arounds. JPype fully supports Java reflection to access any members that are not available in the Python space. If you just need to get one or two fields that works fine. Alternatively, assuming your whole library contains such an idiom, you can use a customizer to automatically add conflicting symbols with an underscore.
You can customize any behavior of any Java wrapper (rename, make beans properties appear as Python properties, rearrange the class tree, etc). This is in addition to adding python methods or defining the type conversions that apply. To get more details look over jpype/_jcollection.py which will show you how to Pythonize Java classes and jpype/beans.py which shows full customization of classes. |
Beta Was this translation helpful? Give feedback.
-
@marscher I could catch conflicts like this back in the class definition phase. I was surprised to see that some of the java base classes used this idiom. Is it worth making this a supported behavior? I just worry about the conflict symbols generating their own conflicts. |
Beta Was this translation helpful? Give feedback.
-
Thanks a lot for the suggestion with code, we are deliberately using public final field objects that manipulate properties with the same name as those fields (so not quite like in the example). So we use this pattern; if we can get the workaround to work it is all fine, great though if handled internally by jpype. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
With the following Java class:
I only see the method mean() on the Python side, not the field, if there is a name collision. Is there any way around this (we can't see some of our public fields at the moment because of this)?
Beta Was this translation helpful? Give feedback.
All reactions