Extensibility mechanisms

An item representing an external Java object (for example, the result of calling new() in a reflexive extension function call) may now be treated as a map. There is one entry in the map for each public non-static method defined on the object (either directly, or inherited), provided that its name is unique. If there are several methods with the same name but different arity, then they are available under suffixed names such as "action_0" and "action_1". But if there are several methods with the same arity, this group of methods is not included in the map. The key of the entry is the method name, while the value is a function item that may be called using dynamic function call syntax to invoke the method.

The conversion of the Java object to a map may be done explicitly or implicitly.

For example, the extension function sql:connect returns an external Java object of class java.sql.Connection. If $connection holds the result of this function, then $connection?isClosed() calls the isClosed method on the underlying object. The rollback method of this class has two variants; the arity-0 version may be invoked as $connection?rollback_0().

The conversion of XDM atomic values to Java values (when passing parameters to extension functions) now handles conversion of the XSD date/time types (xs:dateTime, etc) to the new Java 8 types java.time.ZonedDateTime and java.time.Instant.