I have a copy constructor for class, but Android Studio code inspection throws a warning I don't understand:
Suspicious assignment in copy constructor of 'java.util.Arrays.copyOf(other.value, other.value.length)' to field value
public class CpuVariable extends BaseIdentifier {
private int memoryType;
private byte[] value;
public CpuVariable(@NonNull CpuVariable other) {
super(other);
this.memoryType = other.memoryType;
if (other.value != null) {
this.value = java.util.Arrays.copyOf(other.value, other.value.length);
}
}
}
Changing code to
this.value = other.value
would remove the warning, but this is not an option since I need to create a deep copy or a clone for the field.
Am I coding something wrong or is it safe to ignore or suppress the warning?