Evolving interfaces: source/binary compatibility issues

Gernot Neppert mcnepp02 at googlemail.com
Fri Nov 23 07:23:03 PST 2012


Hi all,

when I browsed the Java 8 docs and found that java.util.List finally has 
a method "void sort(Comparator<? super E> comparator)",
I was quite happy at first.
Unfortunately, that bliss lasted only until I found that one of my own 
implementations of java.util.List already has such a method - albeit 
"protected".
This has at least two consequences:

1. I can't compile my old code against the JDK 8, since it tries to 
implement an interface method with weaker access privileges.

2. Even worse: if I link my old compiled code against a JDK 8, it may 
raise an "java.lang.IllegalAccessError" at Runtime, since code from the 
new codebase may innociously call back my "sort" method via the interface.

Here are some other methods that are likely to cause trouble, because 
they are obvious extensions likely to be already present in user-code:

java.util.Comparator.reverse()

java.util.Collection.addAll(Iterable)

Do you consider this a real danger or does it seem esoteric?









More information about the lambda-dev mailing list