private Class < ? > compileSource0 ( String className , String sourceCode ) throws Exception { List < MemorySourceJavaFileObject > compUnits = new ArrayList < MemorySourceJavaFileObject > ( 1 ) ; compUnits . add ( new MemorySourceJavaFileObject ( className + ".java" , sourceCode ) ) ; DiagnosticCollector < JavaFileObject > diag = new DiagnosticCollector < JavaFileObject > ( ) ; Boolean result = compiler . getTask ( null , fileManager , diag , compilerOptions , null , compUnits ) . call ( ) ; if ( result . equals ( Boolean . FALSE ) ) { throw new RuntimeException ( diag . getDiagnostics ( ) . toString ( ) ) ; } try { String classDotName = className . replace ( ' ' , ' ' ) ; return Class . forName ( classDotName , true , loader ) ; } catch ( ClassNotFoundException e ) { throw e ; } }
Compiles multiple sources file and loads the classes .