Skip to content

Cannot override default methods of indirect superinterfaces in Java 25. #400

@alexgobbo

Description

@alexgobbo

Up to Java 24 we can override default members of both direct and indirect superinterfaces.

As example, these classes in Java:

 public interface A {
   default String getValue() {
       return "1";
   }
 } 
 public interface B extends A {
 }

Can be extended in Jython:

 class X(A):
      def getValue(self):        
           return "2"
 class Y(B):
      def getValue(self):        
           return "3"

In Java 25 the JVM allows invokespecial on a default method only if that interface is a direct superinterface.

Therefore the class X above works, but when I try to evaluate class Y I get:
java.lang.VerifyError: Bad invokespecial instruction: interface method to invoke is not in a direct superinterface.

As a workaround, I can inherit the base interface explicitly too:

 class Y(B, A):
      def getValue(self):        
           return "3"

But a proper fix in Jython would be greatly appreciated.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions