I’ve managed to get a tiny bit of work done on the new JNI wrapper I was working on. It now allows you to get and set non-static fields. Also methods to call non-static object methods and static boolean, byte and char methods have been added. You can download a copy here: http://www.ibeblog.com/files/JNIForDelphi%200.2.rar

I’m currently developing a new modernized JNI wrapper for Delphi 2010 and up. The old wrappers found here and here do work, but my wrapper requires less work to set up and uses a lot of new Delphi language features to ensure it works smoothly. The wrapper has been rewritten from scratch to include all features of JNI in JDK 1.6. Note that this wrapper is NOT backwards compatible with the old JNI wrappers, but switching to this one shouldn’t be too hard. At the moment the wrapper itself is far from complete, but it’s a preview including a small sample application. Afterwards I might also be wrapping JVMTI and create a bigger more user-friendly framework to encapsulate JNI. You can download the preview here: http://ibeblog.com/files/JNIForDelphi%200.1.rar

So you know Delphi or Java and want to learn the other language? A very important thing to know is what datatypes you are using, as these differ in each language.

As you may know, Java does not have any unsigned datatypes, Delphi however has both signed and unsigned datatypes. Because of this the unsigned types are not listed in the table below, but in order for the integer types these are Byte/UInt8, Word/UInt16, Cardinal/LongWord/UInt32, UInt64. Delphi also has ansi strings/chars, these can be stores in string and Char but those can also hold unicode versions, the actual ansi types are AnsiString and AnsiChar. And of course Delphi also comes with a Pointer type as well as it has the ability to create types that hold pointers to specific types.

ShellSort is not a comparison-based sorting algorithm like those previously shown on this blog, it uses the property of InsertionSort that nearly sorted arrays of values are sorted very quickly. It has a performance of O(n log² n) which makes it a lot faster than a lot of other algorithms, certainly the O(n²) ones, but not entirely the fastest.

SelectionSort is another sorting algorithm that has a performance of O(n²) like BubbleSort. It sorts an array of numbers by finding the smallest element in the unsorted part of the array and switching it with the current item. This is repeated until the entire array is sorted.

The bubblesort algorithm is one of the slowest sorting algorithms around as it’s performance is O(n²). As a result of this the algorithm is barely ever used in any real life applications, however, even though the algorithm will always stay rather slow, it can be tweaked to improve the code’s performance.

The implementation of the algorithm you see below has been optimized in various ways and it also makes use of the property that all items in an array of numbers that come after the last index that was sorted in a run through the array by the algorithm are already sorted.