package org.nutz.aop;


public class DefaultClassDefiner extends ClassLoader implements ClassDefiner {
	
	public DefaultClassDefiner(ClassLoader parent) {
		super(parent);
	}

	public Class<?> define(String className, byte[] bytes) throws ClassFormatError {
		try {
			return load(className);
		}
		catch (ClassNotFoundException e) {}
		// If not found ...
		return defineClass(className, bytes, 0, bytes.length);
	}

	public boolean has(String className) {
		try {
			load(className);
			return true;
		}
		catch (ClassNotFoundException e) {}
		return false;
	}

	public Class<?> load(String className) throws ClassNotFoundException {
		try{
			return Thread.currentThread().getContextClassLoader().loadClass(className);
		}
		catch (ClassNotFoundException e) {
			try{
				return ClassLoader.getSystemClassLoader().loadClass(className);
			}catch (ClassNotFoundException e2) {
				try{
					return getParent().loadClass(className);
				}catch (ClassNotFoundException e3) {
				}
			}
		}
		return super.loadClass(className);
	}
}

@@ -20,16 +20,18 @@
 p;%0D%0A%0D%0A%0D%0A
+%0D%0A
 public c
@@ -868,24 +868,29 @@
 Name);%0D%0A%09%09%09%7D
+%0D%0A%09%09%09
 catch (Class
@@ -1026,16 +1026,194 @@
 %0D%0A%09%09%09%7D%0D%0A
+%09%09%09catch (SecurityException e2) %7B//Fix for GAE 1.3.7, Fix issue %0D%0A%09%09%09%09try%7B%0D%0A%09%09%09%09%09return getParent().loadClass(className);%0D%0A%09%09%09%09%7Dcatch (ClassNotFoundException e3) %7B%0D%0A%09%09%09%09%7D%0D%0A%09%09%09%7D%0D%0A
 %09%09%7D%0D%0A%09%09r

Fix Issue 296 : 在gae上使用nutz ioc报错， nutz版本1.a.31及以后版本都报