WebServiceImplValidator { public void validate() { if (!serviceInterface.isInstance(service)) throw new Error(format("service must impl service interface, serviceInterface={}, instance={}", serviceInterface.getCanonicalName(), service)); Class<?> serviceClass = service.getClass(); if (!Object.class.equals(serviceClass.getSuperclass())) { throw new Error("service impl class must not have super class, class=" + serviceClass.getCanonicalName()); } for (Method method : serviceInterface.getDeclaredMethods()) { Class<?>[] parameterTypes = method.getParameterTypes(); try { Method serviceMethod = serviceClass.getMethod(method.getName(), parameterTypes); validateMethod(serviceMethod); } catch (NoSuchMethodException e) { throw new Error("failed to find impl method", e); } } } WebServiceImplValidator(Class<T> serviceInterface, T service); void validate();  }
@Test void validate() { new WebServiceImplValidator<>(TestWebService.class, new WebServiceControllerBuilderTest.TestWebServiceImpl()).validate(); }