Build/compilation issue with wildcard types
Following is some sample code to replicate the issue:
import java.util.List;
public class Tester {
<T extends List<? extends Entry<?, ?>>> Entry<?, ?> test(T input) {
return ConcreteEntry.from(input.get(0)); // Error here
}
public static void main(String[] args) {
Tester tester = new Tester();
System.out.println(tester.test(List.of(new ConcreteEntry<>("a", 1))));
}
}
interface Entry<K, V> {
K getKey();
V getValue();
}
class ConcreteEntry<K, V> implements Entry<K, V> {
private final K key;
private final V value;
public ConcreteEntry(K key, V value) {
this.key = key;
this.value = value;
}
public static <K, V> ConcreteEntry<K, V> from(Entry<K, V> entry) {
return new ConcreteEntry<>(entry.getKey(), entry.getValue());
}
@Override
public K getKey() {
return key;
}
@Override
public V getValue() {
return value;
}
@Override
public String toString() {
return this.key + "=" + this.value;
}
}
The test method throws the error The method from(Entry<K,V>) in the type ConcreteEntry is not applicable for the arguments (capture#1-of ? extends Entry<?,?>) Java(67108979). The expected behaviour is correct compilation. However, enabling the "java.jdt.ls.javac.enabled" works, but is not an ideal solution.
This occurs with the latest Language Support for Java(TM) by Red Hat - v1.42.0.
same as https://github.com/redhat-developer/vscode-java/issues/4053
same as #4053
Strangely enough, I still get the issue when downgrading to v1.41.1. Perhaps it is an issue with the Eclipse Language Tools? Not sure if there's a pinned version or anything
Looks like this was resolved recently according to https://github.com/redhat-developer/vscode-java/issues/4053#issuecomment-2990424063 ? It may have been an upstream bug that was fixed there. @msohaill can you confirm if this is resolved in the pre-release stream ?
Hi @rgrunber! It seems I still get the issue with v1.43.2025062508. The error message remains the same. Let me know if you would require any more information!
Morning, also seeing a similar issue with versions of the extension post v1.41.1 including the current latest pre-release version: -
[email protected]
Looking thorugh the linked issues / PRs, to check whether there's anything else about my environment ( macOS, VSCode, JDK etc. ) that's relevant ...
Just got a new update on the pre-release channel: -
code --list-extensions --show-versions | grep redhat.java
[email protected]
alas the same problem 😿
I tried with 1.32.0 and still see the errors there as well, so likely this isn't something to recently regress. Seems similar to https://github.com/redhat-developer/vscode-java/issues/3688 . This is looking like some kind of longer term limitation of ECJ compilation vs. Javac. See https://github.com/eclipse-jdt/eclipse.jdt.core/issues/1053, https://github.com/eclipse-jdt/eclipse.jdt.core/issues/366 .