We started with one jar with one class with one method like:
boolean foo( int bar ) { ... }
However, the result of this method was useless (in fact, always true) and clients that used this result for anything fails in an error. For this reason, method was changed to:
void foo( int bar ) { ... }
and all items recompiled. Thus, we can assume all users of this jar calls the method as:
foo(14);
none uses the form (and is out of scope for this question if there are someone):
boolean x = foo(14);
Assume none client, new or older, uses the boolean result.
The problem was when, in target systems, the new jar is loaded without upgrading the clients. Not updated clients fails with an exception "NoSuchMethod" when looking for the "foo" method with result "boolean". That is:
- client has an statment like "foo(14);" without usage of the method result
- client is compiled using the jar with boolean method.
- client and library is loaded in target system
- library is updated with new jar with void method
- client crashes with "NoSuchMethod"
The origin of the problem seems to be that both, Java and C/C++ doesn't allows two methods that differs only in result, but only Java "name mangling" includes the result type in the name that class loader (linker in C/C++) is looking for.
The question is: it is possible to trick in any way the library jar or the class loader to skip "NoSuchMethod" exception in this scenario?