MethodImpl { @Exported static String toSignature(Method m) { StringBuilder sb = new StringBuilder(); sb.append(m.getName().replace("_", "_1")).append("__"); appendType(sb, m.getReturnType()); Class<?>[] arr = m.getParameterTypes(); for (int i = 0; i < arr.length; i++) { appendType(sb, arr[i]); } return sb.toString(); }  static Constructor findConstructor(
        Class<?> clazz, Class<?>... parameterTypes); static Constructor[] findConstructors(Class<?> clazz, int mask); static Method findMethod(
        Class<?> clazz, String name, Class<?>... parameterTypes
    ); static Method[] findMethods(Class<?> clazz, int mask); static int signatureElements(String sig); static Enumeration<Class> signatureParser(final String sig); static Object fromPrimitive(Class<?> type, Object o); static boolean samePrimitive(Class<?> c1, Class<?> c2); static String findArraySignature(Class<?> type); @JavaScriptBody(args = {"o"}, body = "return o.valueOf();") static native Object toPrimitive(Object o); static MethodImpl INSTANCE; }
@Test public void underscoresInNames() throws Exception { Method factory = Co_Ty.class.getMethod("fac_to_ry"); String sig = MethodImpl.toSignature(factory); if (sig.equals("fac_1to_1ry__Lorg_apidesign_bck2brwsr_emul_reflect_MethodImplTest$Co_1Ty_2")) { return; } fail(sig); }