Interface BytecodeDeserializer

Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface BytecodeDeserializer
Represents a class that can deserialize constants from a byte stream.

A BytecodeSerializer establishes a byte encoding for objects. The BytecodeDeserializer used to deserialize an interpreter should follow the same encoding.

For example:

public class MyBytecodeDeserializer implements BytecodeDeserializer {
    @Override
    public Object deserialize(DeserializerContext context, DataInput buffer) throws IOException {
        byte objectCode = buffer.readByte();
        return switch (objectCode) {
            case 1 -> buffer.readLong();
            case 2 -> buffer.readUTF();
            case ...
        }
    }
}
Since:
24.2
See Also:
  • Method Details

    • deserialize

      The deserialization process. An object should be decoded from the buffer and returned.

      The context is supplied so that a BytecodeDeserializer can transitively deserialize other root nodes (e.g., inner functions) if necessary.

      Must be idempotent. This method may be invoked multiple times for the same logical constant, so if object identity or footprint is a concern, this method may need to canonicalize such values (for example, using interning or caching).

      Throws:
      IOException
      Since:
      24.2