Enhancing Remote Method Invocation through Type-Based Static Analysis