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

incorrect method resolution failure with default method overriding `clone`

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P3
    • Resolution: Duplicate
    • Affects Version/s: 8, 9
    • Fix Version/s: None
    • Component/s: tools
    • CPU:
      x86_64
    • OS:
      generic

      Description

      FULL PRODUCT VERSION :
      java version "1.8.0_77"
      Java(TM) SE Runtime Environment (build 1.8.0_77-b03)
      Java HotSpot(TM) 64-Bit Server VM (build 25.77-b03, mixed mode)

      FULL OS VERSION :
      Darwin lucmac 15.4.0 Darwin Kernel Version 15.4.0: Fri Feb 26 22:08:05 PST 2016; root:xnu-3248.40.184~3/RELEASE_X86_64 x86_64

      A DESCRIPTION OF THE PROBLEM :
      Interface method resolution fails to find a `clone` method in a parent interface. details in https://gist.github.com/lrytz/6f1451031b09381eb872acd031b00b0b

      THE PROBLEM WAS REPRODUCIBLE WITH -Xint FLAG: Yes

      THE PROBLEM WAS REPRODUCIBLE WITH -server FLAG: Yes

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      See https://gist.github.com/lrytz/6f1451031b09381eb872acd031b00b0b

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      No crash
      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      Exception in thread "main" java.lang.NoSuchMethodError: A$I2.clone()Ljava/lang/Object;
      at A.f(A.java:12)
      at A.main(A.java:15)


      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      public class A {
        public interface I1 {
          default Object clone() { return "hi"; }
        }

        public interface I2 extends I1 { }

        public static class K implements I2 {
          public Object clone() { return "Ka"; }
        }

        public static void f(I2 i) { System.out.println(i.clone()); }

        public static void main(String[] args) {
          f(new K());
        }
      }

      ---------- END SOURCE ----------

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              mcimadamore Maurizio Cimadamore
              Reporter:
              webbuggrp Webbug Group
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: