quarkusio/quarkus · warning · UnsupportedOperationException

Companions are not supported in Java.

Error message

Companions are not supported in Java.

What it means

TypeBundle models the Kotlin companion-class concept used by some Panache bytecode generation (Kotlin builds have entity companions). In pure Java builds companions do not exist, so the default entityCompanion() method throws UnsupportedOperationException if invoked.

Source

Thrown at extensions/panache/panache-common/deployment/src/main/java/io/quarkus/panache/common/deployment/TypeBundle.java:9

package io.quarkus.panache.common.deployment;

public interface TypeBundle {
    ByteCodeType entity();

    ByteCodeType entityBase();

    default ByteCodeType entityCompanion() {
        throw new UnsupportedOperationException("Companions are not supported in Java.");
    }

    default ByteCodeType entityCompanionBase() {
        throw new UnsupportedOperationException("Companions are not supported in Java.");
    }

    ByteCodeType operations();

    ByteCodeType queryType();

    ByteCodeType repository();

    ByteCodeType repositoryBase();

    default ByteCodeType updateType() {
        throw new UnsupportedOperationException("Update types are only supported in MongoDB contexts");
    };
}

View on GitHub (pinned to e1c734241f)

Solutions

  1. Do not invoke entityCompanion() for Java entities; guard callers with a Kotlin check before calling.
  2. Override entityCompanion() in a custom TypeBundle only for Kotlin compilations.
  3. Keep Java and Kotlin Panache enhancement paths separate (per-language processing).

Example fix

// before
ByteCodeType companion = bundle.entityCompanion(); // throws for Java
// after
if (isKotlinClass(classInfo)) {
    ByteCodeType companion = bundle.entityCompanion();
}
Defensive patterns

Strategy: type-guard

Type guard

boolean hasCompanions(ClassInfo ci) {
    return ci.name().toString().endsWith("Kt") || isKotlinClass(ci);
}
if (hasCompanions(classInfo)) bundle.entityCompanion();

Try / catch

try {
    bundle.entityCompanion();
} catch (UnsupportedOperationException e) {
    // Java entity: skip companion processing
}

Prevention

When it happens

Trigger: A bytecode-generation routine that unconditionally calls bundle.entityCompanion() running against a Java TypeBundle implementation that did not override the default, e.g. during Panache enhancement when processing companions.

Common situations: Mixing Java and Kotlin Panache code in one project so the Kotlin-oriented build path runs over Java classes; writing custom TypeBundle implementations for tooling.

Related errors


AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05). Data as JSON: /api/errors/0c43c6c66539445d. Report an issue: GitHub.