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

Resolution fails for default method named 'clone'

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P3
    • Resolution: Fixed
    • Affects Version/s: 8u60, 9
    • Fix Version/s: 11
    • Component/s: hotspot
    • Labels:
      None
    • Subcomponent:
    • Resolved In Build:
      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

              Assignee:
              hseigel Harold Seigel
              Reporter:
              dlsmith Dan Smith
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: