Javac incorrectly claims that class is abstract

Vicente Romero vicente.romero at oracle.com
Tue Jul 8 14:36:37 UTC 2025


Hi Michael,

Thanks again for the issue you reported. It has been fixed in JDK 26,

Vicente

On 6/28/25 11:50, Michael Strauß wrote:
> The following program produces a compiler error on 24.0.1:
>
> abstract class Base<T> {}
> abstract class Derived1<T> extends Base<T> {}
> abstract class Derived2<T> extends Base<T> {
>      Derived2(Derived1<T> obj) {}
> }
>
> Base<String> obj = new Derived2<>(
>      new Derived1<>() {
>          // not abstract
>      }) {
>          // not abstract
>      };
>
> --> error: Derived1 is abstract; cannot be instantiated
>
>
> However, when I explicitly specify the inferred type argument in
> either Derived1<String> or Derived2<String>, the program compiles:
>
> Base<String> obj = new Derived2<String>(
>      new Derived1<>() {
>          // not abstract
>      }) {
>          // not abstract
>      };
>
> --> OK



More information about the compiler-dev mailing list