Community
Participate
Working Groups
The following code (requires guava 18.0) shows a compile error "The method closed(C, C) in the type Range is not applicable for the arguments (Entity, Entity)" When upgrading to Photon. This happens in other situations too when mixing raw and generic types. The code compiles just fine outside of Eclipse via the Java compiler (tried with both IBM and Oracle JDKs) as well as in Eclipse Oxygen. example #1 (error): public final class Entity implements Comparable { private int index = 1; public Entity(int index) { this.index = index; } public int compareTo(Object o) { return index; } } import com.google.common.collect.Range; public class Test { public static void main(String[] args) { Entity d1 = new Entity(1); Entity d2 = new Entity(2); Range<Entity> r = Range.closed(d1, d2); } } This only happens if you don't specify an argument type for the Comparable generic interface in the Entity class. example #2 (no error): public final class Entity implements Comparable<Entity> { private int index = 1; public Entity(int index) { this.index = index; } public int compareTo(Entity o) { return index; } } import com.google.common.collect.Range; public class Test { public static void main(String[] args) { Entity d1 = new Entity(1); Entity d2 = new Entity(2); Range<Entity> r = Range.closed(d1, d2); } } Interestingly if you declare the Entity class as a static inner class within the main class where it's used, then the error disappears ! example #3 (no error) public class Test { public static void main(String[] args) { Entity d1 = new Entity(1); Entity d2 = new Entity(2); Range<Entity> r = Range.closed(d1, d2); } public static final class Entity implements Comparable { private int index = 1; public Entity(int index) { this.index = index; } public int compareTo(Object o) { return index; } } }
This issue is considered critical as it means a no-go for us because the non-generic interfaces we use are coming from a 3rd party library (joda-time 1.6.2) and we cannot afford to upgrade at the moment.
This is caused by commit ec76c89defa5f96571519ef98af5fe717abfdb09 for bug 528970. Unfortunately that is about an underspecified area in the JLS and it is unclear what javac is doing.
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant. -- The automated Eclipse Genie.