static Method[] getOverridableMethods(Class c) { ArrayList list = new ArrayList(); while (c != null) { Method[] methods = c.getDeclaredMethods(); for (int i = 0; i < methods.length; i++) { int mods = methods[i].getModifiers(); if (Modifier.isStatic(mods) || Modifier.isFinal(mods)) continue; if (Modifier.isPublic(mods) || Modifier.isProtected(mods)) list.add(methods[i]); } c = c.getSuperclass(); } return (Method[]) list.toArray(new Method[list.size()]); }
// Needed by NativeJavaObject serializer public static void writeAdapterObject(Object javaObject, ObjectOutputStream out) throws IOException { Class cl = javaObject.getClass(); out.writeObject(cl.getSuperclass().getName()); Class[] interfaces = cl.getInterfaces(); String[] interfaceNames = new String[interfaces.length]; for (int i = 0; i < interfaces.length; i++) interfaceNames[i] = interfaces[i].getName(); out.writeObject(interfaceNames); try { Object delegee = cl.getField("delegee").get(javaObject); out.writeObject(delegee); return; } catch (IllegalAccessException e) { } catch (NoSuchFieldException e) { } throw new IOException(); }