public static Object decode(Object value, Type type) {
        if (value instanceof Integer) {
            int i = (Integer) value;
            switch (type.tag) {
            case BOOLEAN:  return i != 0;
            case CHAR:     return (char) i;
            case BYTE:     return (byte) i;
            case SHORT:    return (short) i;
            }
        }
        return value;
    }