billmanhillman wrote:There is no reason whatsoever that System.load() should only work inside a static block. I suspect you're doing something else wrong.
I have a dll inside a jar file. I extract the dll to a "unique" directory and try to load it via System.load(). I've tried to use System.load outside a static block, but it doesn't load the dll. For some reason, I can only load the dll from a static block. Hence, I tried using reflection to set a static member field before the static initialization block ran.
billmanhillman wrote:When you load a class, regardless of how that occurs, it gets initialized. If initialization fails then the class load fails. This can be demonstrated by having a static initializer throw an exception. That will cause the load to fail.
In my situation, there aren't any static native methods, only one non-static native method. So, loading via non-reflexive calls finds the native methods. Loading via reflection works, but can't find the native methods when a java class calls the native method. Very strange.