Supposedly, method handles are a bit more efficient than using Core reflection. That'll require some proper measuring using JMH.
One challenge will be how to obtain method handles for non-public bean members, e.g. private fields:
* Java 8 allows to do it via some [reflection trickery|http://stackoverflow.com/questions/19135218/invoke-private-method-with-java-lang-invoke-methodhandle]. * Java 9 provides a new method [MethodHandles#privateLookupIn()|http://download.java.net/java/jdk9/docs/api/index.html?java/lang/invoke/MethodHandles.html] which addresses this. We'd have to provide a way for letting users pass in such look-up.
The latter would require some SPI which returns a Lookup with private access for a given class. An interesting question is how _open modules_ play into that. Can we obtain lookups with private access to the user's classes from within Hibernate Validator itself (i.e. no SPI is needed), if the user module is an open module (or opens its beans specifically to HV)? |
|