# Wednesday, July 7, 2010
IKVM.NET 0.44 Release Candidate 0

The first 0.44 release candidate is available.

What's New (relative to IKVM.NET 0.42):

  • Integrated OpenJDK 6 build 18
  • Bug fixes
  • Code cleanup
  • Many AWT improvements (by Nat and Volker)
  • IKVM.Reflection
  • Ability to build from source targetting .NET 4.0
  • Reflection optimizations
  • Codegen optimizations
  • JNI optimizations
  • Introduced IKVM.OpenJDK.Tools.dll
  • Improved build process (removed dependency on shipping stub jar binaries)
  • Improved ikvmc parameter validation and error handling
  • Annotated all security critical code with .NET 4.0 security model custom attributes
  • Added -nostdlib option to ikvmstub and ikvmc to allow them to work with .NET 4.0 assemblies (while running on .NET 2.0)
  • Implemented RuntimeMXBean and OperatingSystemMXBean
  • Experimental (when built from source, targetting .NET 4.0) support for class GC

Binary available here: ikvmbin-

Sources: ikvmsrc-, openjdk6-b18-stripped.zip

The sources zip no longer contains any binaries.

Wednesday, July 7, 2010 3:54:40 PM (W. Europe Daylight Time, UTC+02:00)  #    Comments [0]
Bug Reports

I've disabled the ability for anonymous users to post bug reports (and feature requests). Two useless duplicate reports (3026137 and 3026140) pushed me over the edge.

Some bug reporting tips:

  • Include all the (possibly) relevant information (IKVM.NET, .NET / Mono and Operating System version numbers, CPU architecture, error messages, warning messages).
  • Try to create a small repro that demonstrates the problem. Make sure it compiles, don't just include a non-compiling code snippet.
  • Clearly separate fact from speculation.
  • Read this excellent essay on How to Report Bugs Effectively by Simon Tatham.

P.S.  In the case of the above bug report, the poster tried to look at the code for ServerSocket.accept() with Reflector and Reflector crashed. This is a Reflector bug, it simply doesn't understand the code constructs that ikvmc generates (even though they are perfectly valid).

Wednesday, July 7, 2010 2:11:51 PM (W. Europe Daylight Time, UTC+02:00)  #    Comments [2]
# Wednesday, June 30, 2010
IKVM.Reflection Testing

I decided to do some brute force testing of IKVM.Reflection. I ran my LinkerPrototype on almost all assemblies in the .NET and Mono GACs. This resulted in a number of fixes to the linker (but note that it's still just a toy) and a bunch of fixes to IKVM.Reflection. Most of these fixes aren't relevant for IKVM.NET, but I want IKVM.Reflection to be useful as a general System.Reflection replacement.


  • MethodInfo.DeclaringType should return null for global generic method instances.
  • Fixed support for TypeSpec in custom modifiers.
  • Fixed bug that caused duplicate MethodSpec rows to be emitted.
  • Fixed bug that caused duplicate MemberRef rows to be emitted.
  • Allow use of generic method definition in IL stream.
  • Made signature binding lazy for GenericMethodInstance.
  • Allow declarative security attributes to use non-public constructors.
  • Implemented ManifestResourceInfo.FileName property.
  • Implemented workaround for incorrect exception table length in methods generated by VB compiler.
  • Fixed exception filter block handling to support having both regular handlers and a filter for the same try block.
  • Fixed metadata header to account for the actual ImageRuntimeVersion string length, instead of assuming it to be "v2.0.50727".
  • Implemented __GetDeclaredMethods() for ArrayType and MultiArrayType.
  • Fixed two MarshalSpec blob parsing bugs.
  • Fixed several places where generic type definitions would be encoded as TypeDef token instead of TypeSpec.
  • Re-instroduced generic type instantation for "identity" instantations of TypeBuilder types.
  • Several fixes for C++/CLI that tends to stick custom modifiers everywhere. Also, support void& in local variable signature.
  • Support fields that have an RVA, but where it is set to zero (C++/CLI does this).
  • Added support for a TypeRef with a null ResolutionScope.

The source is available in cvs and the LinkerPrototype zip link above contains the most recent IKVM.Reflection.dll, but if you want just the IKVM.Reflection.dll binary, it is available here: ikvm-reflect-0.43.3833.zip

Wednesday, June 30, 2010 10:47:31 AM (W. Europe Daylight Time, UTC+02:00)  #    Comments [0]
Apache PDFBox 1.2.0 Released

Yesterday the release of Apache PDFBox 1.2.0 was announced. Thanks to Daniel Wilson the included Ant build script to build the .NET version has been updated to work with IKVM.NET 0.42.

Wednesday, June 30, 2010 8:50:07 AM (W. Europe Daylight Time, UTC+02:00)  #    Comments [2]
# Monday, June 21, 2010
New Development Snapshot

One more development snapshot. A couple of minor tweaks.


  • Updated copyright notices.
  • Removed Winforms thread workaround timer that was previously required to make the thread abortable.
  • IKVM.Reflection: Fixed a couple of bugs related to escaped type names not being unescaped.
  • IKVM.Reflection: Changed assembly reference caching to be more efficient and to handle the fact that assembly identities can change (if it is an AssemblyBuilder).
  • IKVM.Reflection: Changed assembly identity caching to only add identities to the cache when they are used to look up the assembly.

Binaries available here: ikvmbin-0.43.3824.zip

Monday, June 21, 2010 10:36:02 AM (W. Europe Daylight Time, UTC+02:00)  #    Comments [2]
# Monday, June 14, 2010
CLR JIT Bugs Found During IKVM.NET Development

"It is actually fairly common that people notice that things fail under retail but not debug and tend to blame code generation.
While a code generation bug is possible, as a matter of statistics, it is not likely."
-- Vance Morrison

Date CLR Arch Type Description
2010-06-12 v4 x64 Incorrect code Optimizer incorrectly propagates invariants.
2010-06-04 v2, v4 x86 Crash Access violation while compiling code.
2010-04-11 v4 x64 Vulnerability Type safety vulnerability caused by incorrect optimization.
2009-10-28 v4 beta 2 x64 Vulnerability Type safety vulnerability in exception handler code.
2007-07-02 v2 x64 Exception System.InvalidProgramException on verifiable IL.
2007-05-11 v2 x64 Incorrect code 0.0 and -0.0 are considered the same by the optimizer.
2006-12-06 v2 x86 Vulnerability Ability to access array outside of bounds.
Monday, June 14, 2010 10:30:23 AM (W. Europe Daylight Time, UTC+02:00)  #    Comments [2]
New Development Snapshot

I finished all the .NET 4.0 security model changes. If you build from source, you can now (optionally) build on .NET 4.0 and get native .NET 4.0 assemblies that use the new .NET 4.0 security model (and also experimental class gc support). The .NET 2.0 binaries also work on .NET 4.0.

This is probably the final development snapshot before the first 0.44 release candidate and it has been tested more than a typical development snapshot. Please start testing it and, as always, feedback is appreciated.


  • Final set of .NET 4.0 security model changes.
  • Added "first-pass" build of IKVM.AWT.WinForms.dll and moved "native" AWT code from IKVM.Runtime.dll to IKVM.AWT.WinForms.dll.
  • Fixed verifier bug that caused verification errors if "new" string was interned before verifying any code. Thanks to Andrey Malakov for tracking this down.
  • Include more parts of tools.jar in IKVM.OpenJDK.Tools.dll.
  • Add feature to expand environment variables in system properties specified with -D ikvmc option.
  • Added jdk-tools target to openjdk.build to build javac.exe, javah.exe and javap.exe (not included in the default build).
  • Added build script to build ikvmdoc.exe (not included in the default build).
  • Fixed JNIEnv.DescribeException() (NPE instead of printing the exception).
  • IKVM.Reflection: When the user string heap overflows, throw an exception instead of silently creating corrupt image.
  • IKVM.Reflection: Fixed .PDB emitter to work with .NET 4.0. Thanks to Jb Evain for the heads up on this.

Binaries available here: ikvmbin-0.43.3817.zip

Monday, June 14, 2010 7:53:11 AM (W. Europe Daylight Time, UTC+02:00)  #    Comments [0]
# Tuesday, June 8, 2010
New Development Snapshot

I finally did the work necessary to improve the codegen for finally handlers. More improvements are still possible, but at least most finally handlers will now execute without touching the exception object (and hence without having to do any mapping/stack trace collection work). It also means that assembly file sizes are a little bit smaller and that the debugging experience should be improved (less exception catching & rethrowing).


  • Restructuring of verifier/analyzer code.
  • Fixed exception stack trace collection regression that caused frame part of the exception stack trace collection infrastructure to show up in some stack traces.
  • Make synthesized .class resources available via ClassLoader.getResources() (note the plural) as well.
  • Use a LinkedHashMap to preserve annotation order (but only in dynamic mode, because for compiled code we get the .NET attributes in unspecified order). By my reading of the API spec there is no guarantee about the ordering, but the Google Guice test suite depends on it.
  • TypeWrapper.AssertFinished() doesn't make sense for the static compiler anymore.
  • Moved mutable flags from Instruction array into separate array.
  • Made ExceptionTableEntry immutable.
  • Implemented codegen improvement to use CLR fault handlers for Java catch all handlers, whenever possible.
  • IKVM.Reflection: Order try blocks inside handlers before the entries for that handler. Workaround for CLR x86 JIT null pointer dereference bug.

Binaries available here: ikvmbin-0.43.3811.zip

Tuesday, June 8, 2010 8:24:58 AM (W. Europe Daylight Time, UTC+02:00)  #    Comments [0]
# Tuesday, June 1, 2010
New Development Snapshot

I got a little side tracked by the investigation of the Google Collections test suite performance issue, reported by Albert Strasheim in the comments to the previous snapshot.

This caused me to do some work on exception handling (unfortunately without any performance benefit to the Google Collections test suite) which, in turn, triggered something I've been wanting to do for while, namely to introduce a stub version of IKVM.OpenJDK.Core.dll which can be referenced by IKVM.Runtime.dll during FIRST_PASS compilation, to make it possible to have a cyclic dependency between IKVM.Runtime.dll and IKVM.OpenJDK.Core.dll for method signatures and not just the method bodies as was previously the case.


  • Added (limited) support to ikvmc for cyclic dependency compilation. The build now takes advantage of this to make it possible to use strongly typed method signatures for "native" methods implemented in IKVM.Runtime.dll.
  • Changed reflection to convert any Method|FieldAccessExceptions to occur (in partial trust) into IllegalAccessException.
  • Fixed type conversion verification issues in reflection dynamic methods.
  • Moved exception handling code to IKVM.Runtime.dll (for IKVM.OpenJDK.Core.dll) and cleaned up several issues. Changed mapping API to be more efficient (in terms of bytecode size, and to allow stack trace collection to be bypassed for discarded remapped exceptions).
  • Added new public API to unmap exception (ikvm.runtime.Util.unmapException()).
  • Fixed loop counter integer overflow bug in tableswitch bytecode parsing. Bug #3009543.
  • IKVM.Reflection: Fixed bug in constructor importing that could cause Module.ResolveMethod() on ModuleBuilder to return the underlying MethodInfo instead of the ConstructorInfo wrapper.

Binaries available here: ikvmbin-0.43.3803.zip

Tuesday, June 1, 2010 7:36:30 AM (W. Europe Daylight Time, UTC+02:00)  #    Comments [0]
# Tuesday, May 25, 2010
New Development Snapshot

More bug fixing and rounding out IKVM.Reflection.


  • Fixed resolution of generic type instance names with "fake" type as type argument.
  • Fixed bug in Finalize/finalize special casing for .NET types that caused exception when reflecting on them.
  • Fixed Finalize/finalize special casing for .NET types to also work for java.lang.Throwable derived types.
  • Removed fake core class library types from ikvmstub and added a -bootstrap option to run without dependency on runtime/core class library.
  • Fixed regression introduced when ikvm.runtime.Startup.setProperties() signature was changed. It should also be changed in the executable main stub.
  • Fixed ikvmc/ikvmstub regression introduced with the switch to IKVM.Reflection (not IKVM.Reflection.Emit) in volatile field handling acros assemblies.
  • Fixed several bugs exposed by Google Guice 2.0 test suite (bug #3004682).
  • Fixed AssemblyClassLoader so that it does not claim to be able to load .class resources for dynamically loaded classes.
  • When compiling with the -sharedclassloader option we can't do the "effectively final" optimization, because classes in another assembly can be part of the same package (and hence extend the packge private class).
  • Handle the case where the exception block ends at the end of the method.
  • IKVM.Reflection: Implemented Type.IsAssignableFrom() (minus co-/contravariance).
  • IKVM.Reflection: Implemented custom attribute filtering at the source. Added support for custom attribute sub typing.
  • IKVM.Reflection: Added __GetCustomAttributes() overloads for Assembly and Module for ease of use and consistency.
  • IKVM.Reflection: Added ICustomAttributeProvider interface.

Binaries available here: ikvmbin-0.43.3797.zip

Tuesday, May 25, 2010 6:28:37 AM (W. Europe Daylight Time, UTC+02:00)  #    Comments [2]