# Wednesday, July 18, 2012
« IKVM.NET 7.1 Released | Main | New Development Snapshot »
New Development Snapshot

I've been working on IKVM.Reflection to fix some loose ends and add support for various .NET 4.5 features. I also managed to squeeze in some bug fixes for IKVM.NET itself and some improvements to the (experimental and disabled by default) MSIL optimizer. Finally, I added intrinsics for some sun.misc.Unsafe operations to make some of the java.util.concurrent classes more efficient.


  • Bug fix. The interface fields exposed in the __Fields nested type should have a public field type.
  • Interface fields can always be marked as initonly and don't need final access stubs.
  • Disable AppDomain.ProcessExit hook to run shutdown hooks when running on Mono to workaround https://bugzilla.xamarin.com/show_bug.cgi?id=5650
  • Changed NoClassDefFoundError resulting from type initialization failure to be consistent with OpenJDK behavior.
  • Many improvements to the (disabled) MSIL optimizer.
  • Added intrinsics for (some usages of) Unsafe methods: putObject, putOrderedObject, putObjectVolatile, getObjectVolatile, getObject, compareAndSwapObject.
  • Marked String.compareTo(Object) as bridge method.
  • Remove org.omg.PortableInterceptor.UNKNOWN class, that is not part of [Open]JDK rt.jar.
  • Add ZipFile constructor that was added in Java 7.
  • Deprecated the ikvmstub -serialver option and added a -japi option instead that also adds non-public interfaces and members. Also added a hack to fix the fact that String instance methods were all marked as deprecated.
  • Internal stub generator now reproduces exact class modifier bits.
  • Unused class modifier bits are now properly masked and returned.
  • Non-abstract interfaces now properly return ACC_ABSTRACT modifier.
  • IKVM.Reflection: Added .NET 4.5 ModuleBuilder APIs GetMethodToken(MethodInfo, IEnumerable) and GetConstructorToken(MethodInfo, IEnumerable).
  • IKVM.Reflection: Added API extensions ModuleBuilder.__GetMethodToken() and ModuleBuilder.__GetConstructorToken().
  • IKVM.Reflection: Bug fix. SignatureHelper.AddArguments() should accept a null reference for arguments parameter.
  • IKVM.Reflection: Bug fix. SignatureHelper.GetMethodSigHelper(Module, Type, Type[]) should accept null reference for parameterTypes argument.
  • IKVM.Reflection: Bug fix. SignatureHelper.AddArguments(Type[], Type[][], Type[][]) should accept null references for requiredCustomModifiers and optionalCustomModifiers.
  • IKVM.Reflection: Bug fix. SignatureHelper.AddSentinel() should not affect the calling convention.
  • IKVM.Reflection: Simplified SignatureHelper implementation to make it more compatible with .NET and more efficient.
  • IKVM.Reflection: Added .NET 4.5 AssemblyName.ContentType property and ContentType=WindowsRuntime in AssemblyName.
  • IKVM.Reflection: Bug fix. ModuleBuilder.ResolveMethod() should return ConstructorInfo for constructors.
  • IKVM.Reflection: Made MethodSpec handling more consistent with MemberRef handling. This avoids the need for the caching the MethodInfo to token mappings (which leaks memory, because generic method instances are not canonicalized).
  • IKVM.Reflection: Removed unnecessary (and memory leaking) member ref caching level.
  • IKVM.Reflection: Explicitly disallow modifying a method signature after it has been used.
  • IKVM.Reflection: Added experimental support for generating Windows Runtime (.winmd) assemblies.
  • IKVM.Reflection: Added missing DefineResource() APIs to ModuleBuilder and AssemblyBuilder.
  • IKVM.Reflection: Fixed regression. Type.GetConstructor() should also return the class constructor. This also fixes Type.TypeInitializer.
  • IKVM.Reflection: Updated Assembly.CreateQualifiedName() to be compatible with current .NET versions.
  • IKVM.Reflection: Added new .NET 4.5 API Type.IsConstructedGenericType.
  • IKVM.Reflection: Added co-/contra-variance support to Type.IsAssignableFrom().
  • IKVM.Reflection: Added support for using the .NETCore v4.5 aka Metro profile mscorlib.dll.
  • IKVM.Reflection: Ignore HasFieldMarshal attribute and always return the pseudo custom attribute if a FieldMarshal record exists. This is similar to .NET reflection.
  • IKVM.Reflection: If a FieldLayout record exists, always return the pseudo custom attribute FieldOffset, regardless of the declaring type's layout.
  • IKVM.Reflection: Added new API [Field|Parameter]Info.__TryGetFieldMarshal().
  • IKVM.Reflection: Added new API FieldInfo.__TryGetFieldOffset().
  • IKVM.Reflection: Keep track of whether a ModuleBuilder has been saved (and only allow it to be saved once).
  • IKVM.Reflection: Fixed various builders to throw NotImplementedException (like .NET) when getting custom attributes before the type has been baked.
  • IKVM.Reflection: Fixed various builders to properly return custom attributes after the module has been saved.
  • IKVM.Reflection: Bug fix. FieldBuilder.GetRawConstantValue() didn't work after saving the module.
  • IKVM.Reflection: Bug fix. MethodInfo should return PreserveSigAttribute pseudo custom attribute if MethodImplAttributes.PreserveSig is set.
  • IKVM.Reflection: Added new API MethodInfo.__TryGetImplMap().
  • IKVM.Reflection: Changed DllImportAttribute synthesis to always include CharSet, BestFitMapping and ThrowOnUnmappableChar to be compatible with .NET. Now that we have __TryGetImplMap() we don't need to distinguish anymore between not set and set to the default value.
  • IKVM.Reflection: Added .NET 4.5 API CustomAttributeData.AttributeType property.
  • IKVM.Reflection: Made MarshalAsAttribute synthesis more compatible with .NET by always setting ArraySubType, SizeParamIndex, SizeConst and SafeArraySubType properties.
  • IKVM.Reflection: Made CustomAttributeData.ToString() output more compatible with .NET (by "casting" enum values, except zero).
  • IKVM.Reflection: Fixed MarshalAsAttribute values. Use enum underlying values, instead of the enum values.
  • IKVM.Reflection: Added UniverseOptions.DisablePseudoCustomAttributeRetrieval to disable returning pseudo custom attributes.

Binaries available here: ikvmbin-7.2.4582.zip

Wednesday, July 18, 2012 8:35:08 AM (W. Europe Daylight Time, UTC+02:00)  #    Comments [2]
Friday, July 20, 2012 1:38:01 AM (W. Europe Daylight Time, UTC+02:00)

I'm trying to convert an applet to a dll. When I try to, an exception is thrown:

System.NotSupportedException: 'Backward branch constraints' violated
at IKVM.Reflection.Emit.ILGenerator.Emit(OpCode opc, Label label)
at IKVM.Internal.CodeEmitter.RealEmitOpCode(OpCode opcode, Object arg)
at IKVM.Internal.CodeEmitter.DoEmit()
at IKVM.Internal.DynamicTypeWrapper.FinishContext.FinishImpl()
at IKVM.Internal.DynamicTypeWrapper.JavaTypeImpl.FinishCore()
at IKVM.Internal.DynamicTypeWrapper.JavaTypeImpl.Finish()
at IKVM.Internal.AotTypeWrapper.Finish()
at IKVM.Internal.DynamicClassLoader.FinishAll()
at IKVM.Internal.CompilerClassLoader.Compile(String runtimeAssembly, List`1
at IkvmcCompiler.Compile(String[] args)
at IkvmcCompiler.Main(String[] args)

It would be nice if you reply and try to fix it.
Tuesday, July 24, 2012 8:13:01 AM (W. Europe Daylight Time, UTC+02:00)
Thanks for reporting this. The bug is fixed in the new development snapshot:
Home page

I apologize for the lameness of this, but the comment spam was driving me nuts. In order to be able to post a comment, you need to answer a simple question. Hopefully this question is easy enough not to annoy serious commenters, but hard enough to keep the spammers away.

Anti-Spam Question: What method on java.lang.System returns an object's original hashcode (i.e. the one that would be returned by java.lang.Object.hashCode() if it wasn't overridden)? (case is significant)

Comment (HTML not allowed)  

Live Comment Preview