I'm looking for something in the Nashorn javascript engine in Java which would call a generic method as a fallback when the actual method cannot be found.
It should be something similar to groovy's methodMissing
or invokeMethod
features.
Is there anything like that?
I tried with java Proxy
, but the InvocationHandler
would be called only for methods in the interface... while I would want something like an InvocationHandler
which should be called for any method.
Have a look at the noSuchMethod feature documented here. There is also a noSuchProperty hook for doing the same with properties and variables.