private Class<?> parse(String str, ScriptContext ctx) throws ScriptException
	{
		String fileName = getFileName(ctx);
		String sourcePath = getSourcePath(ctx);
		String classPath = getClassPath(ctx);
		
		Writer err = ctx.getErrorWriter();
		if (err == null)
		{
			err = new StringWriter();
		}
		
		Map<String, byte[]> classBytes = compiler.compile(fileName, str, err, sourcePath, classPath);
		
		if (classBytes == null)
		{
			if (err instanceof StringWriter)
			{
				throw new ScriptException(((StringWriter) err).toString());
			}
			throw new ScriptException("compilation failed");
		}
		
		// create a ClassLoader to load classes from MemoryJavaFileManager
		MemoryClassLoader loader = new MemoryClassLoader(classBytes, classPath, getParentLoader(ctx));
		return parseMain(loader, ctx);
	}