Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inconsitent generics infererence between ECJ and the JDK compiler #366

Open
alienisty opened this issue Sep 4, 2022 · 2 comments
Open
Labels
compiler Eclipse Java Compiler (ecj) related issues javac ecj not compatible with javac

Comments

@alienisty
Copy link

There is a case where the JDK successfully infers the generics where the eclipse compiler emits an error.
I'm using Adoptium JDK 11.0.13+8 and eclipse 4.22.
The following file is the simplest reproduction of the problem I was able to muster:

public class A {
  Collection<S<? extends X>> values() { return List.of(); }
  void handle() { problemsWith(values()); } // eclipse complains here
  void problemsWith(Collection<S<?>> values) {}
}

class S<T extends Y> {}

class X {}

class Y extends X {}

I've also tried to compile the same with Adoptium JDK 17.0.2+8 and the class still compiled fine.
I'm not sure on which side is the bug though.

@stephan-herrmann
Copy link
Contributor

Yeah, we never settled with Oracle over the exact inference rules when wild cards are involved. They acknowledged that javac does more than what's written in JLS, but we never succeeded to agree on what a compiler really should do. My guess is that first JLS needs to be improved before we could possibly make progress.

Previous discussions:

@trancexpress trancexpress added the compiler Eclipse Java Compiler (ecj) related issues label Apr 3, 2023
@trancexpress
Copy link
Contributor

See also #837.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler Eclipse Java Compiler (ecj) related issues javac ecj not compatible with javac
Projects
None yet
Development

No branches or pull requests

4 participants