Title: VerifyError when implementing Interface containing default methods (Java 8)
Type: behaviour Severity: normal
Components: Core Versions: Jython 2.7, Jython 2.5
Milestone: Jython 2.7.2
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: alexgobbo, amoebam, darjus, hendrik, jamesmudd, jeff.allen, zyasoft
Priority: Keywords:

Created on 2015-09-23.15:07:19 by alexgobbo, last changed 2018-11-04.16:23:32 by jeff.allen.

msg10283 (view) Author: A. Gobbo (alexgobbo) Date: 2015-09-23.15:07:19
Systematically an exception pops up when declaring a Python class implementing a Java interface containing default methods, even if all methods are overriden:
-  java.lang.VerifyError... Illegal use of nonvirtual function call in at line number ...

Workaround: start JVM with option Xverify:none
msg10312 (view) Author: Darjus Loktevic (darjus) Date: 2015-10-07.09:35:17
Can you provide more details? Java version, code you're executing, ideally repro example.

msg10352 (view) Author: A. Gobbo (alexgobbo) Date: 2015-10-12.08:32:52
Below an example - I use Jython 2.7.0. Java 1.8.0_11 and Java 1.8.0_51. The exception throws a VerifyError when declaring the class "MyClass" overriding get().

package test;

import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;

public class Test {

    public static interface TestInterface {

        default String get() {
            return "Unknown";

    public static class TestClass implements TestInterface {

        public String get() {
            return "Value";

    public static void main(String[] args) throws Exception {
        ScriptEngine engine = new ScriptEngineManager().getEngineByName("python");

        engine.eval("import test.Test.TestClass");
        engine.eval("o = test.Test.TestClass()");
        engine.eval("print o.get()"); //This is ok

        engine.eval("import test.Test.TestInterface");
        engine.eval("class MyClass(test.Test.TestInterface):\n"
                + "   def get(self):\n"
                + "       return 'value'");
        engine.eval("o = MyClass()");
        engine.eval("print o.get()");

msg11605 (view) Author: Andy Merton (amoebam) Date: 2017-09-27.22:04:22
The problem specifically occurs when a default method is overridden.

This appears to be caused by the use of v1.5 class files when generating code.  Updating "Opcodes.V1_5" in org.python.compiler.ClassFile to any newer version -- even just V1_6! -- seems to work, at least for a toy example.
msg11613 (view) Author: James Mudd (jamesmudd) Date: 2017-10-02.20:55:58
Thanks for the tip about Opcodes I have investigated this slightly and have a pull request to discuss this

Switching from Opcodes.V1_5 to Opcodes.V1_6 does appear to resolve this issue, i'm not really sure why though. I have added a test for this in the pull request unfortunately I don't think it can be merged as it would require a source level of 1.8

Increasing to Opcodes higher than 1.6 cause things to break.
msg11676 (view) Author: James Mudd (jamesmudd) Date: 2017-11-22.19:40:28
I would like to see this one make it into 2.7.2
msg11694 (view) Author: Jeff Allen (jeff.allen) Date: 2018-01-03.17:39:06
Now committed at, which makes Alex's program run for me. Thanks Alex, Darjus, Andy, and James.
Date User Action Args
2018-11-04 16:23:32jeff.allensetstatus: pending -> closed
2018-01-03 17:39:07jeff.allensetstatus: open -> pending
resolution: remind -> fixed
messages: + msg11694
nosy: + jeff.allen
2017-11-22 19:40:28jamesmuddsetmessages: + msg11676
2017-10-02 20:56:00jamesmuddsetnosy: + jamesmudd
messages: + msg11613
2017-09-27 22:04:22amoebamsetmessages: + msg11605
2017-09-25 03:37:34zyasoftsetresolution: remind
2016-09-06 05:18:32zyasoftsetmilestone: Jython 2.7.2
2016-07-29 20:49:14amoebamsetnosy: + amoebam
2016-05-11 11:17:50hendriksetnosy: + hendrik
2015-10-12 08:32:53alexgobbosetmessages: + msg10352
2015-10-07 09:35:17darjussetnosy: + darjus
messages: + msg10312
2015-09-23 21:24:54zyasoftsetnosy: + zyasoft
2015-09-23 15:07:19alexgobbocreate