oracle/graal · error · IOException

Invalid constant pool index :

Error message

Invalid constant pool index : 

What it means

When reading a pooled object reference, BinaryReader reads a type tag and a 16-bit index into the constant pool it built while parsing. If the index is beyond the pool's current size, the stream references an entry that was never written: the file is corrupted, truncated, or was written/offset in a way that desynchronized the reader from the writer's encoding. The IOException stops parsing because any subsequent reads would be based on unknown data.

Source

Thrown at compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/graphio/parsing/BinaryReader.java:602

        for (int i = 0; i < len; i++) {
            props[i] = readPoolObject(Object.class);
        }
        return props;
    }

    @SuppressWarnings("unchecked")
    private <T> T readPoolObject(Class<T> klass) throws IOException {
        int type = dataSource.readByte();
        if (type == POOL_NULL) {
            return null;
        }
        if (type == POOL_NEW) {
            return (T) addPoolEntry(klass);
        }
        assert assertObjectType(klass, type) : "Wrong object type : " + klass + " != " + type;
        char index = dataSource.readShort();
        if (index >= constantPool.size()) {
            throw new IOException("Invalid constant pool index : " + index);
        }
        Object obj = getPoolData(index);
        return (T) obj;
    }

    private Object getPoolData(int index) {
        return constantPool.get(index, -1);
    }

    private static boolean assertObjectType(Class<?> klass, int type) {
        switch (type) {
            case POOL_CLASS:
                return klass.isAssignableFrom(EnumKlass.class);
            case POOL_ENUM:
                return klass.isAssignableFrom(EnumValue.class);
            case POOL_METHOD:
                return klass.isAssignableFrom(Method.class);
            case POOL_STRING:

View on GitHub (pinned to a66e9ccd1d)

Solutions

  1. Regenerate the graph dump and verify the producer finished writing (look for complete dump close in producer logs).
  2. Verify file integrity (size, checksum/SHA-1 digest the format supports) before parsing.
  3. Ensure producer and consumer run compatible graphio protocol versions (check the file's version header).
  4. If concatenating BGV files, use the documented stream-concatenation support (each chunk carries its own BIGV header) rather than raw byte splicing.
Defensive patterns

Strategy: try-catch

Try / catch

try { reader.parse(); } catch (IOException e) { if (e.getMessage().startsWith("Invalid constant pool index")) { reportCorruptFile(); } throw e; }

Prevention

When it happens

Trigger: Feeding a BGV/BIGV file that was truncated mid-dump; concatenating or splicing graph files incorrectly; reading a file produced by a writer with a different pool-encoding bug; using a skip/seek offset (SkipRootException handling) that lands in the middle of an entry.

Common situations: Reading partially-flushed dump files (a compiler crash while dumping), transferring files without verifying integrity, or a producer/consumer version mismatch that changes entry layouts.

Related errors


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