I understand:
But from the compiler's perspective, why does Java enforce these rules?
This is not a technical limitation, rather (as you have pointed out) a logical one. Java (and many other languages) enforce various rules not because they are impossible to break, but because this is an intentional part of the language.