You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.
I'm a Spoon contributor, an open source project to analyse and transform Java source code. This project have a dependency to JDT to compile target source code. Recently, I tried to analyse Guava with Spoon but JDT can't compile our project.
// If the map is an EnumMap, it must have key type K for some <K extends Enum<K>>.@SuppressWarnings({"unchecked", "rawtypes"})
privatestatic <K, V> ImmutableMap<K, V> copyOfEnumMapUnsafe(Map<? extendsK, ? extendsV> map) {
returncopyOfEnumMap((EnumMap) map);
}
privatestatic <KextendsEnum<K>, V> ImmutableMap<K, V> copyOfEnumMap(EnumMap<K, ? extendsV> original) {
EnumMap<K, V> copy = newEnumMap<K, V>(original);
for (Map.Entry<?, ?> entry : copy.entrySet()) {
checkEntryNotNull(entry.getKey(), entry.getValue());
}
returnImmutableEnumMap.asImmutable(copy);
}
This code is valid but there is an error from JDT:
Type mismatch: cannot convert from <Enum<Enum<K>>> to <K>
Before the creation of this issue, I reported the bug in the bugtracker of JDT (issue here). In 2 words, the conclusion was that: "Yes, JDT don't support this usage of Java but there is a better practice". This better practice is explained here:
I tried some tricky solutions but, unfortunately, this solution can't be applied in your project. So I come to notify you that your project can't be compiled by JDT.
The text was updated successfully, but these errors were encountered:
It seems that the bug is new in the Eclipse compiler since the introduction of support for Java 8. I'm guessing internal users who might have looked at this code with Eclipse aren't on a version with that support yet.
I'm a Spoon contributor, an open source project to analyse and transform Java source code. This project have a dependency to JDT to compile target source code. Recently, I tried to analyse Guava with Spoon but JDT can't compile our project.
What is the problem?
In
ImmutableMapclass, we have these methods:This code is valid but there is an error from JDT:
Before the creation of this issue, I reported the bug in the bugtracker of JDT (issue here). In 2 words, the conclusion was that: "Yes, JDT don't support this usage of Java but there is a better practice". This better practice is explained here:
I tried some tricky solutions but, unfortunately, this solution can't be applied in your project. So I come to notify you that your project can't be compiled by JDT.
The text was updated successfully, but these errors were encountered: