Inner classes

Java effectively has three kinds of inner class: named static inner classes, named instance-level inner classes, and anonymous classes. Only the first of these has a direct equivalent in C#.

Saxon makes extensive use of all three kinds of inner class. The converter makes a strenuous effort to convert all of them to static named inner classes, but this doesn't always succeed. In some cases it can't succeed, because there are things that static named inner classes aren't allowed to do.

Sometimes the conversion can be made to work with the help of hints supplied as Java annotations. For example we might see the following annotation on a method that instantiates an anonymous inner class:

@CSharpInnerClass(outer=false, 
        extra={"net.sf.saxon.expr.XPathContext context", 
               "net.sf.saxon.om.Function function"})

This indicates to the converter that in the generated static inner class, there is no need to pass a reference to the outer this class (because it's not used), but there is a need to pass the values of variables context and function from the outer class to the inner class. (Annotations, like anything else in the Java source code, are parsed by JavaParser and made visible in the syntax tree.)