{"record":{"id":"24aeabe6c94eff69","repo":"quarkusio/quarkus","slug":"companions-are-not-supported-in-java","errorCode":null,"errorMessage":"Companions are not supported in Java.","messagePattern":"Companions are not supported in Java\\.","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"extensions/panache/mongodb-panache/deployment/src/main/java/io/quarkus/mongodb/panache/deployment/ReactiveTypeBundle.java","lineNumber":26,"sourceCode":"import io.quarkus.mongodb.panache.reactive.ReactivePanacheQuery;\nimport io.quarkus.mongodb.panache.reactive.runtime.JavaReactiveMongoOperations;\nimport io.quarkus.panache.common.deployment.ByteCodeType;\nimport io.quarkus.panache.common.deployment.TypeBundle;\n\npublic class ReactiveTypeBundle implements TypeBundle {\n    @Override\n    public ByteCodeType entity() {\n        return new ByteCodeType(ReactivePanacheMongoEntity.class);\n    }\n\n    @Override\n    public ByteCodeType entityBase() {\n        return new ByteCodeType(ReactivePanacheMongoEntityBase.class);\n    }\n\n    @Override\n    public ByteCodeType entityCompanion() {\n        throw new UnsupportedOperationException(\"Companions are not supported in Java.\");\n    }\n\n    @Override\n    public ByteCodeType entityCompanionBase() {\n        throw new UnsupportedOperationException(\"Companions are not supported in Java.\");\n    }\n\n    @Override\n    public ByteCodeType operations() {\n        return new ByteCodeType(JavaReactiveMongoOperations.class);\n    }\n\n    @Override\n    public ByteCodeType queryType() {\n        return new ByteCodeType(ReactivePanacheQuery.class);\n    }\n\n    @Override","sourceCodeStart":8,"sourceCodeEnd":44,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/extensions/panache/mongodb-panache/deployment/src/main/java/io/quarkus/mongodb/panache/deployment/ReactiveTypeBundle.java#L8-L44","documentation":"Kotlin companion-object based Panache is only meaningful for Kotlin MongoDB Panache entities. The Java reactive MongoDB type bundle overrides entityCompanion to fail fast, since Java has no companion objects.","triggerScenarios":"Internal/extension code invokes entityCompanion() on the Java ReactiveTypeBundle for reactive MongoDB Panache during bytecode generation.","commonSituations":"Misconfiguration mixing Kotlin Panache generator expectations with Java modules; upstream bug selecting the wrong TypeBundle; users writing custom build steps calling bundle.entityCompanion().","solutions":["Use the Kotlin type bundle only for Kotlin projects; Java projects should not need companions","If you hit this in a Java app, report it — companion generation should not be requested for Java entities","For Kotlin, use the Kotlin entity base classes/companion support"],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":"if (isKotlinEntity(entityClass)) useKotlinBundle();","typeGuard":"boolean isKotlinEntity(Class<?> c) {\n    return c.isAnnotationPresent(kotlin.Metadata.class);\n}","tryCatchPattern":"try { bundle.entityCompanion(); } catch (UnsupportedOperationException e) { // Java bundle: switch to Kotlin bundle for Kotlin entities }","preventionTips":["Match the type bundle to the entity language","Don't call companion accessors on Java bundles"],"tags":["quarkus","mongodb-panache","kotlin","unsupported-operation"],"backgroundTag":"companions-not-supported","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}