I'm working on a project where I have two programs which need to invoke methods on some of each other's objects.
I do this by sending JSON objects over a TCP connection. These objects have a receiverID, methodName, and then a list of parameters. Each program has a HashMap from receiverIDs to actual object instances, and then I use reflection to invoke the method with the supplied methodName on the correct object instance.
This works, but it forces the methods that get called remotely to have an array of strings as their parameter. Then I have to look at the order that the parameters are packed into the array and read through it on the other end to parse each parameter into what the actual parameters of the method are.
This definitely doesn't feel like a very clean way to accomplish my goal, but I'm not sure how else to do it. I suppose I could mark each parameter with a type and then cast them based on the type, but I would have to add code for each new type of parameter that I want to pass.