Exemple #1
0
 static Method[] getOverridableMethods(Class c) {
   ArrayList<Method> list = new ArrayList<Method>();
   HashSet<String> skip = new HashSet<String>();
   while (c != null) {
     Method[] methods = c.getDeclaredMethods();
     for (int i = 0; i < methods.length; i++) {
       String methodKey =
           methods[i].getName() + getMethodSignature(methods[i], methods[i].getParameterTypes());
       if (skip.contains(methodKey)) continue; // skip this method
       int mods = methods[i].getModifiers();
       if (Modifier.isStatic(mods)) continue;
       if (Modifier.isFinal(mods)) {
         // Make sure we don't add a final method to the list
         // of overridable methods.
         skip.add(methodKey);
         continue;
       }
       if (Modifier.isPublic(mods) || Modifier.isProtected(mods)) {
         list.add(methods[i]);
         skip.add(methodKey);
       }
     }
     c = c.getSuperclass();
   }
   return list.toArray(new Method[list.size()]);
 }
 private void addDependencies(HashSet<byte[]> deps, CommandData data) {
   for (byte[] dep : data.dependencies) {
     deps.add(dep);
   }
   for (byte[] dep : data.runbundles) {
     deps.add(dep);
   }
 }
 private static void appendOverridableMethods(
     Class<?> c, ArrayList<Method> list, HashSet<String> skip) {
   Method[] methods = c.getDeclaredMethods();
   for (int i = 0; i < methods.length; i++) {
     String methodKey =
         methods[i].getName() + getMethodSignature(methods[i], methods[i].getParameterTypes());
     if (skip.contains(methodKey)) continue; // skip this method
     int mods = methods[i].getModifiers();
     if (Modifier.isStatic(mods)) continue;
     if (Modifier.isFinal(mods)) {
       // Make sure we don't add a final method to the list
       // of overridable methods.
       skip.add(methodKey);
       continue;
     }
     if (Modifier.isPublic(mods) || Modifier.isProtected(mods)) {
       list.add(methods[i]);
       skip.add(methodKey);
     }
   }
 }