For a project of mine i am working with the Java Native Interface (JNI).
My project contains a JNI System that calls a function on de C++ side with a port parameter. This function than returns a Object array as written in the comments below, the problem is stated in the last comment:
public Integer SpawnNewConnectionHandler(Integer Port) throws WrapperException {
//Creation of the object array that will hold the result
Object[] result;
//Get the result object array from the external library. Length of the array is either 1 or 2.
//While debugging i found out that it contains two elements of the type int (Not integer, but its basetype).
//This means that nothing on the c++ side went wrong.
result = spawnNewServerConnectionHandler(Port);
//Error coming from the SDK should be handled here. (Code snipped as the if clause checking for it, is not being called.)
//The snipped will throw a WrapperException if the length of the array returned is not 1.
//The debugger will break here and show me that before executing this line both of the result objects are not empty,
//So result[0] and result[1] are filled with data, for result[1] it is a 1 or higher. For result[0] is is the number 0. (Returned as a fact that everything went alright while executing.)
//During execution of this line the program crashes and shows a NullPointerException.
//
//I found out that it is impossible for it to cast the object, stored in the object array as a int into a Integer.
//Doing this manually while debugging shows the following error message:
//"Unable to cast numeric value to java.lang.Integer."
return (Integer) result[1];
}
Does anybody know a solution to this problem, or at least why it is giving me this weird error?