Reputation: 8670
In a program I am using two external jar libraries.
There is a class in the external library X
invoking a method m
of a class in the library Y
. The library X
was compiled with version 1.0 of library Y
. However, since I am using library Y
for other purposes in my code, I preferred to use its last version (let's say 5.0).
My problem is that when I execute the code, library X
complains that the method m
is not there anymore (throwing a NoSuchMethod error). However, the method is there.
The problem could be related to the fact that I am using a newer version of the library Y
than the one that was present at compilation time ? (although backward compatible, with different bytecode?). If that is the case then I will be a bit puzzled since I thought that java method calls were expressed in byte code as symbolic references (e.g., method signatures), and not as direct references (e.g., offsets), but I could have misunderstood something.
Thanks for any clarification !
Upvotes: 0
Views: 85
Reputation: 14810
The method name that X
is calling may still exist in jar Y
but perhaps the method signature has changed -- that is, the number or the types of arguments may have changed.
Upvotes: 1
Reputation: 183446
[...] I thought that java method calls were expressed in byte code as symbolic references (e.g., method signatures), and not as direct references (e.g., offsets) [...]
You thought correctly; but it's possible that the method in Y
v5.0 has a different signature from the method in Y
v1.0, even if they have the same name; for example, it might have a different number of arguments now, or different types of arguments, or it might have become static
or non-static
.
Upvotes: 3