if ( !ok.booleanValue() ) {  throw new Exception( "Failed to execute javac: \n\n" + err.toString() ); }
    public List compile( CompilerConfiguration config ) throws Exception    {        File destinationDir = new File( config.getOutputLocation() );        if ( !destinationDir.exists() )        {            destinationDir.mkdirs();        }        String[] sources = getSourceFiles( config );        System.out.println( "Compiling " + sources.length + " source file" + ( sources.length == 1 ? "" : "s" )            + " to " + destinationDir.getAbsolutePath() );        Map compilerOptions = config.getCompilerOptions();        List args = new ArrayList( sources.length + 5 + compilerOptions.size() * 2 );        args.add( "-d" );        args.add( destinationDir.getAbsolutePath() );        args.add( "-nowarn" );        args.add( "-classpath" );        args.add( getClasspathString( config.getClasspathEntries() ) );                if ( config.isDebug() )        {            args.add( "-g" );        }        Iterator it = compilerOptions.entrySet().iterator();        while ( it.hasNext() )        {            Map.Entry entry = (Map.Entry) it.next();            args.add( entry.getKey() );            if ( (entry.getValue() != null) )                args.add( entry.getValue() );        }        for ( int i = 0; i < sources.length; i++ )        {            args.add( sources[i] );        }        IsolatedClassLoader cl = new IsolatedClassLoader();        File toolsJar = new File( System.getProperty( "java.home" ), "../lib/tools.jar" );        cl.addURL( toolsJar.toURL() );        Class c = cl.loadClass( "sun.tools.javac.Main" );        Constructor cons = c.getConstructor( new Class[] { OutputStream.class, String.class } );        ByteArrayOutputStream err = new ByteArrayOutputStream();        Object compiler = cons.newInstance( new Object[] { err, "javac" } );        Method compile = c.getMethod( "compile", new Class[] { String[].class } );        Boolean ok = (Boolean) compile.invoke( compiler, new Object[] { args.toArray( new String[0] ) } );        List messages = parseModernStream( new BufferedReader( new InputStreamReader( new ByteArrayInputStream( err.toByteArray() ) ) ) );        return messages;    }