Application and Instrumentation java classes are loaded before the .NET runtime is initialized. This means we can't use static { ... } to register native methods and we implemented 2 separate ways of working around this:
ApplicationRegistration.java - generated code which we can call manually from JNIEnvInit and where we can register native methods for all the types that need it (very few usually)
- lazy call to
registerNatives from the generated java constructors of the Application and Instrumentation subclasses (and also from static methods)
We should settle on just one approach and simplify the generator code. I suggest removing the ApplicationRegistration class and only use the lazy registration just before the first native method is called.
Application and Instrumentation java classes are loaded before the .NET runtime is initialized. This means we can't use
static { ... }to register native methods and we implemented 2 separate ways of working around this:ApplicationRegistration.java- generated code which we can call manually from JNIEnvInit and where we can register native methods for all the types that need it (very few usually)registerNativesfrom the generated java constructors of the Application and Instrumentation subclasses (and also from static methods)We should settle on just one approach and simplify the generator code. I suggest removing the
ApplicationRegistrationclass and only use the lazy registration just before the firstnativemethod is called.