Interesantes problem (wahrscheinlich nur ein anfänger Fehler)
-
Hi, mein Problem ist, dass ich bei einem code stück das ich geschreiben habe Access Violations bekomme zur laufzeit.
Ich habe jmeClasses, dessen methode initJavaClasses am anfang des programms aufgerufen wird
void jmeClasses::initJavaClasses(JNIEnv* env) { env->GetJavaVM(&vm); PhysicsSpace = env->FindClass("com/jme3/bullet/PhysicsSpace"); if (env->ExceptionCheck()) { env->Throw(env->ExceptionOccurred()); return; } PhysicsSpace_preTick = env->GetMethodID(PhysicsSpace, "preTick_native", "(F)V"); PhysicsSpace_postTick = env->GetMethodID(PhysicsSpace, "postTick_native", "(F)V"); PhysicsSpace_addCollisionEvent = env->GetMethodID(PhysicsSpace, "addCollisionEvent_native","(Lcom/jme3/bullet/collision/PhysicsCollisionObject;Lcom/jme3/bullet/collision/PhysicsCollisionObject;J)V"); if (env->ExceptionCheck()) { env->Throw(env->ExceptionOccurred()); return; } PhysicsGhostObject = env->FindClass("com/jme3/bullet/objects/PhysicsGhostObject"); if (env->ExceptionCheck()) { env->Throw(env->ExceptionOccurred()); return; } ..... snip ..... ..... RayResult_Class = env->FindClass("com/jme3/bullet/collision/PhysicsRayTestResult"); if (env->ExceptionCheck()) { env->Throw(env->ExceptionOccurred()); return; } printf("Loading Class & Method ids \n"); }Im header davon ist
static jclass RayResult_Class;definiert,
ganz oben in der .cpp stehtjclass jmeClasses::RayResult_Class;wenn ich nun jedoch aus einer andern classe folgendes versuche:
jobject singleresult = env->AllocObject(jmeClasses::RayResult_Class);bekomme ich eine Access Violation.
Wenn ich stattdessen
jclass clazz = env->FindClass("com/jme3/bullet/collision/PhysicsRayTestResult"); if (env->ExceptionCheck()) { env->Throw(env->ExceptionOccurred()); return; } printf("after accessing \n"); jobject singleresult = env->AllocObject(clazz);Mache funktioniert alles wie gewünscht, sieht nur extrem häßlich aus, und zudem muss jedesmal beim aufruf die klasse neu gesucht werden, was die performance drückt.
Hat einer eine Idee woher das problem kommen kann?