In this section we outline some of the features of the Java language where conversion posed particular challenges, and explain briefly how these were tackled.
It's worth noting that there are broadly three classes of solution for each of these difficulties:
Create an automated conversion that handles the Java construct and converts it
to equivalent C#. Note that although this is an automatic conversion, it doesn't
necessarily have to handle every edge case, in the way that a productised converter
might be expected to do. In particular, it doesn't have to handle edge cases that
the Saxon code doesn't rely on: for example the converted code doesn't have to handle
null
as an input in exactly the same way as the original Java, if Saxon never
supplies null
as the input.
Convert with the aid of annotations manually added to the Java code. We'll see examples of some of these annotations later.
Eliminate use of the problematic construct from the Java code, replacing it with something that can be more easily converted. A trivial example of this relates to the use of names. Java allows a field and a method in a class to have the same name; C# does not. Simple solution: manually rename fields where necessary so that no Saxon class ever has a field and a method with the same name. (Very often, imposing such a rule actually improves the Java code.)
The following sections describe some of the difficulties, in no particular order.