Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Steven Simpson Newsgroups: comp.lang.java.programmer Subject: Re: JNI and GetFieldID Date: Fri, 13 Sep 2013 13:31:09 +0100 Organization: A noiseless patient Spider Lines: 26 Message-ID: References: <7cstfa-3nc.ln1@s.simpson148.btinternet.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Info: mx05.eternal-september.org; posting-host="5d73dae2d5408493ae1c00c40513247d"; logging-data="22414"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/pNoUcgb7dEix8Qxt7Hevr4i81CkG4lH4=" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130804 Thunderbird/17.0.8 In-Reply-To: Cancel-Lock: sha1:viy8tw9vgZx9PKIAud/I8z02ZV0= Xref: csiph.com comp.lang.java.programmer:25280 On 08/09/13 11:29, Borneq wrote: > Inside StateProc I can call my_callback function, and ACEListProc will > be called inside native function. Native function can store env and > others parameters. But how within StateProc refer to this env and > other parameters? It's a bugger, isn't it?! > This parameters must be stored globally in data segment? Perhaps. This option would need some synchronization on the Java side to protect it, but I'm not sure that would suffice in some cases (e.g., when the class you lock on is loaded multiple times). A thread-local in C? Find out what the JVM uses for threads, and use its thread-local feature. Perhaps you can use the C callback just to build up a structure locally. When control returns from the library back to your JNI function, you iterate over the structure to invoke Java callbacks. I'm out of decent ideas. -- ss at comp dot lancs dot ac dot uk