Package com.esotericsoftware.kryo

Examples of com.esotericsoftware.kryo.KryoException


      byte methodIndex = input.readByte();
      try {
        cachedMethod = getMethods(kryo, methodClass)[methodIndex];
      } catch (IndexOutOfBoundsException ex) {
        throw new KryoException("Invalid method index " + methodIndex + " for class: " + methodClass.getName());
      }

      Serializer[] serializers = cachedMethod.serializers;
      Class[] parameterTypes = cachedMethod.method.getParameterTypes();
      Object[] args = new Object[serializers.length];
View Full Code Here


          if (generics != null) serializer.setGenerics(kryo, generics);
          if (canBeNull) {
            kryo.writeObjectOrNull(output, value, serializer);
          } else {
            if (value == null) {
              throw new KryoException("Field value is null but canBeNull is false: " + this + " ("
                + object.getClass().getName() + ")");
            }
            kryo.writeObject(output, value, serializer);
          }
        }
      } catch (IllegalAccessException ex) {
        throw new KryoException("Error accessing field: " + this + " (" + object.getClass().getName() + ")", ex);
      } catch (KryoException ex) {
        ex.addTrace(this + " (" + object.getClass().getName() + ")");
        throw ex;
      } catch (RuntimeException runtimeEx) {
        KryoException ex = new KryoException(runtimeEx);
        ex.addTrace(this + " (" + object.getClass().getName() + ")");
        throw ex;
      }
    }
View Full Code Here

        if (accessIndex != -1)
          ((FieldAccess)access).set(object, accessIndex, value);
        else
          field.set(object, value);
      } catch (IllegalAccessException ex) {
        throw new KryoException("Error accessing field: " + this + " (" + type.getName() + ")", ex);
      } catch (KryoException ex) {
        ex.addTrace(this + " (" + type.getName() + ")");
        throw ex;
      } catch (RuntimeException runtimeEx) {
        KryoException ex = new KryoException(runtimeEx);
        ex.addTrace(this + " (" + type.getName() + ")");
        throw ex;
      }
    }
View Full Code Here

          FieldAccess access = (FieldAccess)FieldSerializer.this.access;
          access.set(copy, accessIndex, kryo.copy(access.get(original, accessIndex)));
        } else
          field.set(copy, kryo.copy(field.get(original)));
      } catch (IllegalAccessException ex) {
        throw new KryoException("Error accessing field: " + this + " (" + type.getName() + ")", ex);
      } catch (KryoException ex) {
        ex.addTrace(this + " (" + type.getName() + ")");
        throw ex;
      } catch (RuntimeException runtimeEx) {
        KryoException ex = new KryoException(runtimeEx);
        ex.addTrace(this + " (" + type.getName() + ")");
        throw ex;
      }
    }
View Full Code Here

  protected int fill (byte[] buffer, int offset, int count) throws KryoException {
    if (inputStream == null) return -1;
    try {
      return inputStream.read(buffer, offset, count);
    } catch (IOException ex) {
      throw new KryoException(ex);
    }
  }
View Full Code Here

   * @return the number of bytes remaining.
   * @throws KryoException if EOS is reached before required bytes are read (buffer underflow). */
  private int require (int required) throws KryoException {
    int remaining = limit - position;
    if (remaining >= required) return remaining;
    if (required > capacity) throw new KryoException("Buffer too small: capacity: " + capacity + ", required: " + required);

    // Compact.
    System.arraycopy(buffer, position, buffer, 0, remaining);
    total += position;
    position = 0;

    while (true) {
      int count = fill(buffer, remaining, capacity - remaining);
      if (count == -1) {
        if (remaining >= required) break;
        throw new KryoException("Buffer underflow.");
      }
      remaining += count;
      if (remaining >= required) break; // Enough has been read.
    }
    limit = remaining;
View Full Code Here

    public Enum read (Kryo kryo, Input input, Class<Enum> type) {
      int ordinal = input.readInt(true);
      if (ordinal == NULL) return null;
      ordinal--;
      if (ordinal < 0 || ordinal > enumConstants.length - 1)
        throw new KryoException("Invalid ordinal for enum \"" + type.getName() + "\": " + ordinal);
      Object constant = enumConstants[ordinal];
      return (Enum)constant;
    }
View Full Code Here

    }
  }

  static public class EnumSetSerializer extends Serializer<EnumSet> {
    public void write (Kryo kryo, Output output, EnumSet object) {
      if (object.isEmpty()) throw new KryoException("An empty EnumSet cannot be serialized.");
      Serializer serializer = kryo.writeClass(output, object.iterator().next().getClass()).getSerializer();
      output.writeInt(object.size(), true);
      for (Object element : object)
        serializer.write(kryo, output, element);
    }
View Full Code Here

        if (tags[ii] == tag) {
          cachedField = fields[ii];
          break;
        }
      }
      if (cachedField == null) throw new KryoException("Unknown field tag: " + tag + " (" + getType().getName() + ")");
      cachedField.read(input, object);
    }
    return object;
  }
View Full Code Here

  protected int fill (byte[] buffer, int offset, int count) throws KryoException {
    if (inputStream == null) return -1;
    try {
      return inputStream.read(buffer, offset, count);
    } catch (IOException ex) {
      throw new KryoException(ex);
    }
  }
View Full Code Here

TOP

Related Classes of com.esotericsoftware.kryo.KryoException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.