Once AI can write decent code from scratch, it is likely it can also circumvent potential copyright violations.
A. Check AI generated code against a comprehensive library of open-source copyrighted code and identify potential violations.
B. Ask AI to generate a paraphrase of the potential violations, by employing any number of semantic preserving transforms -- e.g. variable name change, operator replacement, structured block rewrite, functional rebalance, etc.
Lazy example:
private static void rangeCheck(int arrayLen, int fromIndex, int toIndex {
if (fromIndex > toIndex)
throw new IllegalArgumentException("fromIndex(" + fromIndex +
") > toIndex(" + toIndex+")");
if (fromIndex < 0)
throw new ArrayIndexOutOfBoundsException(fromIndex);
if (toIndex > arrayLen)
throw new ArrayIndexOutOfBoundsException(toIndex);
}
private static void rangeCheck(int len, int start, int end) {
if (!(0 <= start)) {
throw new ArrayIndexOutOfBoundsException(`Failed: 0 <= ${start}`);
} else if (!(start <= end)) {
throw new IllegalArgumentException(`Failed: ${start} <= ${end}`);
} else if (!(end <= len)) {
throw new ArrayIndexOutOfBoundsException(`Failed: ${end} <= ${len}`);
}
}