Make OpenCL support work with JPype 0.7
JPype 0.7 introduced some breaking changes (https://github.com/jpype-project/jpype/issues/498). Among those that private class member cannot be accessed than easily from Python as it was before.
I fixed the arrising issues in core pyconrad by disabling JClass' __setattr__
in _extend_conrad_classes.py
__setattr = JClass.__setattr__
JClass.__setattr__ = type.__setattr__
_extend_pointnd()
_extend_simple_vector()
_extend_simple_matrix()
_extend_numeric_grid()
_extend_imageplus()
_extend_pyconrad_java()
if cl:
_extend_ocl_grids()
JClass.__setattr__ = __setattr
And accessing private members the Java way:
f_buffer.put(jpype.JClass('edu.stanford.rsl.conrad.data.numeric.Grid1D').class_.getDeclaredField('buffer').get(self.__grid))
instead of:
f_buffer.put(self.__grid.buffer)
The same has to be done for _extend_ocl_grids()
This Solution was suggested by JPype
Add lines to the module to enable the old property behavior. But this will not reenable the previous buggy access to private variables. Thus code that was exploiting the previous behavior which bypassed the getter/setter of java will need to use the reflection API.
To enable the property customizer, use
try:
import jpype.beans
except ImportError:
pass
Maybe related future feature of JPype: https://github.com/jpype-project/jpype/issues/420