• 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
  • Ron McLeod
  • Paul Clapham
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Rob Spoor
  • Bear Bibeault
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:
  • Frits Walraven
  • Himai Minh

JNI accessing Integer Object

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a JNI method to access java method which returns an Integer object. I do not want to return the primitive int type because this code will be modified to handle Generic objects. The following is what I have. I am not able to get the value of the Integer that I pass. The output at C++ side is something like


How can I get the actual value of Integer object that I pass, at the C++ end?

Please help.

Thanks,

-H

GenericPeer.cpp



GenericPeer.java


Data.java



Test.java (Main class)


 
Sheriff
Posts: 22209
117
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The value jobject is a pointer (yes, actual pointer. After all, this is C++) to the Integer object (or at least a pointer to something that represents the Integer object). To get its value you need to do the following:
- make sure it isn't NULL!
- get its class
- using the class, get the intValue() method
- call that method, the result is a jint.
 
H Padia
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Rob,

Your post helped me through.

 
Rob Spoor
Sheriff
Posts: 22209
117
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I would perhaps change one thing:
 
Beauty is in the eye of the tiny ad.
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic