Hello everyone!
While working on my chromium API/mod https://github.com/montoyo/mcef I've been playing with the JNI (Java Native Interface) a lot. It works pretty well while you keep playing on a Java-created thread; but if you need to create an object from a native thread and pass it to your FML mod... well, you get some weird exceptions: cannot cast class into the same class, incompatible class change exception, abstract method call exception, etc...
This happens when, for instance, you create an object from your C/C++ thread using env->FindClass(), and then passes it to a java method. Sometimes env->FindClass might fail and throw a ClassNotFoundException, or sometimes all the native part works but when using the object from Java it throws one of the exceptions I named before. By the way, I say it happens only with a FML mod because actually it works with a normal Java app.
So I have two questions:
1. Obviously FML changes things on the ClassLoader to load mods; can anyone tell me what and how it works?
2. I've fixed those bugs by calling ClassLoader.loadClass() from my native but this is probably very slow... any idea how else I could fix this?
Thanks a lot,
- BuildLight (aka montoyo)