import java.io.File;
import java.io.IOException;
import java.lang.reflect.Method;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.Arrays;
import java.util.Collections;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;
import java.util.regex.Pattern;

public class JGlasses {
    /*
      Fix URLClassLoader protected method
    */
    static class FixedURLClassLoader extends URLClassLoader {
        public FixedURLClassLoader(URL[] urls) { super(urls); }
        public Class<?> findClass(String name) throws ClassNotFoundException { return super.findClass(name); }
    }

    /*
        Remove extra quotes if in windows, and they are present.
    */ 
    public static String fix_wildcard(String in) {
        if (System.getProperty("os.name").toLowerCase().indexOf("win") < 0) {
            return in;
        }
        if (in.charAt(0) == '\'' && in.charAt(in.length()-1) == '\'' || 
            in.charAt(0) == '"' && in.charAt(in.length()-1) == '"') {
            return in.substring(1, in.length()-1);
        }
        return in;
    }

    static FixedURLClassLoader loader;

    static Pattern class_regex;
    static Pattern method_regex;

    public static void print_methods(String classname) {
        if (class_regex.matcher(classname).find()) { 
            try {
                Class<?> c = loader.findClass(classname);
                for (Method m : c.getDeclaredMethods()) {
                    String method_string = m.toString();
                    if (method_regex.matcher(method_string).find()) { 
                        System.out.println(method_string);
                    }
                }
            } catch (Throwable e) {
                System.err.println(classname + " not found.");
            }
        }
    }

    public static void main(String[] args) throws IOException {
        if (args.length != 3) {
            System.err.println("Usage: java JGlasses <class regex> <method regex> <classpath>");
            System.err.println("Note: on windows regexen will need to be double quoted: \"'.*'\" for .*,");
            System.err.println(" to avoid their damn wildcard expansion that can't be avoided.");
            System.err.println(" Microsoft and Oracle hate us.");
            return;
        }

        class_regex = Pattern.compile(fix_wildcard(args[0]));
        method_regex = Pattern.compile(fix_wildcard(args[1]));
        String[] classpaths = args[2].split(';');

        URL[] urls = new URL[args.length];
        for (int i = 0; i < classpaths.length; i++) {
            urls[i] = new File(classpaths[i]).toURI().toURL();
        }
        loader = new FixedURLClassLoader(urls);
        
        for (String path : classpaths) {
            if (path.endsWith(".jar")) {
                JarFile jar = new JarFile(path);
                for (JarEntry entry : Collections.list(jar.entries())) {
                    String file = entry.getName();
                    if (file.endsWith(".class")) {
                        String classname = file.replace('/', '.').substring(0, file.length() - 6);
                        print_methods(classname); 
                    }
                }
            } else {
                File dir = new File(path);
                for (String file : dir.list()) {
                    if (file.endsWith(".class")) {
                        String classname = file.replace('/', '.').substring(0, file.length() - 6);
                        print_methods(classname); 
                    }
                }
            }
        }
    }
}

@@ -1143,16 +1143,38 @@
 ss_regex
+ = Pattern.compile(%22%22)
 ;%0A    st
@@ -1198,16 +1198,38 @@
 od_regex
+ = Pattern.compile(%22%22)
 ;%0A%0A    p
@@ -1917,10 +1917,28 @@
 gth 
-!=
+%3C 1 %7C%7C args.length %3E
  3) 
@@ -1998,25 +1998,37 @@
 s %3Cclass
+path%3E %5Bclass
  regex
-%3E %3C
+%5D %5B
 method r
@@ -2035,21 +2035,9 @@
 egex
-%3E %3Cclasspath%3E
+%5D
 %22);%0A
@@ -2335,24 +2335,109 @@
 %0A        %7D%0A%0A
+        String%5B%5D classpaths = args%5B0%5D.split(%22;%22);%0A        if (args.length %3E 1) %7B%0A    
         clas
@@ -2484,14 +2484,59 @@
 rgs%5B
-0
+1
 %5D));%0A
+        %7D%0A        if (args.length %3E 2) %7B%0A    
     
@@ -2580,33 +2580,33 @@
 x_wildcard(args%5B
-1
+2
 %5D));%0A        Str
@@ -2606,49 +2606,9 @@
     
-String%5B%5D classpaths = args%5B2%5D.split(';');
+%7D
 %0A%0A  

Change order of arguments and make the regexen optional.