I am using jni4net to access Java code from within a C# application, and vice-versa. jni4net uses reflection to generate JNI code proxies, so obviously one of the limitations is that your Java and C# code have to compile in order to build proxies.
Unfortunately this can result in a catch-22 problem. Consider:
C# class X uses Java class Y
Java class Y uses C# class X
Neither can be compiled, so the well established workaround is to take one of the classes (either X or Y), strip it down to its bare signature and get it to compile and then generate the proxy from the compiled skeleton. You can then replace the stripped class with the original and go on your merry way.
This seems like an ugly approach to me and I believe there should be a better way. An obvious solution would be to tell the compiler (either C# or Java, it really does not matter which) to ignore references to the missing class.
Is ignoring references to a certain missing class feasible for either the C# or Java compilers? Is there a better way to do this (and no, I am not open to considering sockets or anything of that nature; I require true interop between .NET and Java)?
Example code was requested:
Example code with jni4net bridge code removed for clarity. IA and IB are simple interfaces also not included.
Java:
public class A implements IA
{
public void m1()
{
System.out.println("m1 called");
}
public static void main (String args[])
{
IB b = new B();
b.m2(new A());
}
}
C#:
public class B : IB
{
public void m2(IA a)
{
a.m1();
A a2 = new A();
a2.m1();
}
}