// Path: core/src/main/java/org/apache/commons/jci2/problems/CompilationProblem.java
// public interface CompilationProblem {
// 
//     /**
//      * is the problem an error and compilation cannot continue
//      * or just a warning and compilation can proceed
//      *
//      * @return true if the problem is an error
//      */
//     boolean isError();
// 
//     /**
//      * name of the file where the problem occurred
//      *
//      * @return name of the file where the problem occurred
//      */
//     String getFileName();
// 
//     /**
//      * position of where the problem starts in the source code
//      *
//      * @return position of where the problem starts in the source code
//      */
//     int getStartLine();
//     int getStartColumn();
// 
//     /**
//      * position of where the problem stops in the source code
//      *
//      * @return position of where the problem stops in the source code
//      */
//     int getEndLine();
//     int getEndColumn();
// 
//     /**
//      * the description of the problem
//      *
//      * @return the description of the problem
//      */
//     String getMessage();
// 
// }
// 
// Path: core/src/main/java/org/apache/commons/jci2/readers/ResourceReader.java
// public interface ResourceReader {
// 
//     boolean isAvailable( final String pResourceName );
//     byte[] getBytes( final String pResourceName );
// 
// }
// 
// Path: core/src/main/java/org/apache/commons/jci2/stores/ResourceStore.java
// public interface ResourceStore {
// 
//     void write( final String pResourceName, final byte[] pResourceData );
//     byte[] read( final String pResourceName );
//     //FIXME: return the result of the remove
//     void remove( final String pResourceName );
// }


import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.Collection;
import org.apache.commons.jci2.problems.CompilationProblem;
import org.apache.commons.jci2.readers.ResourceReader;
import org.apache.commons.jci2.stores.ResourceStore;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.codehaus.commons.compiler.CompileException;
import org.codehaus.commons.compiler.LocatedException;
import org.codehaus.commons.compiler.Location;
import org.codehaus.janino.ClassLoaderIClassLoader;
import org.codehaus.janino.Compiler;
import org.codehaus.janino.FilterWarningHandler;
import org.codehaus.janino.UnitCompiler.ErrorHandler;
import org.codehaus.janino.WarningHandler;
import org.codehaus.janino.util.StringPattern;
import org.codehaus.janino.util.resource.Resource;
import org.codehaus.janino.util.resource.ResourceCreator;
import org.codehaus.janino.util.resource.ResourceFinder;
    			pSettings.getSourceEncoding(),
    			false,
    			pSettings.isDebug(),
                pSettings.isDebug(),
                pSettings.isDebug(),
    			new FilterWarningHandler(pattern, new WarningHandler() {
						public void handleWarning( final String pHandle, final String pMessage, final Location pLocation ) {
							final CompilationProblem problem = new JaninoCompilationProblem(pLocation.getFileName(), pLocation, pMessage, false);
							if (problemHandler != null) {
								problemHandler.handle(problem);
							}
							problems.add(problem);
						}
			    	})
    			);


    	compiler.setCompileErrorHandler(new ErrorHandler() {
			public void handleError( final String pMessage, final Location pLocation ) throws CompileException {
				final CompilationProblem problem = new JaninoCompilationProblem(pLocation.getFileName(), pLocation, pMessage, true);
				if (problemHandler != null) {
					problemHandler.handle(problem);
				}
				problems.add(problem);
			}
    	});


    	final Resource[] resources = new Resource[pSourceNames.length];
        for (int i = 0; i < pSourceNames.length; i++) {
// Path: core/src/main/java/org/apache/commons/jci2/problems/CompilationProblem.java
// public interface CompilationProblem {
// 
//     /**
//      * is the problem an error and compilation cannot continue
//      * or just a warning and compilation can proceed
//      *
//      * @return true if the problem is an error
//      */
//     boolean isError();
// 
//     /**
//      * name of the file where the problem occurred
//      *
//      * @return name of the file where the problem occurred
//      */
//     String getFileName();
// 
//     /**
//      * position of where the problem starts in the source code
//      *
//      * @return position of where the problem starts in the source code
//      */
//     int getStartLine();
//     int getStartColumn();
// 
//     /**
//      * position of where the problem stops in the source code
//      *
//      * @return position of where the problem stops in the source code
//      */
//     int getEndLine();
//     int getEndColumn();
// 
//     /**
//      * the description of the problem
//      *
//      * @return the description of the problem
//      */
//     String getMessage();
// 
// }
// 
// Path: core/src/main/java/org/apache/commons/jci2/readers/ResourceReader.java
// public interface ResourceReader {
// 
//     boolean isAvailable( final String pResourceName );
//     byte[] getBytes( final String pResourceName );
// 
// }
// 
// Path: core/src/main/java/org/apache/commons/jci2/stores/ResourceStore.java
// public interface ResourceStore {
// 
//     void write( final String pResourceName, final byte[] pResourceData );
//     byte[] read( final String pResourceName );
//     //FIXME: return the result of the remove
//     void remove( final String pResourceName );
// }


// Path: compilers/janino/src/main/java/org/apache/commons/jci2/compilers/JaninoJavaCompiler.java
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.Collection;
import org.apache.commons.jci2.problems.CompilationProblem;
import org.apache.commons.jci2.readers.ResourceReader;
import org.apache.commons.jci2.stores.ResourceStore;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.codehaus.commons.compiler.CompileException;
import org.codehaus.commons.compiler.LocatedException;
import org.codehaus.commons.compiler.Location;
import org.codehaus.janino.ClassLoaderIClassLoader;
import org.codehaus.janino.Compiler;
import org.codehaus.janino.FilterWarningHandler;
import org.codehaus.janino.UnitCompiler.ErrorHandler;
import org.codehaus.janino.WarningHandler;
import org.codehaus.janino.util.StringPattern;
import org.codehaus.janino.util.resource.Resource;
import org.codehaus.janino.util.resource.ResourceCreator;
import org.codehaus.janino.util.resource.ResourceFinder;

    			pSettings.getSourceEncoding(),
    			false,
    			pSettings.isDebug(),
                pSettings.isDebug(),
                pSettings.isDebug(),
    			new FilterWarningHandler(pattern, new WarningHandler() {
						public void handleWarning( final String pHandle, final String pMessage, final Location pLocation ) {
							final CompilationProblem problem = new JaninoCompilationProblem(pLocation.getFileName(), pLocation, pMessage, false);
							if (problemHandler != null) {
								problemHandler.handle(problem);
							}
							problems.add(problem);
						}
			    	})
    			);


    	compiler.setCompileErrorHandler(new ErrorHandler() {
			public void handleError( final String pMessage, final Location pLocation ) throws CompileException {
				final CompilationProblem problem = new JaninoCompilationProblem(pLocation.getFileName(), pLocation, pMessage, true);
				if (problemHandler != null) {
					problemHandler.handle(problem);
				}
				problems.add(problem);
			}
    	});


    	final Resource[] resources = new Resource[pSourceNames.length];
        for (int i = 0; i < pSourceNames.length; i++) {
            log.debug("compiling " + pSourceNames[i]);