JNI is now done. Almost complete support for all J2SE 1.4 JNI functionality. There are a few (permanent) restrictions:
- It's much slower than on a real JVM (most operations are between 10x and 100x slower).
- You cannot create a string instance with AllocObject and then call the constructor on it with CallNonvirtualVoidMethod. This is unlikely to be a problem, because there really is no reason to go through all this trouble to create a string. The normal ways to create a strings are NewString, NewStringUTF and NewObject and these work fine. If any app were found that depended on two step string construction, a workaround for that particular app could probably be added.
- JVM.DLL, which implements the three static invocation API functions, only works on Win32.
- JNI_CreateJavaVM only supports the JDK 1.2 style init args and only the -D option (to define Java properties).
- JNI_GetDefaultJavaVMInitArgs is not implemented. It's only used for JDK 1.1 style JVM creation, so I don't think it'll be used anymore. If anyone requires it, it could be implemented.
- JNI_GetCreatedJavaVMs only returns the JavaVM if the VM was started through JNI or a JNI call that retrieves the JavaVM has already occurred.
- JavaVM.DestroyJVM is only partially implemented (it waits until there are no more non-daemon Java threads and then returns JNI_ERR).
- JavaVM.DetachCurrentThread doesn't release monitors held by the thread.
JVM.DLL is really cool. It's a small stub created with ILASM. It's only a few lines of code and all it really does is export three managed functions to the unmanaged world. The ability to export managed functions is is a very nice CLR feature that is relatively unknown. On a Win32 system, any native application that hosts the Sun Java Virtual Machine can now use IKVM (without modifying the native app), simply by copying the IKVM DLLs into the native applications directory and removing the real Java VM JVM.DLL from the PATH.
- Imported new Classpath TimeZone handling. This still leaves TimeZone support in a very broken state, but at least the Classpath VM interface is now more powerful and should hopefully allow a correct implementation when I get around to it.
- Finally added namespaces to all public classes in IKVM.Runtime.dll. There are IKVM.Attributes, IKVM.Runtime, IKVM.Internal and IKVM.NativeCode. IKVM.Internal contains public types that really shouldn't be public, but have to be public because ikvm or ikvmc depend on them. In IKVM.NativeCode live the implementations of the GNU Classpath native methods.
Don't use the types in the IKVM.Internal or IKVM.NativeCode namespace in your own projects, because they are likely to go away or change in incompatible ways. IKVM.Attributes and IKVM.Runtime are going to be relatively stable (but they can still change up until the 1.0 release) .
- Added support for JNI thread detaching and waiting for all non-daemon threads to end to VMThread.java.
- Added GetClassFromTypeHandle method to ByteCodeHelper, this replaces the direct use of NativeCode.java.lang.VMClass.getClassFromType by JNI method stubs and synchronized static methods.
- Moved the various arraycopy methods from NativeCode.java.lang.VMSystem to ByteCodeHelper.
- Added getSystemClassLoader method to ClassLoaderWrapper.
- JavaException.cs: Removed message from ArrayStoreException and added InstantiationException.
- Added invocation API support to JNI.
- Renamed JniFrame to Frame and made it an innerclass of IKVM.Runtime.JNI.
- Implemented more efficient way to determine active JNI method class loader in JNIEnv.FindClass.
- Fixed JNI method resolution to look for short and long method names in each native library (previous it would first search all libraries for the short name and then in another pass would look for the long names).
- Added support for JavaVMAttachArgs to JavaVM.AttachCurrentThread.
- Implemented JavaVM.DestroyJavaVM.
- Implemented JavaVM.DetachCurrentThread.
- Implemented JavaVM.AttachCurrentThreadAsDaemon.
- Implemented JNIEnv cleanup when thread dies.
- Fixed JNIEnv.DefineClass to decode name as platform specific instead of UTF-8.
- Fixed JNIEnv.FindClass to decode name as platform specific instead of UTF-8.
- Fixed JNIEnv.SetPendingException to do exception mapping and set the stack trace.
- Fixed JNIEnv.ThrowNew to decode message as platform specific instead of UTF-8.
- Fixed JNIEnv.ExceptionDescribe to clear pending exception (and to actually work).
- Fixed JNIEnv.FatalError to decode message as platform specific instead of UTF-8.
- Added error handling to JNIEnv.AllocObject (if you try to create interface or abstract class instance).
- Added error handling and value type support to JNIEnv.NewObjectArray.
- Added value type support to JNIEnv.GetObjectArrayElement and JNIEnv.SetObjectArrayElement.
- Added error handling to the various JNIEnv.New<PrimitiveType>Array functions.
- Added error handling to the various JNIEnv.Get<PrimitiveType>ArrayRegion and JNIEnv.Set<PrimitiveType>ArrayRegion functions.
- Implemented growing the local ref table for native methods that use (or leak) excessive amounts of local refs.
- Changed stack and local variable type encoding of value types and enums to System.ValueType and System.Enum respectively (instead of simply System.Object).
- Fixed bug in bytecode compiler that caused it emit incorrect code when calling inherited methods on value types or enums.
New snapshots: just the binaries and source plus binaries.