• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

How to create NewObject in JNI for different methods?

 
Ranch Hand
Posts: 104
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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................

 
Sheriff
Posts: 22815
132
Eclipse IDE Spring Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 22815
132
Eclipse IDE Spring Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
You don't know me, but I've been looking all over the world for. Thanks to the help from this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic