### Question:
DefaultMethodCall implements Implementation { public static Implementation prioritize(Class<?>... prioritizedInterface) { return prioritize(new TypeList.ForLoadedTypes(prioritizedInterface)); } protected  DefaultMethodCall(List<TypeDescription> prioritizedInterfaces); static Implementation prioritize(Class<?>... prioritizedInterface); static Implementation prioritize(Iterable<? extends Class<?>> prioritizedInterfaces); static Implementation prioritize(TypeDescription... prioritizedInterface); static Implementation prioritize(Collection<? extends TypeDescription> prioritizedInterfaces); static Implementation unambiguousOnly(); InstrumentedType prepare(InstrumentedType instrumentedType); ByteCodeAppender appender(Target implementationTarget);  }### Answer:
@Test(expected = IllegalStateException.class) @JavaVersionRule.Enforce(8) public void testUnrelatedPreferredDefaultMethodThrowsException() throws Exception { new ByteBuddy() .subclass(Object.class) .implement(Class.forName(SINGLE_DEFAULT_METHOD), Class.forName(CONFLICTING_INTERFACE)) .intercept(DefaultMethodCall.prioritize(Class.forName(NON_OVERRIDING_INTERFACE))) .make(); }
@Test(expected = IllegalStateException.class) @JavaVersionRule.Enforce(8) public void testNonDeclaredPreferredDefaultMethodThrowsException() throws Exception { new ByteBuddy() .subclass(Class.forName(SINGLE_DEFAULT_METHOD_CLASS)) .method(not(isDeclaredBy(Object.class))) .intercept(DefaultMethodCall.prioritize(Class.forName(SINGLE_DEFAULT_METHOD))) .make(); }
@Test @JavaVersionRule.Enforce(8) public void testDeclaredAndImplementedAmbiguousMethodWithPreference() throws Exception { DynamicType.Loaded<?> loaded = new ByteBuddy() .subclass(Class.forName(SINGLE_DEFAULT_METHOD_CLASS)) .implement(Class.forName(SINGLE_DEFAULT_METHOD), Class.forName(CONFLICTING_INTERFACE)) .method(not(isDeclaredBy(Object.class))) .intercept(DefaultMethodCall.prioritize(Class.forName(SINGLE_DEFAULT_METHOD))) .make() .load(getClass().getClassLoader(), ClassLoadingStrategy.Default.WRAPPER); assertThat(loaded.getLoaded().getDeclaredMethods().length, is(1)); Method method = loaded.getLoaded().getDeclaredMethod(FOO); Object instance = loaded.getLoaded().getDeclaredConstructor().newInstance(); assertThat(method.invoke(instance), is((Object) FOO)); }