Package com.esotericsoftware.kryo

Examples of com.esotericsoftware.kryo.KryoException


  public Object read (Kryo kryo, Input input, Class type) {
    try {
      return new ObjectInputStream(input).readObject();
    } catch (Exception ex) {
      throw new KryoException("Error during Java deserialization.", ex);
    }
  }
View Full Code Here


        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;
    } finally {
      // if(typeVar2concreteClass != null)
      // kryo.popGenericsScope();
    }
View Full Code Here

          value = kryo.readObject(input, concreteType, serializer);
      }

      setField(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;
    } finally {
      // if(typeVar2concreteClass != null)
      // kryo.popGenericsScope();
    }
View Full Code Here

        FieldAccess access = (FieldAccess)fieldSerializer.access;
        access.set(copy, accessIndex, kryo.copy(access.get(original, accessIndex)));
      } else
        setField(copy, kryo.copy(getField(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

    // Unsafe supports efficient bulk reading into arrays of primitives only because
    // of JVM limitations due to GC
    if (dstObj.getClass().isArray())
      readBytes(dstObj, 0, offset, (int)count);
    else {
      throw new KryoException("Only bulk reads of arrays is supported");
    }
  }
View Full Code Here

  /** @return true if the buffer has been resized. */
  protected boolean require (int required) throws KryoException {
    if (capacity - position >= required) return false;
    if (required > maxCapacity)
      throw new KryoException("Buffer overflow. Max capacity: " + maxCapacity + ", required: " + required);
    flush();
    while (capacity - position < required) {
      if (capacity == maxCapacity)
        throw new KryoException("Buffer overflow. Available: " + (capacity - position) + ", required: " + required);
      // Grow buffer.
      capacity = Math.min(capacity * 2, maxCapacity);
      if (capacity < 0) capacity = maxCapacity;
      byte[] newBuffer = new byte[capacity];
      System.arraycopy(buffer, 0, newBuffer, 0, position);
View Full Code Here

  public void flush () throws KryoException {
    if (outputStream == null) return;
    try {
      outputStream.write(buffer, 0, position);
    } catch (IOException ex) {
      throw new KryoException(ex);
    }
    total += position;
    position = 0;
  }
View Full Code Here

    public Enum read (Kryo kryo, Input input, Class<Enum> type) {
      int ordinal = input.readVarInt(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) {
      Serializer serializer;
      if (object.isEmpty()) {
        EnumSet tmp = EnumSet.complementOf(object);
        if (tmp.isEmpty()) throw new KryoException("An EnumSet must have a defined Enum to be serialized.");
        serializer = kryo.writeClass(output, tmp.iterator().next().getClass()).getSerializer();
      } else {
        serializer = kryo.writeClass(output, object.iterator().next().getClass()).getSerializer();
      }
      output.writeInt(object.size(), true);
View Full Code Here

  public void flush () throws KryoException {
    if (position() > 0) {
      try {
        writeChunkSize();
      } catch (IOException ex) {
        throw new KryoException(ex);
      }
    }
    super.flush();
  }
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.