OCInvocationCallbacks { protected Method methodForSelector(String selectorName) { if (null == selectorName) { logging.severe("methodForSelector called with null selectorName"); return null; } int parameterCount = countColons(selectorName); String methodName = methodNameForSelector(selectorName); try { Method[] methods = javaObject.getClass().getMethods(); for (Method method : methods) { if (method.getName().equals(methodName) && method.getParameterTypes().length == parameterCount) { boolean match = true; if(null == stringForType(method.getReturnType())) { match = false; } if(match) { for (Class<?> parameterType : method.getParameterTypes()) { if(null == stringForType(parameterType)) { match = false; break; } } } if(match) { return method; } } } logging.fine("No method " + methodName + " for selector:" + selectorName); return null; } catch (Exception e) { logging.log(Level.SEVERE, "Exception finding methodForSelector", e); return null; } } OCInvocationCallbacks(Object javaObject);  final RococoaLibrary.MethodSignatureCallback methodSignatureCallback; final RococoaLibrary.SelectorInvokedCallback selectorInvokedCallback; }
@Test public void testMethodForSelector() throws SecurityException, NoSuchMethodException { assertNull(callbacks.methodForSelector("nosuch")); assertEquals( JavaImplementor.class.getDeclaredMethod("returnsIDTakesVoid"), callbacks.methodForSelector("returnsIDTakesVoid")); assertEquals( JavaImplementor.class.getDeclaredMethod("returnsVoidTakesInt", int.class), callbacks.methodForSelector("returnsVoidTakesInt:")); assertEquals( JavaImplementor.class.getDeclaredMethod("returnsVoidTakesInt_andInt", int.class, int.class), callbacks.methodForSelector("returnsVoidTakesInt:andInt:")); assertNull(callbacks.methodForSelector("returnsVoidTakesVoid:")); assertNull(callbacks.methodForSelector("returnsVoidTakesInt")); }