Diego Gonzalez

.NET, movies & //TODO:

JVM-CLR bridge code in GDN

A year ago i have coded an native CLR-JVM bridge that allows to access code from one VM to the other, using P/Invoke, JNI, managed extensions and some .Net vodoo. The approach is very basic, for example to create an instance of a Java class from .Net code you have to write:
try
{
	JavaObject test = new JavaObject( "TestClass", "()V", null );
	test.CallMethod( "Do", "()V", null );
}
catch( JVMException e )
{
	Console.WriteLine( e.ToString() );
}
And in order to call .Net code from Java the following code can be written:
try
{
        DotNetObject dno = new DotNetObject( "mgdsample.dll", "mgd.Sample", new Object[] { new int[] { 23 , 32 } } );
        dno.CallVoidMethod( "Metodo", new Object[] { new String[] { "AVER", "SALIR" } } );
}
catch( CLRException e )
{
        System.out.println( e.Message );
}
The code was for a year in my machine andi really like to share it with you. I hope somebody found this interesting, there's a lot of code, and the code is not "production" code and please forgive any spanish comment. :)
My prototype also include a set of code generators that creates Java and .Net wrappers so classes in the other VM can be called using hard-typed classes avoiding the whole bridgind code.
The workspace with the code and a compiled version can be found here
Posted: Sep 23 2003, 09:51 PM by DiegoGonzalez | with 1 comment(s)
Filed under:

Comments

No Comments