Bug 433658 - forces implementing default methods in interfaces
Summary: forces implementing default methods in interfaces
Status: RESOLVED FIXED
Alias: None
Product: AspectJ
Classification: Tools
Component: Compiler (show other bugs)
Version: 1.8.0   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: 1.8.1   Edit
Assignee: aspectj inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-04-28 09:44 EDT by Andriy Denysenko CLA
Modified: 2014-06-17 17:26 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andriy Denysenko CLA 2014-04-28 09:44:03 EDT
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] ^^^^^^^^^^^^^^^^^^
Comment 1 Andrew Clement CLA 2014-04-28 11:30:55 EDT
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).
Comment 2 Andriy Denysenko CLA 2014-04-28 12:53:00 EDT
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
Comment 3 Andrew Clement CLA 2014-04-28 13:25:58 EDT
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.
Comment 4 Andrew Clement CLA 2014-06-17 17:26:39 EDT
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.