Package com.esotericsoftware.kryo

Examples of com.esotericsoftware.kryo.KryoException


    public void setField (Object object, Object value) throws IllegalArgumentException, IllegalAccessException {
      if (accessIndex != -1)
        ((FieldAccess)access).set(object, accessIndex, value);
      else
        throw new KryoException("Unknown acess index");
    }
View Full Code Here


    public void copy (Object original, Object copy) {
      try {
        if (accessIndex != -1) {
          access.set(copy, accessIndex, kryo.copy(access.get(original, accessIndex)));
        } else
          throw new KryoException("Unknown acess index");
      } 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

    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

  /** @return true if the buffer has been resized. */
  private 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

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

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

        cachedField.set(object, value);
      } catch (IllegalAccessException ex) {
        throw new KryoException("Error accessing field: " + cachedField + " (" + type.getName() + ")", ex);
      } catch (KryoException ex) {
        ex.addTrace(cachedField + " (" + type.getName() + ")");
        throw ex;
      } catch (RuntimeException runtimeEx) {
        KryoException ex = new KryoException(runtimeEx);
        ex.addTrace(cachedField + " (" + type.getName() + ")");
        throw ex;
      }
    }
    return object;
  }
View Full Code Here

      CachedField cachedField = fields[i];
      try {
        Object value = cachedField.get(original);
        cachedField.set(copy, value);
      } catch (IllegalAccessException ex) {
        throw new KryoException("Error accessing field: " + cachedField + " (" + type.getName() + ")", ex);
      } catch (KryoException ex) {
        ex.addTrace(cachedField + " (" + type.getName() + ")");
        throw ex;
      } catch (RuntimeException runtimeEx) {
        KryoException ex = new KryoException(runtimeEx);
        ex.addTrace(cachedField + " (" + type.getName() + ")");
        throw ex;
      }
    }
    return copy;
  }
View Full Code Here

          if (cachedField.generics != null) serializer.setGenerics(kryo, cachedField.generics);
          if (cachedField.canBeNull)
            kryo.writeObjectOrNull(outputChunked, value, serializer);
          else {
            if (value == null) {
              throw new KryoException("Field value is null but canBeNull is false: " + cachedField + " ("
                + object.getClass().getName() + ")");
            }
            kryo.writeObject(outputChunked, value, serializer);
          }
        }

        outputChunked.endChunks();
      } catch (IllegalAccessException ex) {
        throw new KryoException("Error accessing field: " + cachedField + " (" + object.getClass().getName() + ")", ex);
      } catch (KryoException ex) {
        ex.addTrace(cachedField + " (" + object.getClass().getName() + ")");
        throw ex;
      } catch (RuntimeException runtimeEx) {
        KryoException ex = new KryoException(runtimeEx);
        ex.addTrace(cachedField + " (" + object.getClass().getName() + ")");
        throw ex;
      }
    }
  }
View Full Code Here

        cachedField.set(object, value);

        inputChunked.nextChunks();
      } catch (IllegalAccessException ex) {
        throw new KryoException("Error accessing field: " + cachedField + " (" + getType().getName() + ")", ex);
      } catch (KryoException ex) {
        ex.addTrace(cachedField + " (" + getType().getName() + ")");
        throw ex;
      } catch (RuntimeException runtimeEx) {
        KryoException ex = new KryoException(runtimeEx);
        ex.addTrace(cachedField + " (" + getType().getName() + ")");
        throw ex;
      }
    }
    return object;
  }
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.