The Mono Beta 1 was released today and I've prepared a new snapshot that works with this version to test interoperability.
What's new?
- Fixed ik.vm.jni.build to create output directory.
- Added Profiler.Count calls to ByteCodeHelper.cs for dynamic helper methods.
- Fixed TypeWrapper.IsSamePackage to handle case where one type is array and other isn't.
- Fixed bug introduced in last snapshot in bytecode compiler, that caused NullReferenceException if exception block starts on an unreachable instructions.
- Added exception handling to VMRuntime.exec.
- Added -Xwait option to ikvm, to keep the process hanging around (this is just a hack so I can look at the console window that contains the profiling statistics and trace messages after Eclipse has exited).
- Fixed ikvmc to ignore Main-Class attribute when building a library.
- Implemented JNI methods AllocObject and ReleasePrimitiveArrayCritical (on Windows JNI provider only).
- Fixed resource loading from -Xbootclasspath.
- Fixed a minor bug in remapped type handling.
- Changed map.xml format to support future metadata annotations (thanks Stuart!).
- Fixed handling of final fields in ikvmc.
- Changed handling of shadow types (e.g. cli.System.Object now extends java.lang.Object and cli.System.String exists side by side with java.lang.String).
- Fixed support for deserializing final fields.
- Fixed java.lang.Class/VMClass to no longer require VMClass instances (Class now contains direct reference to TypeWrapper).
- Added the managed part of the Mono JNI provider to CVS and the build script (and the snapshot).
- Updated the SharpZipLib reference to the latest version.
- Locked to GNU Classpath 0.09 and changed classpath build directory to ../../classpath-0.09
- Fixed Thread.sleep() to support larger values than Integer.MAX_VALUE
Linux Lamer
Since I'm a Linux Lamer (tm), I'm documenting the steps here to get JNI to work with Mono (primarily for my own use).
- cd /usr/local/src/classpath-0.09
- ./configure --with-jikes --disable-gtk-peer
- make
- cp include/jni.h /usr/local/include/
- cp include/jni_md.h /usr/local/include/
- cd ../mono-0.91/ikvm-jni/
- make && make install
- cd ../jnitest
- vi test.java
class test {
public static void main(String[] args) {
System.loadLibrary("test");
nativeMethod();
}
static native void nativeMethod();
}
- jikes -cp ../classpath-0.09:../classpath-0.09/vm/reference:../ikvm/classpath test.java
- vi test.c
#include <stdio.h>
#include <jni.h>
JNIEXPORT void JNICALL Java_test_nativeMethod(
JNIEnv* env, jclass clazz) {
printf("Hello from JNI\n");
}
- gcc -shared test.c -o libtest.so
- export LD_LIBRARY_PATH=.
- ikvm test
New snapshots: just the binaries and source plus binaries.
The GNU Classpath release that this is based on can be downloaded from ftp://ftp.gnu.org/pub/gnu/classpath/classpath-0.09.tar.gz
Note that anon cvs for SourceForge is apparently still lagging behind, so at the moment I'm posting this, anon cvs does not yet contain the latest changes.