use of CallStaticVoidMethod

I've got a problem when trying to retrieve "args" argument in java class main method

my C code is equivallent to :

void MyFunction()

{

...

mid = env->GetStaticMethodID(cls, "main", "([Ljava/lang/String;)V");

env->CallStaticVoidMethod(cls, mid, "ABC");

...

}

my java code is equivallent to :

class MyClass {

public static void main( String[] args ) {

for( int i = 0 ; i < args.length ; i++ )

{

myFunction( args ) ;

}

}

}

When running : java MyClass, all is ok

When running MyClass trough MyFunction args.length or args makes my soft break down

Can anyone explain me the phenomenon ? How can I solve this problem

JCC

[788 byte] By [jccarrion] at [2007-9-26 6:13:46]
# 1

are you sure that you have the reference to env pointer available in Myfunction?

Also please indicate what sort of error are you getting when you call CallStaticVoidMethod(..).

If everything seems alright, try the following code to pass the string:

jstring str = env->NewStringUTF(" from C++!");

jarray args =

env->NewObjectArray(1, env->FindClass("java/lang/String"), str);

env->CallStaticVoidMethod(cls, mid, args);

Good Luck,

Zeeshan

zeeshanarif at 2007-7-1 15:06:24 > top of Java-index,Java HotSpot Virtual Machine,Specifications...