Skip to content

Commit

Permalink
Add test from EsotericSoftware#377
Browse files Browse the repository at this point in the history
  • Loading branch information
magro committed Jun 17, 2016
1 parent 50f7f36 commit f33d519
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions test/com/esotericsoftware/kryo/GenericsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,52 @@ public void testNonGenericClassWithGenericSuperclass () throws Exception {
roundTrip(108, 108, cc1);
}

// Test for/from https:/EsotericSoftware/kryo/issues/377
public void testDifferentTypeArguments() throws Exception {
LongHolder o1 = new LongHolder(1L);
LongListHolder o2 = new LongListHolder(Arrays.asList(1L));

kryo.setRegistrationRequired(false);
kryo.getFieldSerializerConfig().setOptimizedGenerics(false);
Output buffer = new Output(512, 4048);
kryo.writeClassAndObject(buffer, o1);
kryo.writeClassAndObject(buffer, o2);
}

private interface Holder<V> {
V getValue();
}

private static abstract class AbstractValueHolder<V> implements Holder<V> {
private final V value;

AbstractValueHolder(V value) {
this.value = value;
}

public V getValue() {
return value;
}
}

private static abstract class AbstractValueListHolder<V> extends AbstractValueHolder<List<V>> {
AbstractValueListHolder(List<V> value) {
super(value);
}
}

private static class LongHolder extends AbstractValueHolder<Long> {
LongHolder(Long value) {
super(value);
}
}

private static class LongListHolder extends AbstractValueListHolder<Long> {
LongListHolder(java.util.List<Long> value) {
super(value);
}
}

// A simple serializable class.
private static class SerializableObjectFoo implements Serializable {
String name;
Expand Down

0 comments on commit f33d519

Please sign in to comment.