Community
Participate
Working Groups
Using java 8 and aspectj 1.8.0 it's not possible to compile implementations of Comparator: private static class KeyValueValueComparator<K, V> implements Comparator<KeyValue<K, V>> { public int compare(KeyValue<K, V> o1, KeyValue<K, V> o2) { .... } } results in error mentioning thenComparing() (default interface method) not implemented (thus defying the purpose of default interface methods introducted in java 8) [ERROR] /mnt/mint/home/denny/proj/epom/epom-common/src/main/java/com/epom/commons/CollectionUtils.java:68:0::0 The type CollectionUtils.KeyValueValueComparator<K,V> must implement the inherited abstract method Comparator<KeyValue<K,V>>.thenComparing(Function<? super KeyValue<K,V>,? extends U>, Comparator<? super U>) [ERROR] error at private static class KeyValueValueComparator<K, V> implements Comparator<KeyValue<K, V>> { [ERROR] ^^^^^^^^^^^^^^^^^^
Are you passing the -1.8 flag in when building code (or -source 1.8 or whatever) - or are you compiling with 1.7 compliance against a 1.8 JRE. The latter is a known limitation of JDT right now that has only recently been addressed (so the fix is not in AspectJ yet).
thanks, specifying 1.8 as source and target levels fixed the problem So it's just currently impossible to compile against 1.8 JDK old projects written for java 7 - that's also a bug but a much lesser one
Glad you are working now. > So it's just currently impossible to compile against 1.8 JDK old projects written for java 7 - that's also a bug but a much lesser one Strictly speaking it isn't a bug - as it is never recommended to compile your source against a JDK beyond the compliance level you are using. It just hasn't manifested this badly before with other java versions because default methods are quite a big change. javac allows it and after some discussion Eclipse JDT finally does too, so I expect AspectJ 1.8.1 will as well.
Eclipse JDT now supports this way of working. It will cope with default methods when passing -1.7 as the source level. The latest AspectJ 1.8.1 dev builds include the fix.