public ClassLoader getExternalClassLoader ( ) { Map < String , String > opts = _ap . getAnnotationProcessorEnvironment ( ) . getOptions ( ) ; String classpath = opts . get ( "-classpath" ) ; if ( classpath != null ) { String [ ] cpEntries = classpath . split ( File . pathSeparator ) ; ArrayList a = new ArrayList ( ) ; for ( String e : cpEntries ) { try { File f = ( new File ( e ) ) . getCanonicalFile ( ) ; URL u = f . toURL ( ) ; a . add ( u ) ; } catch ( Exception ex ) { System . err . println ( "getExternalClassLoader(): bad cp entry=" + e ) ; System . err . println ( "Exception processing e=" + ex ) ; } } URL [ ] urls = new URL [ a . size ( ) ] ; urls = ( URL [ ] ) a . toArray ( urls ) ; return new URLClassLoader ( urls , ControlChecker . class . getClassLoader ( ) ) ; } return null ; }
Returns a classloader that can be used to load external classes