# 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]
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