Java code can write, rewrite, or inspect other Java code. The real question is when it happens, and who pays…