-
Notifications
You must be signed in to change notification settings - Fork 31
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Thrameos Thanks!
How do I reference |
That method was previously an internal private so it likely wasn't intended to be used directly thus it did not get preserved. PyJPField is an descriptor now so the nearest function would be There is one other place were I have seen people using internals that seems to crop up. Under 0.7.0 the exceptions are mapped directly to Python, but they were indirectly mapped in 0.6.3. The use of JException() was the safe pattern in the old version and should work in both, but most people got directly into the argument list. If you want to require 0.7.0 it is easy as rather than calling the wrapper you simple catch the Java type (or catch from a rethrow.) Ie. 0.6.3:
Which is bad because it is going into the private methods. The pattern for 0.6.3 was supposed to be (though honestly I am not sure if it worked as some things were buggy)
Starting from 0.7.0, the exceptions are all Python exceptions so they can be caught directly.
JException is still the base class and can be used to catch and redirect to a handling routine. I see this issue at |
It seems that 0.7.0 can be written fluently. |
The return value of |
Well it is a descriptor so it should be accessed as such. Thus types = jpype.java.sql.Types
_jdbc_type_name_mappings = dict()
for field in types.__javaclass__.getClassFields():
_jdbc_type_name_mappings[field.getName()] = field.getStaticAttribute()
print(_jdbc_type_name_mappings) Would become types = jpype.java.sql.Types
_jdbc_type_name_mappings = dict()
for field in types.__javaclass__.getClassFields():
_jdbc_type_name_mappings[field.getName()] = getattr(types,field.getName())
print(_jdbc_type_name_mappings) Because to get the value of a Python field is to call Of course this still isn't perfect as we are still accessing the private modifier = jpype.java.lang.reflect.Modifier
types = jpype.java.sql.Types
_jdbc_type_name_mappings = dict()
for field in types.class_.getFields():
if modifier.isStatic(field.getModifiers()):
_jdbc_type_name_mappings[field.getName()] = getattr(types, field.getName())
print(_jdbc_type_name_mappings) Simple and now without touching anyone's privates.
Better yet, running the same code with 0.6.3 gives the same answer. |
Thanks! It was really easy to understand.
It is wonderful. I will try to fix it to work with 0.7.0 and 0.6.3. |
Corrects issues with
-server
option. Not all JVM accept that option.