X-Git-Url: http://plrg.eecs.uci.edu/git/?p=jpf-core.git;a=blobdiff_plain;f=src%2Ftests%2Fjava8%2FDefaultMethodTest.java;h=70f00b257a949d83cbdef70d5c2e6416b4529561;hp=d1c897717634bc97bc2270468e1e1d97e8366127;hb=d0a18eb873b7a2c18a61d0a6207e00cf04d50f44;hpb=97aa2f798ce7173f778234427b9b840f5886296d diff --git a/src/tests/java8/DefaultMethodTest.java b/src/tests/java8/DefaultMethodTest.java index d1c8977..70f00b2 100644 --- a/src/tests/java8/DefaultMethodTest.java +++ b/src/tests/java8/DefaultMethodTest.java @@ -140,7 +140,63 @@ public class DefaultMethodTest extends TestJPF { o.bar(); } } + // -- most specific implementations + + public static interface Intf1 { + default int getInt() { + return 4; + } + } + + public static interface Intf2 extends Intf1 { + @Override + default int getInt() { + return 3; + } + } + public static abstract class A implements Intf1 { + + } + + public static class B extends A implements Intf2 { + } + + @Test + public void testMostSpecificImplementationResolution() { + if(verifyNoPropertyViolation()) { + B b = new B(); + int x = b.getInt(); + assertEquals(x, 3); + } + } + // --- inherited default methods + + interface SuperIntf { + default String getString() { + return "Hello World"; + } + } + + interface SubIntf extends SuperIntf { + default int getZero() { + return 0; + } + } + + public class ConcreteClass implements SubIntf { + + } + + @Test + public void testInheritedDefaultMethod() { + if(verifyNoPropertyViolation()) { + ConcreteClass cls = new ConcreteClass(); + assertEquals(cls.getString(), "Hello World"); + } + } + // <2do> how to test IncompatibleClassChangeError without explicit classfile restore? } +