Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to create NewObject in JNI for different methods?

 
Vinney Shanmugam
Ranch Hand
Posts: 104
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have done it with constructors, where i use to populate the values and add those values to the new object created. This can be retirved on the java side.

Say, if i have empty constructor and have setter methods(say, 4 methods), whose value will be filled in the native side and i have to create a object out of all these setter methods(say, 4 methods).

code below is for constructor.... how to create object using four different methods................

 
Rob Spoor
Sheriff
Pie
Posts: 20511
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The constructor is the same, except the signature is different and there are less parameters to the NewObject call.

The setter methods all need to be retrieved afterwards using GetMethodID and CallVoidMethod.
 
Vinney Shanmugam
Ranch Hand
Posts: 104
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you give me a sample code of it please.... because, as of now i am populating the values in constructor and also NewObject is taking constrcutor as a parameter, which we are finding using GetMethodID. In case we have two setter methods, they ll ve different jmehtodID. How can i pass these two in NewObject? I am confused only at this point... Please clear me the air....

Thanks a lot for the reply.........
 
Rob Spoor
Sheriff
Pie
Posts: 20511
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm ignoring any possible errors here for simplicity:
 
Vinney Shanmugam
Ranch Hand
Posts: 104
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a ton Rob.

It not only helped me to solve my problem but also to understand how to do it. I wont forget this in my lifetime.

A BIG THANKS.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic