@@ -44,15 +44,29 @@ public static CallSite createBridge(MethodHandles.Lookup caller, String name, Me
4444 }
4545
4646 private static Method findTarget (MethodHandles .Lookup caller , String name , Class <?> owner , Class <?>... parameters ) {
47- final Method [] methods = owner .getMethods ();
48- for (final Method method : methods ) {
49- if (!method .getName ().equals (name )) continue ;
50- if (Arrays .equals (method .getParameterTypes (), parameters )) return method ;
47+ {
48+ final Method [] methods = owner .getMethods ();
49+ for (final Method method : methods ) {
50+ if (!method .getName ().equals (name )) continue ;
51+ if (Arrays .equals (method .getParameterTypes (), parameters )) return method ;
52+ }
53+ for (final Method method : methods ) {
54+ if (!Modifier .isStatic (method .getModifiers ())) continue ; // can only hit statics for now
55+ if (!method .getName ().equals (name )) continue ;
56+ if (parameters .length == method .getParameterCount ()) return method ;
57+ }
5158 }
52- for (final Method method : methods ) {
53- if (!Modifier .isStatic (method .getModifiers ())) continue ; // can only hit statics for now
54- if (!method .getName ().equals (name )) continue ;
55- if (parameters .length == method .getParameterCount ()) return method ;
59+ {
60+ final Method [] methods = owner .getDeclaredMethods ();
61+ for (final Method method : methods ) {
62+ if (!method .getName ().equals (name )) continue ;
63+ if (Arrays .equals (method .getParameterTypes (), parameters )) return method ;
64+ }
65+ for (final Method method : methods ) {
66+ if (!Modifier .isStatic (method .getModifiers ())) continue ; // can only hit statics for now
67+ if (!method .getName ().equals (name )) continue ;
68+ if (parameters .length == method .getParameterCount ()) return method ;
69+ }
5670 }
5771 throw new ScriptRuntimeError ("Unable to find function '" + name + Arrays .toString (parameters ).replace ('[' , '(' )
5872 .replace (']' , ')' ) + "' from " + owner .getSimpleName ());
0 commit comments