eclipse-jdt / eclipse-jdt/eclipse.jdt.core

Bindings fail with JLS 21 but they worked with JLS 11

Open
#4,492 10 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
237
Forks
195
Avg merge
1d 12h
Merged PRs (30d)
47

Description

We have been using Eclipse JDT for parsing and binding resolution for Java programs.

We were previously using JLS 11, and have moved to JLS 21 recently.

While we see the improvement in parsing otherwise, some improved Java features are not supported.

For example, we are previously able to resolve the binding for this

```java
Pair entry = new Pair<>("A", 1);
```

But after the update, we are not able to resolve the binding anymore. We get `null` for the binding.

Note, if we change the above code to this, we get the binding again.

```java
Pair entry = new Pair("A", 1);
```

Here is how we are calling this.

```
ITypeBinding instantiatedClassBinding = classInstanceCreation.resolveTypeBinding();
```

We also get `null` for the `resolveMethodBinding()` call.

This (no parameter in a constructor for a parameterized type) is an improved feature of Java that is pretty common. It will be great if the binding is supported for such cases.

Do we need to change anything to get the correct binding?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.