{"record":{"id":"5f6ec21a8ddc4a93","repo":"apache/dubbo","slug":"non-public-delegate-class-from-different-packages","errorCode":null,"errorMessage":"non-public delegate class from different packages","messagePattern":"non-public delegate class from different packages","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"dubbo-common/src/main/java/org/apache/dubbo/common/bytecode/Mixin.java","lineNumber":129,"sourceCode":"                        .append(\"];\\n\");\n                if (MixinAware.class.isAssignableFrom(dcs[i])) {\n                    code.append('d').append(i).append(\".setMixinInstance(this);\\n\");\n                }\n            }\n            ccp.addConstructor(Modifier.PUBLIC, new Class<?>[] {Object[].class}, code.toString());\n\n            Class<?> neighbor = null;\n            // impl methods.\n            Set<String> worked = new HashSet<>();\n            for (int i = 0; i < ics.length; i++) {\n                if (!Modifier.isPublic(ics[i].getModifiers())) {\n                    String npkg = ics[i].getPackage().getName();\n                    if (pkg == null) {\n                        pkg = npkg;\n                        neighbor = ics[i];\n                    } else {\n                        if (!pkg.equals(npkg)) {\n                            throw new IllegalArgumentException(\"non-public delegate class from different packages\");\n                        }\n                    }\n                }\n\n                ccp.addInterface(ics[i]);\n\n                for (Method method : ics[i].getMethods()) {\n                    if (\"java.lang.Object\".equals(method.getDeclaringClass().getName())) {\n                        continue;\n                    }\n\n                    String desc = ReflectUtils.getDesc(method);\n                    if (worked.contains(desc)) {\n                        continue;\n                    }\n                    worked.add(desc);\n\n                    int ix = findMethod(dcs, desc);","sourceCodeStart":111,"sourceCodeEnd":147,"githubUrl":"https://github.com/apache/dubbo/blob/3a3043227f5571d25eb2889de5bca22f2914843b/dubbo-common/src/main/java/org/apache/dubbo/common/bytecode/Mixin.java#L111-L147","documentation":"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.","triggerScenarios":"Mixin.mixin(ics, dc) where ics contains package-private interfaces drawn from more than one package.","commonSituations":"Mixing internal package-private interfaces from different modules; SPI extension interfaces that are not public and come from separate libraries.","solutions":["Make the interfaces public so they can be implemented from any package.","Keep all non-public interfaces in a single shared package.","Split into multiple mixin instances grouped by package."],"exampleFix":"// before\npackage a.b; interface InternalA {} // package-private\npackage c.d; interface InternalB {} // package-private\nMixin.mixin(new Class[]{ InternalA.class, InternalB.class }, dc);\n\n// after\npackage a.b; public interface InternalA {} // promote to public","handlingStrategy":"validation","validationCode":"for (Class<?> ic : ics) {\n    if (!Modifier.isPublic(ic.getModifiers())) {\n        // all non-public interfaces must share a single package\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Make interfaces public whenever they are mixed via Mixin.","Keep package-private interfaces in one package if you must mix them.","Validate interface visibility before calling Mixin.mixin."],"tags":["bytecode","mixin","visibility","validation"],"backgroundTag":null,"analyzedSha":"3a3043227f5571d25eb2889de5bca22f2914843b","analyzedAt":"2026-08-14T00:43:19.853Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}