To prevent the crash, I've modified javapre.i line 197:

    iBase * ibase = (iBase *)$1.Ref;
    void * ptr =
ibase->QueryInterface(iSCF::SCF->GetInterfaceID($1.Type), $1.Version);

by

    iBase * ibase = dynamic_cast<iBase *>((iBase *)$1.Ref);
    if (ibase != NULL) {
       void * ptr =
ibase->QueryInterface(iSCF::SCF->GetInterfaceID($1.Type), $1.Version);
       ...
    }

This way it doesn't crash anymore... but still the console object is null...

Quentin

2008/9/22 Quentin Anciaux <[EMAIL PROTECTED]>:
> Hi,
>
> I've narrowed the problem:
>
> Here is the generated JNI code for Query registry, the problem is that
> "iBase * ibase = (iBase *)(&result)->Ref;" is null...
> So it seems the query registry cannot find the plugin... but if I
> execute with verbose, it shows these lines:
>
> [EMAIL PROTECTED]:~/crystalspace/workspace/crystalspace-tutorial-map/run/bin$
> cat log.log | grep cscon
> SCF_NOTIFY: registering plugin
> /home/qan/crystalspace/workspace/crystalspace-tutorial-map/run/crystalspace/lib/crystalspace-1.2/csconout.so
> in context `{none}'
> SCF_NOTIFY: registering class crystalspace.console.output.standard in
> context `{none}' (from
> /home/qan/crystalspace/workspace/crystalspace-tutorial-map/run/crystalspace/lib/crystalspace-1.2/csconout.so)
> SCF_NOTIFY: registering plugin
> /home/qan/crystalspace/workspace/crystalspace-tutorial-map/run/crystalspace/lib/crystalspace-1.2/csconin.so
> in context `{none}'
> SCF_NOTIFY: registering class crystalspace.console.input.standard in
> context `{none}' (from
> /home/qan/crystalspace/workspace/crystalspace-tutorial-map/run/crystalspace/lib/crystalspace-1.2/csconin.so)
> SCF_NOTIFY: loading plugin
> /home/qan/crystalspace/workspace/crystalspace-tutorial-map/run/crystalspace/lib/crystalspace-1.2/csconin.so
> to satisfy request for csConsoleInput
> SCF_NOTIFY: loading plugin
> /home/qan/crystalspace/workspace/crystalspace-tutorial-map/run/crystalspace/lib/crystalspace-1.2/csconout.so
> to satisfy request for csConsoleOutput
>
> So why doesn't it work ? I've seen thread with the Warning: Suspicious
> but it is about multiple crystalspace install... But I've only one
> installation, and the CRYSTAL variable is set.
>
> Thanks for any help,
> Quentin
>
> generated JNI code:
> SWIGEXPORT jobject JNICALL
> Java_org_crystalspace3d_cspaceJNI_CS_1QUERY_1REGISTRY(JNIEnv *jenv,
> jclass jcls, jlong jarg1, jobject jarg1_, jstring jarg2) {
>  jobject jresult = 0 ;
>  iObjectRegistry *arg1 = (iObjectRegistry *) 0 ;
>  char *arg2 = (char *) 0 ;
>  int arg3 ;
>  SwigValueWrapper<csWrapPtr > result;
>  char className2[1024] ;
>
>  (void)jenv;
>  (void)jcls;
>  (void)jarg1_;
>  arg1 = *(iObjectRegistry **)&jarg1;
>  {
>    const char * s = jenv->GetStringUTFChars(jarg2, 0);
>    const char * dot = strrchr(s, '.');
>    strcpy(className2, "org/crystalspace3d/");
>    strcat(className2, dot?dot+1:s);
>    arg2 = className2 + sizeof("org/crystalspace3d/") - 1;
>    jenv->ReleaseStringUTFChars(jarg2, s);
>    jclass cls = jenv->FindClass(className2);
>    jmethodID mid = jenv->GetStaticMethodID(cls, "scfGetVersion", "()I");
>    arg3 = jenv->CallStaticIntMethod(cls, mid);
>  }
>  result = CS_QUERY_REGISTRY(arg1,(char const *)arg2,arg3);
>  {
>    iBase * ibase = (iBase *)(&result)->Ref;
>    if (ibase != NULL) {
>        void * ptr = 
> ibase->QueryInterface(iSCF::SCF->GetInterfaceID((&result)->Type),
> (&result)->Version);
>        ibase->DecRef(); // Undo IncRef from QueryInterface
>        if (ptr == 0)
>        jresult = 0;
>        else
>        {
>        jlong cptr = 0;
>        *(void **)&cptr = ptr;
>        char cls_name[1024];
>        strcat(strcpy(cls_name, "org/crystalspace3d/"), (&result)->Type);
>        jclass cls = jenv->FindClass(cls_name);
>        jmethodID mid = jenv->GetMethodID(cls, "<init>", "(JZ)V");
>        jresult = jenv->NewObject(cls, mid, cptr, false);
>        }
>   }
>  }
>  return jresult;
> }
>
>
> 2008/9/20 Quentin Anciaux <[EMAIL PROTECTED]>:
>> Hi,
>>
>> I try to add a console using the
>> http://www.crystalspace3d.org/main/Cimstep1 tutorial with crystalspace
>> 1.2.1 on an ubuntu 64. I'm using the csjava binding (so the code is in
>> java).
>>
>> I register the plugin with:
>>
>>                plugins.add(new csPluginRequest(
>>                                "crystalspace.console.output.standard", 
>> "iConsoleOutput"));
>>                plugins.add(new csPluginRequest(
>>                                "crystalspace.console.input.standard", 
>> "iConsoleInput"));
>>
>> But when in the program I do:
>>
>> this.conout = (iConsoleOutput)cspace.CS_QUERY_REGISTRY(cspace
>>                                .getTheObjectRegistry(), 
>> iConsoleOutput.class);
>>
>> I got the following in the console:
>>
>> WARNING! Suspicious: object with tag 'iConsoleOutput' does not
>> implement interface 'iConsoleOutput'!
>>
>> and the program crash with:
>>
>> #
>> # An unexpected error has been detected by Java Runtime Environment:
>> #
>> #  SIGSEGV (0xb) at pc=0x00007f980b75b96b, pid=29215, tid=1082800464
>> #
>> # Java VM: OpenJDK 64-Bit Server VM (1.6.0_0-b11 mixed mode linux-amd64)
>> # Problematic frame:
>> # C  [lib26687.so+0x1bd96b]
>> Java_org_crystalspace3d_cspaceJNI_CS_1QUERY_1REGISTRY+0x225
>> #
>> # An error report file with more information is saved as:
>> # 
>> /home/qan/crystalspace/workspace/crystalspace-tutorial-map/run/bin/hs_err_pid29215.log
>> #
>> # If you would like to submit a bug report, please visit:
>> #   https://bugs.launchpad.net/ubuntu/+source/openjdk-6/
>> # The crash happened outside the Java Virtual Machine in native code.
>> # See problematic frame for where to report the bug.
>> #
>> Aborted
>>
>> Same thing if trying to get ConsoleInput first.
>>
>> I did have to modify cspace.i to add ivaria/conin.h to get
>> ConsoleInput and also added an iConsoleExecCallback implementation in
>> java-post.i. But it crash well before adding the callback, it crash at
>> the query registry.
>>
>> Do you have an idea why it crash and or what means : Suspicious:
>> object with tag 'iConsoleOutput' does not implement interface
>> 'iConsoleOutput'!
>>
>> Thank you,
>> Quentin Anciaux
>>
>> --
>> All those moments will be lost in time, like tears in rain.
>>
>
>
>
> --
> All those moments will be lost in time, like tears in rain.
>



-- 
All those moments will be lost in time, like tears in rain.

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Crystal-main mailing list
Crystal-main@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/crystal-main
Unsubscribe: mailto:[EMAIL PROTECTED]

Reply via email to