eclipse-jdt / eclipse-jdt/eclipse.jdt.core
Align type inference with JDK-8386318
- Dominant language
- Java
- Stars
- 237
- Forks
- 195
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 47
Description
In https://bugs.openjdk.org/browse/JDK-8386318 a regression since JDK 9+80 is reported and being fixed:
```java
class Pair{
A left;
B right;
static Pair change(Pair a){ return a;}
static Pair left(Pair p){return p;}
public static void main(String[] args){
Pair p1 = new Pair();
p1.left = "1";
p1.right = 2;
Pair p = change(left(p1));
p.right = p.left;
System.out.println(p1.right + p1.right);
}
}
```
This is accepted by javac >= 9+80 as well as ecj.
When run, the program throws:
```
Exception in thread "main" java.lang.ClassCastException: class java.lang.String cannot be cast to class java.lang.Integer (java.lang.String and java.lang.Integer are in module java.base of loader 'bootstrap')
at Pair.main(Pair.java:13)
```
If the fix is released to javac 28, we should try to fix this in BETA_JAVA28.
Contributor guide
Assessment
This issue has not been assessed yet.