@@ -0,0 +1,3118 @@
+package lib;%0A%0Aimport java.io.File;%0Aimport java.io.IOException;%0Aimport java.util.HashSet;%0Aimport java.util.Set;%0A%0Aimport javax.tools.DiagnosticCollector;%0Aimport javax.tools.JavaCompiler;%0Aimport javax.tools.JavaFileManager;%0Aimport javax.tools.JavaFileObject;%0Aimport javax.tools.StandardLocation;%0Aimport javax.tools.ToolProvider;%0A%0Apublic class ClassFinder %7B%0A    public static void main(String%5B%5D args) %7B%0A        for (Class%3C?%3E klass : getClasses(%22java.lang%22)) %7B%0A            System.out.println(klass.getCanonicalName());%0A        %7D%0A    %7D%0A%0A    /**%0A     * See: http://qiita.com/kei2100/items/a9ba32a86bb0e685ecc7%0A     */%0A    @SuppressWarnings(%22rawtypes%22)%0A    private static Set%3CClass%3E getClasses(String packageName) %7B%0A        JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();%0A        JavaFileManager jfm = compiler.getStandardFileManager(new DiagnosticCollector%3CJavaFileObject%3E(), null, null);%0A%0A        Set%3CJavaFileObject.Kind%3E kind = new HashSet%3CJavaFileObject.Kind%3E();%0A        kind.add(JavaFileObject.Kind.CLASS);%0A%0A        boolean recursive = true;%0A        Set%3CClass%3E classes = new HashSet%3CClass%3E();%0A%0A        try %7B%0A            for (JavaFileObject jfo : jfm.list(StandardLocation.PLATFORM_CLASS_PATH, packageName, kind, recursive)) %7B%0A                String uri = null;%0A%0A                try %7B%0A                    uri = jfo.toUri().toString();%0A                    String uriDotSeparate = uri.replaceAll(File.separator, %22.%22);%0A%0A                    int indexOfPkgNmBegin = uriDotSeparate.indexOf(packageName);%0A                    String fqcnWithExtension = uriDotSeparate.substring(indexOfPkgNmBegin); // FQCN: Fully Qualified Class Name%0A                    String fqcn = fqcnWithExtension.replaceFirst(%22.class$%22, %22%22);%0A%0A                    Class klass = Class.forName(fqcn);%0A                    classes.add(klass);%0A                %7D catch (NoClassDefFoundError e) %7B%0A                    System.err.println(%22get class failed. %22 + uri);%0A                    e.printStackTrace();%0A                %7D catch (ClassNotFoundException e) %7B%0A                    System.err.println(%22get class failed. %22 + uri);%0A                    e.printStackTrace();%0A                %7D%0A            %7D%0A        %7D catch (IOException e) %7B%0A            System.err.println(%22list class failed. packageName=%22 + packageName);%0A            e.printStackTrace();%0A        %7D%0A%0A        return classes;%0A    %7D%0A%0A    /**%0A     * See: http://unageanu.hatenablog.com/entry/20100107/1262869452%0A    private static void printer() %7B%0A        JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();%0A        JavaFileManager fm = compiler.getStandardFileManager(%0A            new DiagnosticCollector%3CJavaFileObject%3E(), null, null);%0A%0A        Set%3CJavaFileObject.Kind%3E kind = new HashSet%3CJavaFileObject.Kind%3E()%7B%7B%0A            add(JavaFileObject.Kind.CLASS);%0A        %7D%7D;%0A%0A        try %7B%0A            for ( JavaFileObject f : fm.list(StandardLocation.PLATFORM_CLASS_PATH, %22java.io%22, kind, false)) %7B%0A                System.out.println( f.getName() );%0A            %7D%0A        %7D catch (IOException ex) %7B%0A            ex.printStackTrace();%0A            System.exit(1);%0A        %7D%0A    %7D%0A     */%0A%0A%7D%0A

Add ClassFinder