What's new in 0.3

szegedi edited this page Jul 21, 2012 · 4 revisions

Changes in 0.3 compared to 0.2

Major new features

  • New "dyn:new" operation for creation of instances.
  • java.lang.Class objects accessed through BeansLinker have a synthetic property named "static" which exposes an object representing the static facet of the class; that is, a request for "dyn:getProp:static" on a Class will return it.
  • Static facet of the class exposes all public constructors (it answers with constructors to "dyn:new"), static methods, static fields and static property getters/setters for the class. Classes of arrays also have a constructor that takes a single int as the length of the array. Full overload resolution and vararg handling applies to statics too.
  • New call site class, ChainedCallSite can remember several already linked methods and build guardWithTest() chains from them. Usually performs better than MonomorphicCallSite.
  • ConversionComparator interface that can be implemented by language runtimes for defining priorities between language-specific type conversions.
  • BeansLinker recognizes method names with explicit type signatures in them, i.e. "dyn:callPropWithThis:println(String)" and uses them to explicitly select an overload with that exact signature. Not usually needed for correctness as automatic overload resolution typically always works, but can improve performance.
  • DynamicLinker.getTypeConverter(sourceType, targetType) can be used to retrieve a type converter method handle outside of the linking context (if the language runtime needs to explicitly invoke them from some other code).
  • Swanky new website at http://szegedi.github.com/dynalink

Minor new features

  • Array objects now expose a synthetic "length" property when accessed through BeansLinker.
  • DynamicLinkerFactory.setSyncOnRelink() method.
  • GuardedInvocation.compose() convenience methods.
  • GuardedInvocation.hasBeenInvalidated() method.
  • GuardedInvocation.asType(), .filterArguments() and .dropArguments() convenience methods that operate both on the invocation and the guard.
  • Guards.isNull() method.
  • LinkRequest.getReceiver() for returning the 0th argument of the link request. Saves whole lot of argument array cloning in code that only inspects the 0th argument.
  • Lookup.findOwnStatic() method for easy creation of method handles to a class' own static methods.
  • TypeUtilities.getPrimitiveTypeByName() and .getPrimitiveType() methods.

Improvements and fixes

  • Significantly improved overloaded method resolution compared to 0.2. We no longer know of any case where it wouldn't work as expected out of the box.
  • Use of foldArguments(exactInvoker()) for relinking invocation eliminates Dynalink stack frames from the relinking operations.
  • CallSiteDescriptor is now an interface; we provide a factory that canonicalizes instances and varies between optimal implementations for different needs.
  • POJO linker reuses most guard method handles; much less method handles are generated.
  • Language specific context arguments are now expected from the argument position 1. In 0.2, they were trailing arguments, but that caused problems with vararg invocation. Now they're after "this" (which is in position 0), and before any regular arguments.