我正在尝试通过将 Python 对象发送到 Java来扩展本教程中的示例。虽然在 Python 和 Java 之间交换字符串对象的示例代码工作正常,但当我尝试用我自己的 Python 对象(事件)替换它时,会显示有关 object_id 的错误。
蟒蛇代码:
class Event(object):
#some content here
stack = gateway.entry_point.getStack()
event = Event()
stack.push(event)
错误:
Traceback (most recent call last):
File "/home/******/src/py4jSample.py", line 19, in <module>
stack.push(event)
File "/usr/local/lib/python2.7/dist-packages/py4j-0.7-py2.7.egg/py4j/java_gateway.py", line 423, in __call__
[get_command_part(arg, self.pool) for arg in new_args])
File "/usr/local/lib/python2.7/dist-packages/py4j-0.7-py2.7.egg/py4j/protocol.py", line 241, in get_command_part
command_part = REFERENCE_TYPE + parameter._get_object_id()
AttributeError: 'Event' object has no attribute '_get_object_id'
知道如何解决这个问题吗?