GNU Classpath 0.15 was released yesterday, so based on that I'm releasing a new version of IKVM. Besides the many improvements to GNU Classpath, there have been a bunch of IKVM fixes and two major new features: support for defining .NET properties and for applying .NET attributes. Both these features are controlled via the xml remap file. Here's an example Java class with corresponding xml file:
public class IntList
{
private int[] list;
public IntList(int size)
{
list = new int[size];
}
public void setItem(int index, int value)
{
list[index] = value;
}
public int getItem(int index)
{
return list[index];
}
}
<?xml version="1.0" encoding="utf-8" ?>
<root>
<assembly>
<class name="IntList">
<attribute type="System.Reflection.DefaultMemberAttribute, mscorlib" sig="(Ljava.lang.String;)V">
<parameter>Item</parameter>
</attribute>
<property name="Item" sig="(I)I">
<getter name="getItem" sig="(I)I" />
<setter name="setItem" sig="(II)V" />
</property>
</class>
</assembly>
</root>
When IntList.java is compiled to IntList.class and then ikvmc'ed using:
ikvmc IntList.class -remap:IntList.xml
The resulting IntList.dll will be usable from C# like this:
IntList l = new IntList(10);
l[4] = 42;
Console.WriteLine(l[4]);
Valdemar Mejstad created a tool to automatically generate the xml to define properties based on Java's java.beans.BeanInfo. The source is available here: MapFileGenerator.java.
Files:
ikvm-0.14-rc1.zip (source + binaries)
ikvmbin-0.14-rc1.zip (binaries)
Changes:
- Integrated GNU Classpath 0.15 release
- Dropped support for Mono 1.0.x, because Mono 1.1.x is now the recommended (by the Mono team) version to use.
- Made some optimizations to System.arraycopy().
- Removed the previously deprecated ikvm.lang.ByteArrayHack class.
- Merged fixes to gnu.java.nio.channels.FileChannelImpl from Classpath.
- Added CLR "bitness" (32 or 64) to ikvm -version output.
- Fixed ByteCodeHelper.DynamicCast() and ByteCodeHelper.DynamicInstance() to handle null references properly (always succeed/fail the cast/instanceof, without trying to load the type).
- Changed os.arch for "AMD64" to "amd64" to match JDK.
- Added sun.arch.data.model system property.
- Fixed VMThread.suspend()/resume() to not throw exceptions if invalid calls are done.
- Fixed VMThread.stop() to better handle suspended threads.
- Fixed a bug in invocation of JNI_OnLoad (if the method exited with a pending exception, the exception wasn't dispatched).
- Added GC.KeepAlive() to FileChannelImpl.flush() to make sure the file channel isn't GCed (and thus closed) while the native method is running.
- Fixed verifier to correctly identify stack overflows when double/long values are involved.
- Fixed verifier to reject empty try blocks.
- Fixed bug in VMTimeZone.inDaylightTime() [Fix by Alexander Zuev].
- Fixed a whole bunch of bugs in java.lang.reflect.Field [Reported by Alexander Zuev].
- Created two subclasses of CompiledTypeWrapper to handle the special cases for remapped and ghost type to make the normal types more efficient.
- Added a micro optimization to FieldWrapper to avoid having to call FieldInfo.IsLiteral on each reflective field access, because FieldInfo.IsLiteral turns out to be quite expensive on the Microsoft CLR.
- Removed -monoBugWorkaround switch from IKVM.GNU.Classpath.dll build script, since Mono 1.1.4 and later no longer require it.
- Fixed bug in protected member access check (it was too strict, requiring the referenced class to be visible).
- Improved error message when core library doesn't match runtime version.
- Implemented memory mapped I/O.
- Added support for defining properties through map.xml file.
- Added check to ikvmc to prevent signing assemblies that reference unsigned assemblies.
- Added support for adding custom attributes to assembly, classes, fields, methods and constructors in the map.xml file.
- Removed -enabletls option from ikvmc (fields can now be marked as thread local by adding a custom attribute).
- Added AssemblyCopyrightAttribute to IKVM.GNU.Classpath.dll.
- Fixed a bug in .NET type reflection handling of explicit method implementations.
- Fixed bug in JNI return value marshaling for methods with boolean return type.
- Fixed NullReferenceException bug when compiling class with native finalize method.
- Fixed JNI to continue to work during "finalization for exit".
- Implemented System.runFinalizersOnExit(boolean). By default, Java finalizers no longer run at application exit.