oracle/graal · error · IllegalArgumentException

The replay map does not contain a tag: ${map}

Error message

The replay map does not contain a tag: ${map}

What it means

During deserialization, every JSON object in a replay file must carry a 'tag' string identifying its type; the RecursiveDeserializer reads map.get("tag") to dispatch. IllegalArgumentException('The replay map does not contain a tag: ...') fires when an EconomicMap node lacks the tag key entirely.

Source

Thrown at compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/replaycomp/JsonReplayCodec.java:1945

     *
     * @param compilationUnit the compilation unit to encode
     * @param writer the destination writer
     * @throws IOException if encoding fails
     */
    public void dump(RecordedCompilationUnit compilationUnit, JsonWriter writer) throws IOException {
        recursiveSerializer.serialize(compilationUnit, writer.valueBuilder(), RecordedCompilationUnitSerializer.TAG);
    }

    private RecursiveDeserializer createRecursiveDeserializer() {
        return new RecursiveDeserializer() {
            @Override
            @SuppressWarnings("unchecked")
            public Object deserialize(Object json, CompilationProxies.ProxyFactory proxyFactory) throws DeserializationException {
                if (json instanceof EconomicMap<?, ?>) {
                    EconomicMap<String, Object> map = (EconomicMap<String, Object>) json;
                    String tag = (String) map.get("tag");
                    if (tag == null) {
                        throw new IllegalArgumentException("The replay map does not contain a tag: " + map);
                    }
                    ObjectSerializer deserializer = tagSerializers.get(tag);
                    if (deserializer == null) {
                        throw new IllegalArgumentException("No deserializer registered for tag " + tag);
                    }
                    return deserializer.deserialize(map, this, proxyFactory);
                } else {
                    return json;
                }
            }

            @Override
            @SuppressWarnings("unchecked")
            public Object deserialize(Object json, CompilationProxies.ProxyFactory proxyFactory, String tag) throws DeserializationException {
                if (json instanceof EconomicMap<?, ?>) {
                    EconomicMap<String, Object> map = (EconomicMap<String, Object>) json;
                    ObjectSerializer deserializer = tagSerializers.get(tag);
                    if (deserializer == null) {

View on GitHub (pinned to a66e9ccd1d)

Solutions

  1. Locate the tag-less object via the map dump in the message and add the correct 'tag' field
  2. Re-generate the file with the same codec that reads it (use the codec's write API)
  3. Validate the file's schema before replay: every object node must have a 'tag'

Example fix

// before: { "number": 7 }  // no tag
// after:   { "tag": "register", "number": 7 }
Defensive patterns

Strategy: validation

Validate before calling

// Schema pre-check: every object node in the replay JSON must carry a 'tag'
void validateTags(Object node) {
    if (node instanceof EconomicMap<?,?> m) {
        if (m.get("tag") == null) throw new IllegalArgumentException("Missing tag: " + m);
        m.values().forEach(this::validateTags);
    } else if (node instanceof List<?> l) {
        l.forEach(this::validateTags);
    }
}

Prevention

When it happens

Trigger: Replaying JSON where an object node has no 'tag' field — hand-written or transformed JSON, a file produced by a different/older codec version, or a JSON→map parser that drops keys (e.g. malformed nesting).

Common situations: Manual authoring of replay files; converting replay JSON through tools that lose fields; version skew between writer and reader formats.

Related errors


AI-assisted analysis of oracle/graal@a66e9ccd1d (2026-08-14). Data as JSON: /api/errors/6f174b7a65e7744b. Report an issue: GitHub.