Я наследую класс Serializer в пакете kryo и получаю следующую ошибку:
BasicPOJOSerializerHelper.java:47: error: name clash: read(Kryo,Input,Class<? extends T#1>) in BasicPOJOSerializerHelper and read(Kryo,Input,Class<T#2>) in Serializer have the same erasure, yet neither overrides the other
public T read(Kryo kryo, Input input, Class<? extends T> type) {
^
where T#1,T#2 are type-variables:
T#1 extends AbstractPOJO declared in class BasicPOJOSerializerHelper
T#2 extends Object declared in class Serializer
Я могу собрать из intellij, но сборка ant выдает ошибку. Версия Java "1.8.0_144"
Serializer.java
package com.esotericsoftware.kryo;
import com.esotericsoftware.kryo.io.Input;
import com.esotericsoftware.kryo.io.Output;
public abstract class Serializer<T> {
private boolean acceptsNull, immutable;
public Serializer () {
}
public Serializer (boolean acceptsNull) {
this.acceptsNull = acceptsNull;
}
public Serializer (boolean acceptsNull, boolean immutable) {
this.acceptsNull = acceptsNull;
this.immutable = immutable;
}
abstract public void write (Kryo kryo, Output output, T object);
abstract public T read (Kryo kryo, Input input, Class<? extends T> type);
public boolean getAcceptsNull () {
return acceptsNull;
}
public void setAcceptsNull (boolean acceptsNull) {
this.acceptsNull = acceptsNull;
}
public boolean isImmutable () {
return immutable;
}
public void setImmutable (boolean immutable) {
this.immutable = immutable;
}
public T copy (Kryo kryo, T original) {
if (isImmutable()) return original;
throw new KryoException("Serializer does not support copy: " + getClass().getName());
}
}
BasicPOJOSerializerHelper.java
package com.manu.scpoweb.drm.apm.ds.common;
import com.esotericsoftware.kryo.Kryo;
import com.esotericsoftware.kryo.Serializer;
import com.esotericsoftware.kryo.io.Input;
import com.esotericsoftware.kryo.io.Output;
import com.manu.webservices.common.ManuRuntimeException;
import com.manu.webworks.ds.common.attribute.*;
import com.manu.webworks.ds.common.pojo.AbstractPOJO;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Collection;
public abstract class BasicPOJOSerializerHelper<T extends AbstractPOJO> extends Serializer<T> {
public BasicPOJOSerializerHelper() {
}
abstract public T getInstance(GenericKey key);
public void specialWriteLogic(Kryo kryo, Output output, T pojo) {
}
public void specialReadLogic(Kryo kryo, Input input, T result) {
}
private Method getMethod(boolean isBusinessObject) {
try {
Method method;
if (isBusinessObject) {
method = BusinessObject.class.
getDeclaredMethod("setAttributeNoModificationStateChange", String.class,
BusinessObject.class);
method.setAccessible(true);
} else {
method = BusinessObject.class.
getDeclaredMethod("setAttributeNoModificationStateChange", ManuAttribute.class);
method.setAccessible(true);
}
return method;
} catch (NoSuchMethodException e) {
throw new ManuRuntimeException(e);
}
}
@Override
public T read(Kryo kryo, Input input, Class<? extends T> type) {
GenericKey key = kryo.readObject(input, GenericKey.class);
T result = getInstance(key);
specialReadLogic(kryo, input, result);
int numAttrs = input.readInt();
if (numAttrs > 0) {
try {
for (int i = 0; i < numAttrs; i++) {
Object attribute = kryo.readClassAndObject(input);
if (attribute instanceof BusinessObject) {
GenericKey boKey = ((BusinessObject) attribute).getKey();
T boResult = getInstance(boKey);
Method setAttributeNoModificationStateChangeField = getMethod(true);
setAttributeNoModificationStateChangeField.
invoke(boResult, ((BusinessObject) attribute).getBusinessObjectMetadataName(), attribute);
} else {
Method setAttributeNoModificationStateChangeField = getMethod(false);
setAttributeNoModificationStateChangeField.invoke(result, attribute);
}
}
} catch (IllegalAccessException | InvocationTargetException e) {
throw new ManuRuntimeException(e);
}
}
return result;
}
@Override
public void write(Kryo kryo, Output output, T pojo) {
GenericKey key = pojo.getKey();
kryo.writeObject(output, key);
specialWriteLogic(kryo, output, pojo);
Collection attrs = pojo.getContainedAttributes();
int numAttrs = 0;
if (attrs != null)
numAttrs = attrs.size();
output.writeInt(numAttrs);
if (numAttrs > 0) {
//as of now considering only PrimitiveAttribute, BusinessObjectRef, CollectionAttribute and BusinessObject types
//add the remaining ones if needed
for (Object attr : attrs) {
kryo.writeClassAndObject(output, attr);
}
}
output.flush(); //as per MDAP notes, do not use close()
}
}