Skip to content

Static interface methods not recognized on type generics #4058

Closed as not planned

Description

@msohaill

Following is some sample code to replicate the issue:

public class Tester<T extends Thing> {
    public void test() {
        System.out.println("Testing: " + T.getStuff());  // Error is here
    }

    public static void main(String[] args) {
        Tester<OtherThing> tester = new Tester<>();
        tester.test();
    }

}

interface Thing {
    static String getStuff() {
        return "Stuff";
    }
}

class OtherThing implements Thing {
}

With this, I get a build error: The method getStuff() is undefined for the type T Java(67108964). However, enabling the "java.jdt.ls.javac.enabled" works, but is not an ideal solution.

This occurs with the latest Language Support for Java(TM) by Red Hat - v1.42.0.

Activity

  1. fbricon commented on Oct 24, 2025

    @fbricon
    Collaborator
  2. fbricon commented on Feb 12, 2026

    @fbricon
    Collaborator

    So this will not be fixed in ECJ:

    Actually, further investigation shows that ECJ behavior has been correct all along.

    See JLS 9.4.1 Inheritance and Overriding saying categorically An interface does not inherit private or static methods from its superinterfaces

    This would mean that ECJ behaviors is correct.

    Indeed there has been recently acknowledgment from OpenJDK side that this is a bug in javac.

    See

    mail.openjdk.org/pipermail/compiler-dev/2025-September/031579.html
    bugs.openjdk.org/browse/JDK-8365676
    bugs.openjdk.org/browse/JDK-6644562

    Now you can either keep the javac compilation turned on, or change the code to be compliant with the Java spec.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions