protected final Map < Class < ? > , URI > searchJar ( Class < ? > clazz , URI location ) { Map < Class < ? > , URI > ret = new HashMap <> ( ) ; try { JarURLConnection conn = ( JarURLConnection ) location . toURL ( ) . openConnection ( ) ; JarFile jarFile = conn . getJarFile ( ) ; for ( Enumeration < JarEntry > e = jarFile . entries ( ) ; e . hasMoreElements ( ) ; ) { JarEntry entry = e . nextElement ( ) ; String entryname = entry . getName ( ) ; if ( this . processed . contains ( entryname ) ) { continue ; } this . processed . add ( entryname ) ; if ( ! entry . isDirectory ( ) && entryname . endsWith ( ".class" ) ) { String classname = entryname . substring ( 0 , entryname . length ( ) - 6 ) ; if ( classname . startsWith ( "/" ) ) { classname = classname . substring ( 1 ) ; } classname = classname . replace ( ' ' , ' ' ) ; if ( ! StringUtils . startsWithAny ( classname , this . excludedNames ) ) { try { Class < ? > c = Class . forName ( classname ) ; if ( clazz . isAssignableFrom ( c ) && ! clazz . getName ( ) . equals ( classname ) ) { ret . put ( c , location ) ; } } catch ( Exception exception ) { errors . add ( exception ) ; } catch ( Error error ) { errors . add ( error ) ; } } } } } catch ( IOException ignore ) { errors . add ( ignore ) ; } return ret ; }
Returns all known subclasses found in a given location