JDK-8364144 : Multiple type bounds cause a compilation error
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 22,24
  • Priority: P4
  • Status: Open
  • Resolution: Unresolved
  • Submitted: 2025-07-26
  • Updated: 2025-08-18
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
tbdUnresolved
Related Reports
Blocks :  
Description
From the mailing list: https://mail.openjdk.org/pipermail/compiler-dev/2025-July/031126.html

Initially reported in the Eclipse compiler since ECJ accepts code that
javac does not: https://github.com/eclipse-jdt/eclipse.jdt.core/issues/4226.
The current assessment is that the fault is with javac.

Copying the example from there:

```
interface Culprit {}

class EntityInfo<E extends NumberGenerator<?> & Culprit> {}

class NumberGenerator<N extends Number> implements NumberSupplier<N> {

@Override
    public N getNumber() {
        return null;
    }
}

interface NumberSupplier<N extends Number>  {

    N getNumber();
}
```

javac fails with:
```
error: getNumber() in NumberGenerator cannot implement getNumber() in
NumberSupplier
class EntityInfo<E extends NumberGenerator<?> & Culprit> {}
                 ^
  return type CAP#1 is not compatible with CAP#2
  where N#1,N#2 are type-variables:
    N#1 extends Number declared in class NumberGenerator
    N#2 extends Number declared in interface NumberSupplier
  where CAP#1,CAP#2 are fresh type-variables:
    CAP#1 extends Number from capture of ?
    CAP#2 extends Number from capture of ?
1 error
```

Removing the Culprit bound:
class EntityInfo<E extends NumberGenerator<?>> {}

satisfies javac.

Also noted that combining the supertypes explicitly is accepted:
```
class X<T extends Number> extends NumberGenerator<T> implements Culprit {
}

class EI2<E extends X<?>> {}
```