M
Martin Strube
Hi there
I have an public inner Java Class witch I want to create from a c++
..dll. How to do that?
When I want to create it on the Java side it looks like that:
// creating the Outer Class
Outer myOuter = new Outer();
// creating the inner Class as an Array (initialized with NULL)
Outer.Inner myCoord[] = new Outer.Inner[2];
// create new Inner Class Objects
myCoord[0] = myOuter.new Inner();
myCoord[1] = myOuter.new Inner();
// do sth.
myCoord[0].x = 5;
myCoord[0].y = 5;
----------------
Now I wanne do that on the C++ side. It looks like that:
jclass cls = env->FindClass("Outer$Inner");
jmethodID InnerConstructor = env->GetMethodID(cls, "<init>",
"(LOuter
V");
// create an new Java Inner Object Array, the initelement is NULL
jobjectArray joaMyCoord = env->NewObjectArray(2, cls, NULL);
// create a new Java Inner Object, initial x,y = 0;
newObject = env->NewObject(cls, InnerConstructor);
// fill the InnerArray with Inner Elements
env->SetObjectArrayElement(joaMyCoord, 0, newObject);
env->SetObjectArrayElement(joaMyCoord, 1, newObject);
jfieldID varID = env->GetFieldID(cls,"myCoord","[LOuter$Inner;");
jobject var = env->GetObjectField(obj, varID);
// set the Java Object into the MyCoord Element on the Java side
env->SetObjectField(var, varID, joaMyCoord);
---------
Now when I want to debug the programm and want to view the stuktur of
the Inner Class Array I'll get a memory exception. Even though when I
force the GarbageCollector I'll get the memory exception. So i think
that i created the Java Object in the wrong way.
Anny Ideas?
thanks
dr.m.
I have an public inner Java Class witch I want to create from a c++
..dll. How to do that?
When I want to create it on the Java side it looks like that:
// creating the Outer Class
Outer myOuter = new Outer();
// creating the inner Class as an Array (initialized with NULL)
Outer.Inner myCoord[] = new Outer.Inner[2];
// create new Inner Class Objects
myCoord[0] = myOuter.new Inner();
myCoord[1] = myOuter.new Inner();
// do sth.
myCoord[0].x = 5;
myCoord[0].y = 5;
----------------
Now I wanne do that on the C++ side. It looks like that:
jclass cls = env->FindClass("Outer$Inner");
jmethodID InnerConstructor = env->GetMethodID(cls, "<init>",
"(LOuter
// create an new Java Inner Object Array, the initelement is NULL
jobjectArray joaMyCoord = env->NewObjectArray(2, cls, NULL);
// create a new Java Inner Object, initial x,y = 0;
newObject = env->NewObject(cls, InnerConstructor);
// fill the InnerArray with Inner Elements
env->SetObjectArrayElement(joaMyCoord, 0, newObject);
env->SetObjectArrayElement(joaMyCoord, 1, newObject);
jfieldID varID = env->GetFieldID(cls,"myCoord","[LOuter$Inner;");
jobject var = env->GetObjectField(obj, varID);
// set the Java Object into the MyCoord Element on the Java side
env->SetObjectField(var, varID, joaMyCoord);
---------
Now when I want to debug the programm and want to view the stuktur of
the Inner Class Array I'll get a memory exception. Even though when I
force the GarbageCollector I'll get the memory exception. So i think
that i created the Java Object in the wrong way.
Anny Ideas?
thanks
dr.m.