Most of my code is in C/C++, and I will only confess to a half-written android app in Java

, but Java looks to me exactly like C++ with automatic memory management.
I think the problem is not in the language itself but the bloated interface to the "runs on anything" virtual machine. I'm not surprised that breaks a lot.
I would also guess that the advantage of Java to afpex is precisely that the code runs on your hardware, whatever it might be, so you pay the processing costs and suffer the security risks, not them.