Some usability problems have been identitied in the class QueryCompiler, which provides the API for Java code generation (new facility in Saxon 8.9).
if setClassName() is not called, an NPE occurs
there is a method compileJavaToByteCode() which has no effect. To compile the Java source code to byte code you should invoke the Java compiler directly; Saxon will not do this stage for you.
Nevertheless, an error is reported if no Java compiler can be loaded.
the method runQuery, which runs the query once you have compiled it to bytecode, is therefore rather misleading, and it only works if you compiled the Java classes into the same directory where the source code is held.
I will fix these in Subversion (and therefore in the next patch release) by making the following changes:
(a) if setClassName() is not called, the default class name "Query" will be used
(b) the attempt to load a Java compiler and report an error if none can be found will be removed from the code
(c) calling compileJavaToByteCode() will raise an UnsupportedOperation Exception
(d) the runQuery() method will be marked as deprecated.