Constructor rgsEnumConstructor = rgsEnumClass.getConstructor( new Class[]{ InputStream.class }); Object rgsEnum = rgsEnumConstructor.newInstance( new Object[]{new PreserveInputStream( preserve ) } );
Constructor rgsEnumConstructor = rgsEnumClass.getConstructor( new Class[]{ String.class }); Object rgsEnum = rgsEnumConstructor.newInstance( new Object[]{ preserveBuffer.toString() } );
	public void obfuscate(Device device, File sourceFile, File targetFile,			String[] preserve, Path bootClassPath) throws BuildException 	{        try {        	this.logBuffer.clear();        	AntClassLoader antClassLoader = new AntClassLoader( this.project, bootClassPath );        	antClassLoader.addPathElement( this.libDir.getAbsolutePath() + File.separator + "retroguard.jar");    		String[] apiPaths = device.getClassPaths();    		for (int i = 0; i < apiPaths.length; i++) {				antClassLoader.addPathElement( apiPaths[i] );			}        	// load the RetroGuard main class through the classloader:        	Class guardDbClass = antClassLoader.forceLoadClass("COM.rl.obf.GuardDB");        	Constructor guardDbConstructor = guardDbClass.getConstructor( new Class[]{ File.class} );        	Class rgsEnumClass = antClassLoader.forceLoadClass("COM.rl.obf.RgsEnum");        	Constructor rgsEnumConstructor = rgsEnumClass.getConstructor( new Class[]{ InputStream.class });        	Object rgsEnum = rgsEnumConstructor.newInstance( new Object[]{new PreserveInputStream( preserve ) } );        	Object database = guardDbConstructor.newInstance( new Object[]{ sourceFile } );        	Method retain = guardDbClass.getMethod( "retain", new Class[]{ rgsEnumClass, PrintWriter.class} );        	Method remapTo = guardDbClass.getMethod( "remapTo", new Class[]{ File.class, PrintWriter.class } );        	Method close = guardDbClass.getMethod( "close", new Class[0] );        	//System.out.println("ALL SYSTEMS GO.");        	        	//GuardDB db = (GuardDB) guardDbConstructor.newInstance( new Object[]{ sourceFile } );        	//GuardDB db = new GuardDB( sourceFile );        	try {        		retain.invoke(database, new Object[]{ rgsEnum, this.log } );        		remapTo.invoke(database, new Object[]{ targetFile, this.log } );        		/*		        db.retain(new RgsEnum(new PreserveInputStream( preserve )), log);        		db.remapTo(targetFile, log);        		*/        	} finally {        		close.invoke( database, new Object[0] );        	}        } catch (Exception e) {        	System.out.println("RetroGuard-Log:\n");        	this.logBuffer.print();        	e.printStackTrace();        	throw new BuildException("Unable to obfuscate: " + e.toString(), e );        } finally {			this.log.flush();			this.log.close();        }	}