The two languages just have
different main application areas where one is "better" than the other.
This is IMHO not a problem with compilation per-se. It is the same with
interpretation. SQL injection is a prime example. If you put unfiltered
user input in an SQL statement, the user might very well "own" the
database. The same with Perl

, cgi script vulnerables are legendary,
thanks to programmers forgetting to check user requests.
You have that problem already in any Java application which fires up the
compiler on-the-fly and loads the resulting class. If the generated
source code somehow depends on user input, and if it isn't thoroughly
checked by the programmer, the user can inject code and get it executed.
No need to wait for eval() :-(.