[cfe-dev] clang via JNI + libclang-c
Anton Smirnov
dev at antonsmirnov.name
Fri Oct 11 02:17:04 PDT 2013
i tried to hold CXIndex as static variable in native code (array of
pointers to be more detailed) and pass just index to java back and then
pass index to native code in order to hold variable in native code without
passing.
Still the same result.
I can check it easily using clang_getTranslationUnitSpelling().
Before passing it returns filename and ater packing/unpacking (even using
index) it returns nothing.
2013/10/11 Renato Golin <renato.golin at linaro.org>
> On 11 October 2013 10:02, Anton Smirnov <dev at antonsmirnov.name> wrote:
>
>> The problem is that if i do in the same invocation from java (f.e. in
>> single Java_name_antonsmirnov_clang_clang_1wrapper_tokenize() function) -
>> it works good.
>> For example if i just remember parameters and then create index, parse,
>> tokenize (clang-c invocations) within tokenize() method it's okay.
>>
>> If i do everything in separate native methods (clang-c invocation in
>> separate native calls from java) (as it's designed to do) pointers are
>> corrupted.
>> So unpacked CXIndex in parse() invocation is corrupted even if it was
>> packed/unpacked correctly and the pointer is the same.
>>
>
> This looks a lot like standard JNI stack corruption to me. This is the
> exact same behaviour I've seen in JNI 10 years ago, and I'm not surprised
> they're still there...
>
> cheers,
> --renato
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20131011/3ea84065/attachment.html>
More information about the cfe-dev
mailing list