Once upon a time there was a class:
public class Scope> implements Comparable>, Clon
Hopefully I've resolved the problem of generic cloning in Java:
public class Generic {
private T data;
public Generic() {
// ...
}
@SuppressWarnings("unchecked")
@Override
public Object clone() {
Generic cloned = new Generic();
try {
cloned.data = (T) data.getClass().getMethod("clone").invoke(data);
} catch (Exception e) {
// ...
}
return cloned;
}
}