apache/dubbo · error · RuntimeException
Class {} is not a interface.
Error message
Class {} is not a interface. What it means
Thrown by Mixin.assertInterfaceArray at the start of mixin(). It verifies every element of the ics array is actually an interface; passing a concrete or abstract class is a programming error because Dubbo generates an implementor, not a subclass. The message names the offending class.
Source
Thrown at dubbo-common/src/main/java/org/apache/dubbo/common/bytecode/Mixin.java:226
private static int findMethod(Class<?>[] dcs, String desc) {
Class<?> cl;
Method[] methods;
for (int i = 0; i < dcs.length; i++) {
cl = dcs[i];
methods = cl.getMethods();
for (Method method : methods) {
if (desc.equals(ReflectUtils.getDesc(method))) {
return i;
}
}
}
return -1;
}
private static void assertInterfaceArray(Class<?>[] ics) {
for (int i = 0; i < ics.length; i++) {
if (!ics[i].isInterface()) {
throw new RuntimeException("Class " + ics[i].getName() + " is not a interface.");
}
}
}
/**
* new Mixin instance.
*
* @param ds delegates instance.
* @return instance.
*/
public abstract Object newInstance(Object[] ds);
public static interface MixinAware {
void setMixinInstance(Object instance);
}
}
View on GitHub (pinned to 3a3043227f)
Solutions
- Pass the interface type, not a concrete/abstract class, in the ics array.
- If you intended to proxy a class rather than implement an interface, use a different mechanism (Proxy only handles interfaces too).
- Add a compile-time or pre-call check ic.isInterface() for each element.
Example fix
// before
Mixin.mixin(new Class[]{ ServiceImpl.class }, dc); // ServiceImpl is a class
// after
Mixin.mixin(new Class[]{ Service.class }, dc); // Service is the interface Defensive patterns
Strategy: validation
Validate before calling
for (Class<?> ic : ics) {
if (!ic.isInterface()) {
throw new IllegalArgumentException(ic.getName() + " is not an interface");
}
} Prevention
- Pass interface types, not classes, to Mixin.mixin.
- Add a unit test that asserts each element of ics is an interface.
When it happens
Trigger: Mixin.mixin(new Class[]{ SomeClass.class }, dc) where SomeClass is not declared with the interface keyword.
Common situations: Passing an implementation class instead of its interface by mistake; passing a class that was refactored from interface to abstract class; copy-paste of the wrong Class reference.
Related errors
- Missing method [{}] implement.
- non-public interfaces class from different packages
- non-public delegate class from different packages
- {} is not a interface.
- interface limit exceeded
AI-assisted analysis of apache/dubbo@3a3043227f (2026-08-14).
Data as JSON: /api/errors/99f6e2b54bfb96e3.
Report an issue: GitHub.