does native keyword imply static?

In out project we have two DLLS which export the same JNI functions.

We have a single base class which interfaces to them then two subclasses which implement specific functionality (ie. the DLLS are plugins that conform to a spec, the java classes are the specific classes to load the dlls).

All the native method definitions are held in the base class.

Each class works individually when its the only one instantiated, and even loads the correct DLL.

However when they are both instantiated at the same time only the first one is used. The only way I can see this happening is if native methods in java class definitions were also static.

(for further reference the code is like this)

Base ContactListclass

|

+-ContactInterface1

|

+--ContactInterface2

We never instantiate base only the 1 and 2 (which represent different contact storage mechanisms) the DLLs they load each implement specific functionality (one local and one remote) and have the same exports.

[1068 byte] By [tonymilliona] at [2007-11-27 7:40:19]
# 1

> In out project we have two DLLS which export the same JNI functions.

Then you are doing something wrong.

Say you have TWO classes

class MyClass1

{

public native void doit()

}

class MyClass2

{

public native void doit()

}

The names of the above native methods WILL be different in your C/C++ code.

The only way that the names can be the same is if the package, class name and method signature are all the same. And if that is the case then how do you intend to load two classes which have exactly the same package and name?

> (one local and one remote) and have the same exports.

I can only guess that you think that you are going to switch back an forth between the two. If so then either need to different java classes or you need a way to do the switch in the C method itself.

Note that you can use the same name, if and only if, the dlls are named ifferently and you use custom class loaders for both classes (not that this second part has nothing to do with JNI, it is the only way you can do that in java by itself.)

jschella at 2007-7-12 19:20:49 > top of Java-index,Java HotSpot Virtual Machine,Specifications...