# Monday, 02 October 2006
« New Snapshot | Main | New Snapshot »
New Snapshot

Again, a new snapshot. This time with some new magic to make Java boxed primitives integrate a little better with .NET string formatting. The following code now produces the expected result:

class test
  public static void main(String[] args)
    cli.System.Console.WriteLine("Java Magic = {0:X}", 0xCAFEBABE);
    cli.System.Console.WriteLine("Pi is approx. = {0:N2}", Math.PI);

To enable this, the Java box classes have to implement IFormattable. I added support to the remapping infrastructure for this:

<class name="java.lang.Double">
  <implements class="cli.System.IFormattable">

The ToString helper method is trivial:

public static String ToString(Double d, String format, IFormatProvider provider)
  return ((IFormattable)CIL.box_double(d.doubleValue())).ToString(format, provider);

Note that from the Java side this is mostly invisible (the exception being that you can now cast a java.lang.Double to cli.System.IFormattable, even though the interface is not visible thru reflection).


  • Added workaround for mono bug.
  • Added support for specifying java class names in map.xml attribute parameters of type System.Type.
  • Added support to remapping infrastructure for adding interfaces to classes (invisible to Java code).
  • Made java.lang.Byte, Short, Integer, Long, Float and Double implement IFormattable (privately, so this is invisible to Java code).

Source is in cvs. Binaries: ikvmbin-0.31.2466.zip

Monday, 02 October 2006 09:27:16 (W. Europe Daylight Time, UTC+02:00)  #    Comments [0]