This is the mail archive of the java@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: JNI without Jni_Lookup() ?


> You can't know until runtime which is the one to use (unless you design some way to
> tell gcj about it ahead of time). 

To give an example for fixing code broken, because of overloaded native methods:

public JniClass
{
	/* may lead to ambiguous javah-generated 
	jni signatures
	when one of both is removed */

	private native String f(int i);
	private native String f(long l);
}


Can easily be fixed as following:


public JniClass
{
	private String f(int i)
	{
		return fInt(i);
	}
	
	private String f(long)
	{
		return fLong(l);
	}

	/* home-cooked name mangling :-) */

	private native String fInt(int i);
	private native String fLong(long l);
}


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]