Java序列化方法 [英] Java Serializing Methods

查看:90
本文介绍了Java序列化方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可以序列化方法吗?因为当我查看文档时,Method类不实现Serializable。那么还有其他选择吗?

解决方案

由于Method没有实现Serializable,因此无法使用标准Java Serialization API对其进行序列化。 / p>

解决方法是手动序列化类和方法的名称及其参数类型。然后,您可以在反序列化期间重新创建Method实例。


It is possible to serialize a method? Because when I look at the documentation the Method class does not implements Serializable. So are there any alternatives?

解决方案

Since Method does not implement Serializable, it cannot be serialized using the standard Java Serialization API.

A workaround would be to manually serialize just the name of the class and method and its parameter types. You can then recreate the Method instance during deserialization.

这篇关于Java序列化方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆