Now that 0.30 has been released, it's time to talk about the next version. While 0.30 was baking, I've made some significant changes. People sometimes ask me why the version number is so low, part of the reason is that I anticipate that I'll need to make breaking changes a couple more times.
Moved Runtime API to IKVM.GNU.Classpath.dll
To make the runtime API easier to use and to allow (potential) future changes that remove the need for IKVM.Runtime.dll to discover IKVM.GNU.Classpath.dll, I moved the public API of the runtime into IKVM.GNU.Classpath.dll. Now, IKVM.Runtime.dll still exposes a bunch of public types, but you should not use any of these, they are "undocumented" and only for use by ikvmc generated code and IKVM.GNU.Classpath.dll. They will also change in future versions.
Revisiting the ClassLoader per Assembly Idea
Over the past couple of years I've slowly come around on my initial decision to have all classes in assemblies appear to be loaded by the boot class loader. My initial reluctance was mostly due to the fact that using a ClassLoader per assembly would require violating the ClassLoader delegation model, but the success of OSGi (which does the same) demonstrates that this isn't such a big deal.
Here are some of the advantages:
- Each assembly will be its own namespace, meaning that things like Class.forName() and Class.getResource() will be able to search the calling assembly first, so you won't get into class or resource name conflicts as easily.
- It removes the need for the hack that returns the system class loader, instead of null, for statically compiled classes.
- It allows for many operations to be more efficient.
- It removes the need for pre-loading assemblies to make Class.forName() work, because the assembly class loader will be able to search all referenced assemblies (i.e. ikvmc's -reference option will be honored by the assembly class loader).
- You will be able to take full advantage of .NET assembly namespace separation (i.e. multiple versions of a jar can be compiled and used in the same AppDomain, by different pieces of code).
- It allows for a more natural integration of ReflectionOnly support (when running a .NET 2.0 build of ikvmc or ikvmstub).
I made a new snapshot that you can play around with to evaluate how the change will impact you. Please let me know, now's the time to convince me to change some of the details
Here's a full list of changes in this snapshot:
- Changed class loader architecture to represent each .NET assembly with its own class loader.
- Changed system class loader to the application entry assembly class loader (except if the java.class.path system property is explicitly set, then you get a URL class loader that loads from the specified class path).
- Ported stub class generator from C# to Java and incorporated it into IKVM.GNU.Classpath.dll.
- Hooked up assembly class loader resource loading with stub generator, to support loading .class stub files for .NET and statically compiled classes.
- Changed ikvmstub to create stub classes by simply loading them as resources.
- Removed IKVM.Runtime.Util methods that existed for ikvmstub.
- Fixed runtime/ikvmc to no longer depend on the CLR interning string literals.
- Runtime no longer locks the class loader instance before calling loadClass.
- Removed old mono bug work arounds from jni code.
- Class.getProtectionDomain() now returns a more meaningful ProtectionDomain (including a CodeSource) for statically compiled Java code and .NET assemblies.
- Moved VMSystem.setIn/setOut/setErr implementation from C# to Java.
- Changed the way final instance fields are handled (added a private setter method to the property) to remove the need for the runtime to correlate the field with the property.
- Fixed final field property accessor generator to make sure that the generated method name doesn't clash with other methods.
- Moved IKVM.Runtime public API to IKVM.GNU.Classpath (and renamed to namespace and method names to follow Java naming convention).
- Set system property to disable usage of Graphics 2D by Swing implementation.
- Added java.vendor.url.bug, java.runtime.name and java.runtime.version system properties.
Source is in cvs. Binaries can be downloaded here: ikvmbin-0.31.2421.zip