# Monday, 22 July 2002
No Title

I did lots of work on exception handling. Most of it now works (fully compatible with J2SE 1.4). Some highlights:

  • java.lang.Throwable is remapped to System.Exception (for maximum compability with .NET code)
  • Throwable.getMessage(), Throwable.getCause() & Throwable.toString() all work, and are fully compatible with J2SE 1.4. Additionally, the message is stored as the System.Exception.Message property, and when the exception object was constructed with a cause, the System.Exception.InnerException property is set.
  • Stack traces now work (fully Java compatible), except for J2SE 1.4 inner exceptions stack trace dumping.
  • I made the XML remapping language more powerful. It now supports calling helper methods and using locals to twiddle around with method arguments.

Things that don't work:

  • When .NET code prints a stacktrace from an exception thrown by Java code, the stacktrace only shows the stack from the last rethrow point in the Java code.
  • Throwable.printStackTrace() doesn't yet support Caused by: in the stack traces.
  • Additional exception information object (that contains the stacktrace and the cause)  is not yet garbage collected when the exception goes away.

Here is the testcase I used.

Updated the snapshot.

Monday, 22 July 2002 19:32:54 (W. Europe Daylight Time, UTC+02:00)  #    Comments [0]
# Tuesday, 16 July 2002
No Title

I cleaned up the Visual Studio .NET solution. For now it consists of the following projects:

    This is the Managed C++ project that implements the JNI interface.
    This is the Virtual Machine. It contains the Java classfile parsing, classpath native code, method compiler and various other bits.
  • ikvm
    This is a very simple C# program that starts up the VM and runs the class specified on the command line. The equivalent of java.exe in the JDK.

Other changes:

  • I decided to use a license derived from the zlib license.
  • gjc (Generic Java Compiler formerly known as Pizza) now runs (i.e. it compiles Hello, World)
  • The map.xml file is now an embedded resource

I updated the snapshot.

Tuesday, 16 July 2002 16:52:24 (W. Europe Daylight Time, UTC+02:00)  #    Comments [0]
# Saturday, 13 July 2002
No Title

Stuart commented on the previous item: ...That leaves #2, which seems hard to me. At the very least, it seems like it would require changes to the Java language compiler to interpret (at least metadata from) .NET classes and allow for those to be in the CLASSPATH at compilation time. Is that something you're interested in pursuing as part of IKVM, or do you regard it as a separate problem?

The way I plan to go about this, is to create a tool that generates jar files from .NET assemblies. The jar will contain all the public classes & interfaces from the .NET assembly, and all the methods will appear to be native. Standard Java compilers can then be used to compile against .NET code. The IK.VM will be aware of these special classes (they will contain an attribute to specify the fully qualified .NET type name) and reroute all access to these wrappers to the real .NET types. I haven't built any of this, but I don't expect any problems.

Saturday, 13 July 2002 10:31:48 (W. Europe Daylight Time, UTC+02:00)  #    Comments [1]
# Wednesday, 10 July 2002
No Title

I changed the Java to native code transition from my own MC++ marshaling to use the calli instruction. The code is much more elegant now, not to mention much faster. My database app now performs on a par with JDK 1.1. Not bad at all.

Also, I implemented support for interfaces that "override" java.lang.Object methods and I remapped java.lang.Comparable to System.IComparable. Both of these features use the same underlying mechanism, i.e. the ability to provide explicit interface implementations that redirect to virtual methods with a different name.

Wednesday, 10 July 2002 18:18:28 (W. Europe Daylight Time, UTC+02:00)  #    Comments [1]
# Monday, 08 July 2002
No Title

Many changes:

  • Added exception remapping support for some exceptions (NullReferenceException, IndexOutOfRangeException, InvalidCastException & TypeInitializationException)
  • Changed Throwable.printStackTrace() to print out stack traces in Java format
  • Partial support for retaining stack traces when exception is rethrown
  • java.lang.StringBuffer is now remapped to System.Text.StringBuilder
  • Rewrote file IO in classpath because it was buggy
  • Started on an ahead-of-time compiler that also emits debugging information (based on the debugging info in the Java classes)

Yesterday, I ran into a bug in MC++ when unboxing.

I've updated the snapshot and since I've made some changes to classpath, I've now put my modified version of that online as well.

Monday, 08 July 2002 12:28:53 (W. Europe Daylight Time, UTC+02:00)  #    Comments [0]
# Thursday, 04 July 2002
No Title

Updated the snapshot. Many fixes to the verifier and compiler and I also implemented a few more "native" methods. My company's database server product now works (at least partially), which is a pretty exciting step. It uses JNI to do its file I/O (because it runs on JDK 1.1), so it runs a little slower than under JDK 1.1, but hopefully that will improve once I've optimized the JNI method calling implementation.

Thursday, 04 July 2002 15:45:24 (W. Europe Daylight Time, UTC+02:00)  #    Comments [0]
# Tuesday, 02 July 2002

Just for fun, I tried to run a FFT program from the IBM Ninja (Numerically Intensive Java) package. After implementing a few more native methods, it ran, but to my surprise it ran about as fast as under JDK 1.4 (with Sun's Hotspot VM). Not bad for totally unoptimized code ;-)

The cfft.java source that I ran can be viewed here, the resulting executable (in a zip) can be found here and I've updated the project snapshot. For the array package, follow the Ninja link.

Tuesday, 02 July 2002 12:28:37 (W. Europe Daylight Time, UTC+02:00)  #    Comments [0]
J# released

Yesterday, Microsoft released J#. When I first looked at it yesterday, I was happy to find that they fixed the huge flaw that existed in beta 2. In the final version they have made java.lang.Object and java.lang.String aliases for System.Object and System.String. So they no longer require a "VerifierFix" to convert System.Object references to java.lang.Object references. Even so, they've decided to remove the AllowPartiallyUntrustedCallers attribute from the J# runtime libraries.

Unfortunately, the rest of the story isn't so positive. In only an hour of trying to compile my Java code, I already encountered three bugs in the compiler and one in the runtime. So I remain very sceptical about the quality of this product.

Tuesday, 02 July 2002 11:34:38 (W. Europe Daylight Time, UTC+02:00)  #    Comments [1]
# Friday, 28 June 2002
Status Update

"Hello, world!" is now fully verifiable. I haven't got all the corner cases of jsr support worked out, but the most important chunk of work in handling try {} catch {} blocks is now done. Next task is to translate the CLR exceptions (System.NullReferenceException, System.IndexOutOfRangeException, and may be others) into the corresponding Java exceptions.

Friday, 28 June 2002 16:03:39 (W. Europe Daylight Time, UTC+02:00)  #    Comments [0]
# Thursday, 27 June 2002
Status Update

"Hello, world!" now runs without first having to process the entire transitive closure of classes. It turns out that there is (what I feel) a bug in ModuleBuilder.GetType(string). It can be used to construct array types for types that have not yet been finished, but whenever you do that, it does fire the AppDomain.TypeResolveEvent, which caused me to finish the type (which wouldn't work because it was already in the process of being finished). Fortunately, it's easy to workaround, by setting a flag to ignore the TypeResolveEvent while inside ModuleBuilder.GetType().

Running "Hello, world!" takes slightly less than 2 seconds. So startup performance could be better ;-)

Thursday, 27 June 2002 14:33:14 (W. Europe Daylight Time, UTC+02:00)  #    Comments [0]