DefaultExpressionSerializer implements ExpressionSerializer { @Override public Expression deserialize(String code) { try { ByteArrayInputStream input = new ByteArrayInputStream(Base64.getDecoder().decode(code)); ObjectInputStream objectInput = new ObjectInputStream(input); return (Expression) objectInput.readObject(); } catch (Exception e) { throw new IllegalStateException("Failed to deserialize expression code: " + code, e); } }  @Override String serialize(Expression expr); @Override Expression deserialize(String code);  }
@Test public void cannot_deserialize_illegal_expression_code() { assertThrows(IllegalStateException.class, () -> serializer.deserialize("hello world")); }