quarkusio/quarkus · error · RuntimeException

Failed to injector constructor ${injectCtor} of bytecode rec

Error message

Failed to injector constructor ${injectCtor} of bytecode recorder

What it means

This wraps any exception thrown in the generated 'method' while BytecodeRecorderImpl actually emits the constructor invocation (loadDeferred of each deferred parameter plus newInstance of the inject constructor). Unlike 153 (prepare phase) this happens during the final load/emit phase of the recorder method.

Source

Thrown at core/deployment/src/main/java/io/quarkus/deployment/recording/BytecodeRecorderImpl.java:1880

                i.doPrepare(context);
            }
            super.doPrepare(context);
        }

        @Override
        ResultHandle createValue(MethodContext context, MethodCreator method, ResultHandle array) {
            if (injectCtor == null) {
                return method.newInstance(ofConstructor(theClass));
            } else {
                try {
                    List<ResultHandle> handles = new ArrayList<>();
                    for (var result : deferredParameters) {
                        handles.add(context.loadDeferred(result));
                    }
                    return method.newInstance(ofConstructor(injectCtor.getDeclaringClass(), injectCtor.getParameterTypes()),
                            handles.toArray(ResultHandle[]::new));
                } catch (Exception e) {
                    throw new RuntimeException("Failed to injector constructor " + injectCtor + " of bytecode recorder", e);
                }
            }
        }
    }

    static final class SubstitutionHolder {
        final Class<?> from;
        final Class<?> to;
        final Class<? extends ObjectSubstitution<?, ?>> sub;

        SubstitutionHolder(Class<?> from, Class<?> to, Class<? extends ObjectSubstitution<?, ?>> sub) {
            this.from = from;
            this.to = to;
            this.sub = sub;
        }
    }

    static final class NonDefaultConstructorHolder {

View on GitHub (pinned to e1c734241f)

Solutions

  1. Inspect the 'Caused by' to find the actual failing deferred parameter or handle
  2. Rebuild the extension and application from clean state (./mvnw clean install)
  3. Ensure the @Inject constructor's parameter order/types match what is recorded and registered
  4. Update Quarkus core and extensions to consistent versions
Defensive patterns

Strategy: try-catch

Try / catch

try {
    // augmentation / recording step
} catch (RuntimeException e) {
    if (e.getMessage() != null && e.getMessage().startsWith("Failed to injector constructor")) {
        e.getCause().printStackTrace(); // diagnose the failing deferred load
    }
    throw e;
}

Prevention

When it happens

Trigger: An Exception is thrown when loading deferred parameter ResultHandles or when calling gizmo newInstance with the inject constructor's declaring class and parameter types — e.g. mismatched parameter types, deferred load failures, or invalid handles produced in preparation.

Common situations: Constructor signature changed but cached/stale generated code or mismatched parameter ordering remains; a deferred parameter's value cannot be materialized in the target method context; internal Gizmo errors after Quarkus upgrades.

Related errors


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