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

Resolution fails for default method named 'clone'

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P3
    • 11
    • 8u60, 9
    • hotspot
    • None
    • b01

    Description

      If I compile* the following with javac and run, I get a NoSuchMethodError. Expect it to run without error.

      public class DefaultClone {
        interface I1 {
          default Object clone() { return this; }
        }

        interface I2 extends I1 { }
        
        static class C implements I2 {
          public Object clone() { return this; }
        }

        static void test(I2 i) { i.clone(); }

        public static void main(String[] args) {
          test(new C());
        }
      }

      *Separately, the I1 declaration shouldn't compile at all -- see linked issue. So producing a future-proof test will require some non-Java bytecode generation.

      (Originally reported here: https://twitter.com/lrytz/status/722512917485195270 )

      Attachments

        Issue Links

          Activity

            People

              hseigel Harold Seigel (Inactive)
              dlsmith Dan Smith
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: