Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8004967

Default method cause java.lang.VerifyError: Illegal use of nonvirtual function call

XMLWordPrintable

    • b18
    • Not verified

        Extend an interface with default method, existing code using that interface build with -target 1.5 will cause throwing java.lang.VerifyError with "Illegal use of nonvirtual function call".

        Attached is a test case to illustrate the bug.

        Build TestInterface.java + MyInterface.java.1.5(rename to MyInterface.java) with
        $ cp MyInterface.java.1.5 MyInterface.java
        $ javac -source 1.5 -target 1.5 TestInterface.java
        $java TestInterface
        foo

        Now replace MyInterface with new version,

        $ cp MyInterface.java.1.8 MyInterface.java
        $ javac MyInterace.java
        $ java TestInterface
        Exception in thread "main" java.lang.VerifyError: (class: TestInterface$1, method: bar signature: ()V) Illegal use of nonvirtual function call
        at TestInterface.main(TestInterface.java:3)


        Note that build to target 1.6 works as expected.

          1. MyInterface.java.1.5
            0.0 kB
            Henry Jen
          2. MyInterface.java.1.8
            0.1 kB
            Henry Jen
          3. TestInterface.java
            0.2 kB
            Henry Jen

              bharadwaj Bharadwaj Yadavalli (Inactive)
              henryjen Henry Jen
              Votes:
              0 Vote for this issue
              Watchers:
              18 Start watching this issue

                Created:
                Updated:
                Resolved: