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 )
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 )
- relates to
-
JDK-8154588 Error expected for declaring a 'clone' default method
-
- Open
-
-
JDK-8026394 Eclipse fails with JDK8 build 111
-
- Closed
-