Refactored java.c to cache JNI methods and classes and skip detach for r...

@octo here are the changes for "Java plugin used in high volume application causes process to grow very large #737"