quarkusio/quarkus · error · RuntimeException

Cannot create new DeferredArrayStoreParameter after array ha

Error message

Cannot create new DeferredArrayStoreParameter after array has been allocated

What it means

DeferredArrayStoreParameter represents array/collection elements that are filled into an allocated array or collection at a later point in generated bytecode. Once the array has been allocated (loadComplete == true) no new deferred store parameter may be created for it, since the allocation already happened in the generated method.

Source

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

            }
        }

        void doPrepare(MethodContext context) {
        }
    }

    abstract class DeferredArrayStoreParameter extends DeferredParameter {

        int arrayIndex = -1;
        final String returnType;
        ResultHandle originalResultHandle;
        ResultHandle originalArrayResultHandle;
        MethodCreator originalRhMethod;

        DeferredArrayStoreParameter(String expectedType) {
            returnType = expectedType;
            if (loadComplete) {
                throw new RuntimeException("Cannot create new DeferredArrayStoreParameter after array has been allocated");
            }
        }

        DeferredArrayStoreParameter(Object target, Class<?> expectedType) {
            if (expectedType == List.class || expectedType == Map.class || expectedType == Set.class
                    || expectedType == SortedMap.class || expectedType == SortedSet.class) {
                returnType = expectedType.getName();
            } else if (target != null && !(target instanceof Proxy) && isAccessible(target.getClass())) {
                returnType = target.getClass().getName();
            } else if (expectedType != null && isAccessible(expectedType)) {
                returnType = expectedType.getName();
            } else {
                returnType = null;
            }
            if (loadComplete) {
                throw new RuntimeException("Cannot create new DeferredArrayStoreParameter after array has been allocated");
            }
        }

View on GitHub (pinned to e1c734241f)

Solutions

  1. Do not mutate the recorded collection/array after passing it to the recorder or after serialization begins
  2. Snapshot collections before recording (record an immutable copy: List.copyOf(...))
  3. If a custom ObjectSerializer is involved, ensure all elements are created before the array allocation step
  4. Report/upgrade: verify Quarkus version consistency between core and extensions

Example fix

// before
List<String> list = new ArrayList<>();
recorderMethod.returnValue(list); // list mutated afterwards during recording
list.add("late");
// after
List<String> list = List.copyOf(sourceList); // snapshot, never mutated
recorderMethod.returnValue(list);
Defensive patterns

Strategy: validation

Validate before calling

static <T> List<T> frozen(List<T> in) {
    return List.copyOf(in); // snapshot before recording; never mutate after
}

Try / catch

try {
    recorder.returnValue(collection);
} catch (RuntimeException e) {
    if (e.getMessage() != null && e.getMessage().contains("after array has been allocated")) {
        throw new IllegalStateException("Collection mutated during recording; pass an immutable snapshot", e);
    }
    throw e;
}

Prevention

When it happens

Trigger: Creating a DeferredArrayStoreParameter with the single-arg (expectedType) constructor after the recording of the array/collection has already been finalized — i.e. element recording interleaved incorrectly with the array build phase inside BytecodeRecorderImpl's serialization logic.

Common situations: Usually internal: triggered by extension code that records mutable collections/lists in an order the serializer does not expect (e.g. mutating a recorded List while it is being serialized), or custom ObjectSerializer implementations that add elements late.

Related errors


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