According to Wikipedia, there are 3 class loaders.
The Boot Class-Loader which loads everything in RT.jar and /../jre/lib
Then the extensions class loader and the system class loader.
I'm only interested in the Boot class loader because I want to hook it and redefine a class in RT.jar without all the legality issues that come with
Note: Applications that use this option to override a class in rt.jar should not be deployed. Doing so would contravene the Java 2 Runtime Environment binary code license.
And the license here: http://www.oracle.com/technetwork/java/javase/downloads/jre-6u21-license-159054.txt
C. Java Technology Restrictions. You may not create, modify, or change the behavior of, or authorize your licensees to create, modify, or change the behavior of, classes, interfaces, or subpackages that are in any way identified as "java", "javax", "sun" or similar convention as specified by Oracle in any naming convention designation.
So I'm thinking that if I can hook the boot class loader from native code via C++, I can replace a class in by hooking the
JVM_DefineClass function from
JVM.dll without any legal trouble.
The function has the signature:
JNIEXPORT jclass JNICALL JVM_DefineClass(JNIEnv *env, const char *name, jobject _loader, const jbyte *buf, jsize len, jobject pd)
- 1: Does this function actually get call when a JVM is starting up?
- 2: Would I still be breaking the license if I hook it?
- 3: Am I hooking the right function or should I be doing something else(better method maybe?)?