Are DLL methods called as instance or static methods from Java ?

Hi,

I have only a small question.

When I call a C++ DLL method from Java using JNI, do I instantiate it like an object method or is it called as a static method ?

I am asking you this because I will use servlets (Java 1.2.2) to call a DLL. These servlets may run concurrently in any moment, and I pass some data to this DLL. I want to know if there is any possibility of this data becoming corrupt, because of one concurrent servlet rewriting the data another servlet has passed.

Thanks and regards.

[537 byte] By [brcard] at [2007-9-26 12:08:54]
# 1

The question is not specific enough.

Methods in C/C++ can be qualified with the following forms:

-global (C/C++)

-static member(C++ class method)

-instance member(C++ class method)

Since you didn't provide your code I couldn't possible determine which of the above you are using, but presumably you know.

On the other hand a java native method is either static or non-static depending on how you defined it in the class. Once again without the code there is no way to say and presumably you already know this.

The context of the methods is the same context that a similar servlet method has. But naturally in C/C++ is is easy to circumvent the context - for example by using a global variable.

Data in C/C++ can always become corrupt and in the vast (all?) cases it is because something is wrong in the C/C++ code. Like a pointer that is not initialized, or a pointer used after it is free'd. Or writing past the end of a buffer, or writing before the beginning of a buffer.

jschell at 2007-7-2 2:37:40 > top of Java-index,Java HotSpot Virtual Machine,Specifications...
# 2

Actually I think the question is clear enough, but perhaps represents a misunderstanding.

1. You can define a java (native) method that is either static or operates on an object instance.

2. Assuming that the native method is implemented as a subroutine in a DLL, one instance is loaded. SO any multi-threaded access you will have to handle.

I haven't had to face this, so I won't try to tell ou how to handle the synchronization.

bschauwe at 2007-7-2 2:37:40 > top of Java-index,Java HotSpot Virtual Machine,Specifications...