Package com.esotericsoftware.kryo.serializers

Examples of com.esotericsoftware.kryo.serializers.FieldSerializer$AsmCachedField


    test.byteArrayField = new byte[] {2, 1, 0, -1, -2};
    roundTrip(78, 88, test);

    kryo.register(HasStringField.class);
    test.hasStringField = new HasStringField();
    FieldSerializer serializer = (FieldSerializer)kryo.getSerializer(DefaultTypes.class);
    serializer.getField("hasStringField").setCanBeNull(false);
    roundTrip(79, 89, test);
    serializer.setFixedFieldTypes(true);
    serializer.getField("hasStringField").setCanBeNull(false);
    roundTrip(78, 88, test);
  }
View Full Code Here


    supportsCopy = false;

    test.StringField = null;
    roundTrip(67, 87, test);

    FieldSerializer serializer = (FieldSerializer)kryo.getSerializer(DefaultTypes.class);
    serializer.removeField("LongField");
    serializer.removeField("floatField");
    serializer.removeField("FloatField");
    roundTrip(55, 75, test);

    supportsCopy = true;
  }
View Full Code Here

      return kryo;
    };
  };
  @SuppressWarnings("rawtypes")
  protected static void removeField(Kryo kryo, Class type, String fieldName) {
    FieldSerializer fld = new FieldSerializer(kryo, type);
    fld.removeField(fieldName);
    kryo.register(type, fld);
  }
View Full Code Here

        // Let's live dangerously.
        serialiser.setAsmEnabled(false);

        // Serialiser for ClassInfo
        FieldSerializer classInfoSerialiser = new FieldSerializer(serialiser, ClassInfo.class);
        classInfoSerialiser.setFieldsCanBeNull(false);

        // Serialiser for MethodInfo
        FieldSerializer methodInfoSerialiser = new FieldSerializer(serialiser, MethodInfo.class);
        methodInfoSerialiser.getField("methodHash").setClass(String.class, new DefaultSerializers.StringSerializer());
        methodInfoSerialiser.setFieldsCanBeNull(false);

        // Serialiser for EffectSet.
        FieldSerializer effectSetSerialiser = new FieldSerializer(serialiser, EffectSet.class);

        SymbolSetSerialiser symbolSetSerialiser = new SymbolSetSerialiser();
        serialiser.register(SymbolSet.class, symbolSetSerialiser);

        // Don't serialise non-escaping symbol sets. Nobody cares.
        effectSetSerialiser.removeField("readInternal");
        effectSetSerialiser.removeField("writeInternal");
        effectSetSerialiser.getField("readEscaping").setClass(SymbolSet.class, symbolSetSerialiser);
        effectSetSerialiser.getField("writeEscaping").setClass(SymbolSet.class, symbolSetSerialiser);

        serialiser.register(EffectSet.class, effectSetSerialiser);

        // Now you can serialise an EffectSet, you can serialise an Effects.
        serialiser.register(Effects.class, new EffectsSerialiser());
View Full Code Here

    waitForThreads();
  }

  static public void register (Kryo kryo) {
    kryo.register(short[].class);
    kryo.register(SomeData.class, new DeflateSerializer(new FieldSerializer(kryo, SomeData.class)));
    kryo.register(ArrayList.class, new CollectionSerializer());
  }
View Full Code Here

   * @see Kryo#register(Class, Serializer) */
  static public void registerClasses (final Kryo kryo) {
    kryo.register(Object[].class);
    kryo.register(InvokeMethod.class);

    FieldSerializer serializer = (FieldSerializer)kryo.register(InvokeMethodResult.class).getSerializer();
    serializer.getField("objectID").setClass(int.class, new Serializer<Integer>() {
      public void write (Kryo kryo, Output output, Integer object) {
        output.writeInt(object, true);
      }

      public Integer read (Kryo kryo, Input input, Class<Integer> type) {
View Full Code Here

    test.byteArrayField = new byte[] {2, 1, 0, -1, -2};
    roundTrip(78, 88, test);

    kryo.register(HasStringField.class);
    test.hasStringField = new HasStringField();
    FieldSerializer serializer = (FieldSerializer)kryo.getSerializer(DefaultTypes.class);
    serializer.getField("hasStringField").setCanBeNull(false);
    roundTrip(79, 89, test);
    serializer.setFixedFieldTypes(true);
    serializer.getField("hasStringField").setCanBeNull(false);
    roundTrip(78, 88, test);
  }
View Full Code Here

    supportsCopy = false;

    test.StringField = null;
    roundTrip(67, 87, test);

    FieldSerializer serializer = (FieldSerializer)kryo.getSerializer(DefaultTypes.class);
    serializer.removeField("LongField");
    serializer.removeField("floatField");
    serializer.removeField("FloatField");
    roundTrip(55, 75, test);

    supportsCopy = true;
  }
View Full Code Here

                f.inheritableFiberLocals = f.inheritableFiberLocals != null
                        ? filterThreadLocalMap(ThreadAccess.toMap(f.inheritableFiberLocals)).keySet().toArray() : null;
                f.stack.resumeStack();

                kryo.writeClass(output, f.getClass());
                new FieldSerializer(kryo, f.getClass()).write(kryo, output, f);
            } catch (Throwable t) {
                t.printStackTrace();
                throw t;
            } finally {
                ThreadAccess.setThreadLocals(currentThread, tmpThreadLocals);
View Full Code Here

            ThreadAccess.setInheritablehreadLocals(currentThread, null);
            try {
                final Registration reg = kryo.readClass(input);
                if (reg == null)
                    return null;
                f = (Fiber) new FieldSerializer(kryo, reg.getType()).read(kryo, input, reg.getType());

                f.fiberLocals = ThreadAccess.getThreadLocals(currentThread);
                f.inheritableFiberLocals = ThreadAccess.getInheritableThreadLocals(currentThread);

                return f;
View Full Code Here

TOP

Related Classes of com.esotericsoftware.kryo.serializers.FieldSerializer$AsmCachedField

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.