CodeQL documentation

Interface cannot be implemented

ID: java/unimplementable-interface
Kind: problem
Security severity: 
Severity: warning
Precision: very-high
   - maintainability
   - useless-code
Query suites:
   - java-security-and-quality.qls

Click to see the query in the CodeQL repository

An interface that contains methods whose return types clash with protected methods on java.lang.Object can never be implemented, because methods cannot be overloaded based simply on their return type.


If the interface is useful, name methods so that they do not clash with methods in Object. Otherwise you should delete the interface.


In the following example, the interface I is useless because the clone method must return type java.lang.Object:

interface I {
    int clone();

class C implements I {
    public int clone() {
        return 23;

Any attempt to implement the interface produces an error: clone() in C cannot override
  clone() in java.lang.Object; attempting to use incompatible return
found   : int
required: java.lang.Object
  public int clone() {
1 error


  • © GitHub, Inc.
  • Terms
  • Privacy