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

Eclipse 2026-03 compiles fine but Java does not: unchecked conversion

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

Description

I just discovered this in a broken build today.

```
Eclipse IDE for Eclipse Committers (includes Incubating components)

Version: 2026-03 (4.39.0)
Build id: 20260305-0817

```
## Reproducer

Compiles fine in Eclipse 2026-03:

```java
import java.util.Comparator;
import java.util.Map;

public class Snippet {

public static void main(String[] args) {

Comparator> eventComparator = Comparator
., Comparable>comparing(e -> (Comparable) e.get("event_date"),
Comparator.nullsLast(Comparator.naturalOrder()))
.thenComparing(e -> (String) e.get("event_type"));
}

}

```

**but Fails in Java:**

```
java --version
openjdk 21.0.7 2025-04-15 LTS
OpenJDK Runtime Environment Temurin-21.0.7+6 (build 21.0.7+6-LTS)
OpenJDK 64-Bit Server VM Temurin-21.0.7+6 (build 21.0.7+6-LTS, mixed mode, sharing)

java -Duser.language=en Snippet.java

Snippet.java:12: warning: [unchecked] unchecked method invocation: method nullsLast in interface Comparator is applied to given types
Comparator.nullsLast(Comparator.naturalOrder()))
^
required: Comparator
found: Comparator
where T is a type-variable:
T extends Object declared in method nullsLast(Comparator)
Snippet.java:11: warning: [unchecked] unchecked method invocation: method comparing in interface Comparator is applied to given types
., Comparable>comparing(e -> (Comparable) e.get("event_date"),
^
required: Function,Comparator
found: Function,Comparable>,Comparator
where T,U are type-variables:
T extends Object declared in method comparing(Function,Comparator)
U extends Object declared in method comparing(Function,Comparator)
Snippet.java:12: warning: [unchecked] unchecked conversion
Comparator.nullsLast(Comparator.naturalOrder()))
^
required: Comparator
found: Comparator
where U,T are type-variables:
U extends Object declared in method comparing(Function,Comparator)
T extends Object declared in method comparing(Function,Comparator)
Snippet.java:13: warning: [unchecked] unchecked call to thenComparing(Function) as a member of the raw type Comparator
.thenComparing(e -> (String) e.get("event_type"));
^
where U,T are type-variables:
U extends Comparable declared in method thenComparing(Function)
T extends Object declared in interface Comparator
Snippet.java:13: error: cannot find symbol
.thenComparing(e -> (String) e.get("event_type"));
^
symbol: method get(String)
location: variable e of type Object
Snippet.java:13: warning: [unchecked] unchecked conversion
.thenComparing(e -> (String) e.get("event_type"));
^
required: Comparator>
found: Comparator
1 error
5 warnings
error: compilation failed
```

## Fix

If I rewrite it to something like this, then it compiles in Eclipse and also in Java:

```java
import java.util.Comparator;
import java.util.Map;

public class Snippet {

public static void main(String[] args) {

Comparator nullableComparableObjectComparator = Comparator.nullsLast((a,
b) -> ((Comparable) a).compareTo(b));

Comparator> eventComparator = Comparator
.comparing((Map e) -> e.get("event_date"),
nullableComparableObjectComparator)
.thenComparing((Map e) -> (String) e.get("event_type"),
Comparator.nullsLast(String::compareTo));
}

}
```

```
java -Duser.language=en Snippet.java
Snippet.java:11: warning: [unchecked] unchecked cast
b) -> ((Comparable) a).compareTo(b));
^
required: Comparable
found: Object
1 warning
```

## Settings

JRE: points to a `jdk-21.0.7+6/Contents/Home`

Image

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.