I need to pass java.lang.reflect.Field from one process to another using RMI, but Field does not implement Serializable interface. how can I overcome this problem?
I need to pass java.lang.reflect.Field from one process to another using RMI, but Field
Share
It doesn’t make sense to pass a Field via RMI. A Field instance is really a dependent object of a
java.lang.Classinstance, andClassobjects are not transmissible either. (And the reason that aClassis not transmissible is that it would present all sorts of nasty type checking problems … considering that aClassinstance actually denotes a reference type.)You will need to declare the relevant
Fieldfield astransient. If you want to transmit theFieldinformation, you are probably going to need to pass it in the form of a field name / class name, and then reconstruct theFieldat the other end in a customreadObjectmethod.