1

I have for work to modify an old dll written in 2005 in c++. I have installed Eclipse Oxygen, cygwin with gcc, gdb and make.

I have searched in many places, made many changes in my project properties but my problem is here anyway : I have 5 errors "Invalid Arguments".

my code :

#include <jni.h>
#include "core_dll_ModDriver.h"
#include <stdio.h>
#include <iostream>

JNIEXPORT jobjectArray JNICALL Java_core_dll_ModDriver_EtatSupport(JNIEnv * env, jobject o)
{
    const int nbFen = 4;
    const char FAR* name = "EtatSupport";
    char* fen1 = NULL;
    char* fen2 = NULL;
    char* fen3 = NULL;
    char* fen4 = NULL;
    loadDll();
    if ( isDllLoaded() )
    {
        typedef unsigned char ( __stdcall * Function)( char*, char*, char*, char* );
        Function function = (Function)getDllFunction( name );
        if ( function != NULL )
        {
            char error = function ( fen1, fen2, fen3, fen4 );
        }
        else
            std::cout << "echec" << name;
        closeDll();
    }
    jobjectArray result = env->NewObjectArray( nbFen, env->FindClass("java/lang/String"), NULL );
    jstring jfen1 = env->NewStringUTF( fen1 );
    jstring jfen2 = env->NewStringUTF( fen2 );
    jstring jfen3 = env->NewStringUTF( fen3 );
    jstring jfen4 = env->NewStringUTF( fen4 );

    env->SetObjectArrayElement( result, 0, jfen1 );
    env->SetObjectArrayElement( result, 1, jfen2 );
    env->SetObjectArrayElement( result, 2, jfen3 );
    env->SetObjectArrayElement( result, 3, jfen4 );
    return result;
}

And I have "Invalid Arguments" with NewObjectArray, and all SetObjectArray.

Line 27 Invalid arguments' Candidates are : _jobjectArray * NewObjectArray(?,_jclass *,_jobject *)' Line 33,34,35,36 Invalid arguements' Candidates are : void SetObjectArrayElement(_jobjectArray *,?,_jobject *)'

Calimero79
  • 13
  • 4
  • Please provide the exact output from the error. Try the "Console" view in Eclipse. (For example, you have no associated line number of the errors, etc) – Jonah Graham Jul 26 '17 at 12:21
  • done in the original post – Calimero79 Jul 26 '17 at 12:41
  • The two question marks happen to be for `jsize` arguments. Any chance you've got a redefinition of `jsize` elsewhere? New compilers might be more vulnerable to violations of the One Definition Rule. – MSalters Jul 26 '17 at 13:51
  • Also, please quote the real errors. I'm quite certain they won't contain "arguements". – MSalters Jul 26 '17 at 14:13
  • The errors added look like the ones from the Problems view, which is just a summary/simplification. Additional details (including the output from the compiler and the command line options used for g++) will be in the "Console" view. – Jonah Graham Jul 26 '17 at 14:18
  • Possible duplicate of [Eclipse giving me Invalid arguments ' Candidates are: void \* memset(void \*, int, ?) ' though I know the args are good](https://stackoverflow.com/questions/13021594/eclipse-giving-me-invalid-arguments-candidates-are-void-memsetvoid-int) – Basya Jul 26 '17 at 15:02

1 Answers1

1

The first thing to realize is that the "Invalid arguments" error you're getting is coming from Eclipse's own code analysis, not from the compiler. It shouldn't actually be blocking you from building or running your code, it's just an annoyance.

Having established that, the cause of this error is usually a problem with the project configuration, and may be specific to the platform, Java version, etc. (I, for example, do not get such errors on this code on Linux, with GCC 6 and Java 8).

As @Msalters already pointed out in a comment, the errors seem to be caused by Eclipse not being able to resolve the type jsize. To investigate this, I would open up the header jni.h (you can do via "Open Declaration" on the #include for it), find the definition of jsize, and see if there's anything there that might indicate why it doesn't resolve. To rectify the problem, you may need to make adjustments to your project configuration such as specifying additional include paths or defining additional macros.

HighCommander4
  • 50,428
  • 24
  • 122
  • 194
  • 1
    problem solved. my jni.h call a jni_md.h in another directory that my project didn't know. I have modified the path to that diretory and it's solved. Thank for help – Calimero79 Jul 27 '17 at 06:15