¿Tiene impacto en la memoria si tengo dos clases Java que tienen llamadas nativas al código C compilado y las llamo a ambas clases en otra clase? Por ejemplo, tengo clase A y clase B con ambas llamadas a funciones nativas. Son configuración como esta:Llamada JNI de Java para cargar la biblioteca
public class A{
// declare the native code function - must match ndkfoo.c
static {
System.loadLibrary("ndkfoo");
}
private static native double mathMethod();
public A() {}
public double getMath() {
double dResult = 0;
dResult = mathMethod();
return dResult;
}
}
public class B{
// declare the native code function - must match ndkfoo.c
static {
System.loadLibrary("ndkfoo");
}
private static native double nonMathMethod();
public B() {}
public double getNonMath() {
double dResult = 0;
dResult = nonMathMethod();
return dResult;
}
}
Clase C luego se llama a ambos, ya que ambos hacen una llamada estática para cargar la biblioteca será el caso en la clase C? ¿O es mejor tener la clase C System.loadLibrary llamada (...?
public class C{
// declare the native code function - must match ndkfoo.c
// So is it beter to declare loadLibrary here than in each individual class?
//static {
// System.loadLibrary("ndkfoo");
//}
//
public C() {}
public static void main(String[] args) {
A a = new A();
B b = new B();
double result = a.getMath() + b.getNonMath();
}
}