Are there a way to attach to the env pointer a native object? Let mebe more clear.I have the following native function (simplified):solve(JNIEnv * env , jobject obj1 , void* alpha){....nativeobject *native1 = new nativeobject;}and I wan to acces the j1 object form another native functionsetup (JNIEnv * env){....}If I have only the C part, I would cast the "native1" object, pass to"setup" and cast back the object, but since the setup function iscalled from java, I don't know how to access native1 object from"setup". Is it possible? Thanks
|
|
0
|
|
|
|
Reply
|
edsoncv (22)
|
3/2/2007 4:05:22 PM |
|
On 2 Mar 2007 08:05:22 -0800, Edsoncv wrote:> If I have only the C part, I would cast the "native1" object, pass> to "setup" and cast back the object, but since the setup function is> called from java, I don't know how to access native1 object from> "setup". Is it possible?Of course. Either store it someplace in the native code where it's visible toboth methods (i.e. not as a local variable in solve() like yourexample).Or, remembering that even native methods have return values, return itto the caller (cast to jlong) so that it can be passed back to thenext method, where you cast it back to the appropriate pointer typebefore attempting to use it./gordon-- [ don't email me support questions or followups ]g o r d o n + n e w s @ b a l d e r 1 3 . s e
|
|
0
|
|
|
|
Reply
|
Gordon
|
3/2/2007 5:17:25 PM
|
|
On Mar 2, 2:17 pm, Gordon Beaton <n...@for.email> wrote:> On 2 Mar 2007 08:05:22 -0800, Edsoncv wrote:>> > If I have only the C part, I would cast the "native1" object, pass> > to "setup" and cast back the object, but since the setup function is> > called from java, I don't know how to access native1 object from> > "setup". Is it possible?>> Of course.>> Either store it someplace in the native code where it's visible to> both methods (i.e. not as a local variable in solve() like your> example).>> Or, remembering that even native methods have return values, return it> to the caller (cast to jlong) so that it can be passed back to the> next method, where you cast it back to the appropriate pointer type> before attempting to use it.>> /gordon>> --> [ don't email me support questions or followups ]> g o r d o n + n e w s @ b a l d e r 1 3 . s eThanks Gordon, I think I'll pick the second option.
|
|
0
|
|
|
|
Reply
|
Edsoncv
|
3/2/2007 6:49:27 PM
|
|
|
2 Replies
88 Views
(page loaded in 0.058 seconds)
Similiar Articles: comp.lang.java.programmer - page 21JNI Question #4 0 2 (7/8/2003 8:37:35 AM) Hi : may my describtion for the problem was not clear , my graduation project in the faculy is Network Monitoring , after ... ERROR: JDWP Unable to get JNI 1.2 environment? - comp.lang.java ...... Post Question | Groups ... Reference that discusses the Java Native Interface, but it is unclear to me whether that ... HBA Queue Depth - comp.unix.solarisIs there some reason you had to post this question three times in an hour? ... second one is what the QLogic cards reference. > The first one is used by the JNI ... 32 bit applet on 64 bit Java? - comp.lang.java.programmer ...I have a 32 bit java applet which accesses JNI library which accesses some other ... Anyways, "it's always worked before" is not exactly a sign that the code in question ... calling a VB6 .DLL from java - comp.lang.java.helpI've been looking into JNI, but I can't quite figure out if this will be supported. ... Java Answers discussion forum, where you can ask and answer Java programming questions. Interop. problem with OpenSSL? - comp.lang.java.security ...Hi all, We have a JNI wrapper around OpenSSL that we are using to successfully ... Post Question | Groups | ... FC devices disappear after patching Solaris 9? - comp.unix.solaris ...... Post Question | Groups | ... causes devfsadm to not understand that the devices presented by the Emulex and JNI ... java deployment for web: UnsatisfiedLinkError - comp.soft-sys ...... Post Question | Groups | ... MWMCR.mclIsStandaloneMode()Z > > I have read that this error is caused by JNI ... SUN StorEdge 2G FC PCI adapters - comp.unix.solarisNmon fiber card output question - comp.unix.aix I executed Bonnie ... > systems ... Factory Configurable JNI 2 Gb PCI FC HBA's with Sun StorEdge SFS... JNI 2 Gb PCI ... H.263 codec video encoding/decoding - comp.soft-sys.matlab ...... Post Question | Groups ... There is something called JNI(Java Native Interface) but does matlab have some alternative? JNI question: java, jvoid - Experts Exchange - Your Technology ...Hi Experts, I need to use a C library in my Java program. When I was going through the examples on the web, I understand JNI is basically done the ... HELP!!! JNI Question using NEtbeans!? - Yahoo! AnswersBest Answer: JNI is a bridge to use C/c++ libraries. It makes your java code non-portable, but it allows you to use libraries instead of having to re ... 7/7/2012 4:20:57 AM
|