apache/dubbo · error · IllegalArgumentException

non-public delegate class from different packages

Error message

non-public delegate class from different packages

What it means

Thrown by Mixin.mixin when two or more INTERFACE classes (the ics array) are non-public AND reside in different packages. The generated mixin must live in one package to access package-private interfaces; if non-public interfaces span multiple packages, neither package can host the class, so Dubbo aborts with IllegalArgumentException.

Source

Thrown at dubbo-common/src/main/java/org/apache/dubbo/common/bytecode/Mixin.java:129

                        .append("];\n");
                if (MixinAware.class.isAssignableFrom(dcs[i])) {
                    code.append('d').append(i).append(".setMixinInstance(this);\n");
                }
            }
            ccp.addConstructor(Modifier.PUBLIC, new Class<?>[] {Object[].class}, code.toString());

            Class<?> neighbor = null;
            // impl methods.
            Set<String> worked = new HashSet<>();
            for (int i = 0; i < ics.length; i++) {
                if (!Modifier.isPublic(ics[i].getModifiers())) {
                    String npkg = ics[i].getPackage().getName();
                    if (pkg == null) {
                        pkg = npkg;
                        neighbor = ics[i];
                    } else {
                        if (!pkg.equals(npkg)) {
                            throw new IllegalArgumentException("non-public delegate class from different packages");
                        }
                    }
                }

                ccp.addInterface(ics[i]);

                for (Method method : ics[i].getMethods()) {
                    if ("java.lang.Object".equals(method.getDeclaringClass().getName())) {
                        continue;
                    }

                    String desc = ReflectUtils.getDesc(method);
                    if (worked.contains(desc)) {
                        continue;
                    }
                    worked.add(desc);

                    int ix = findMethod(dcs, desc);

View on GitHub (pinned to 3a3043227f)

Solutions

  1. Make the interfaces public so they can be implemented from any package.
  2. Keep all non-public interfaces in a single shared package.
  3. Split into multiple mixin instances grouped by package.

Example fix

// before
package a.b; interface InternalA {} // package-private
package c.d; interface InternalB {} // package-private
Mixin.mixin(new Class[]{ InternalA.class, InternalB.class }, dc);

// after
package a.b; public interface InternalA {} // promote to public
Defensive patterns

Strategy: validation

Validate before calling

for (Class<?> ic : ics) {
    if (!Modifier.isPublic(ic.getModifiers())) {
        // all non-public interfaces must share a single package
    }
}

Prevention

When it happens

Trigger: Mixin.mixin(ics, dc) where ics contains package-private interfaces drawn from more than one package.

Common situations: Mixing internal package-private interfaces from different modules; SPI extension interfaces that are not public and come from separate libraries.

Related errors


AI-assisted analysis of apache/dubbo@3a3043227f (2026-08-14). Data as JSON: /api/errors/5f6ec21a8ddc4a93. Report an issue: GitHub.