public static byte[] modify(ClassLoader classloader, String name, byte[] bytes) {
		ClassLoader parent = classloader.getParent();
		if (parent != null) {
			TypeRegistry typeRegistry = TypeRegistry.getTypeRegistryFor(parent);
			// classloader.getParent() can return null - I've seen it when the target of the call being compiled is
			// java_lang_class$getDeclaredFields (i.e. a system class that cant change, so rewriting is unnecessary...)
			if (typeRegistry != null) {
				bytes = typeRegistry.methodCallRewrite(bytes);
			}
			else {
				if (GlobalConfiguration.verboseMode) {
					System.out.println("No type registry found for parent classloader: " + parent);
				}
				bytes = MethodInvokerRewriter.rewrite(null, bytes, true);
			}
		}
		else {
			bytes = MethodInvokerRewriter.rewrite(null, bytes, true);
		}
		return bytes;
	}
public static byte [ ] modify ( ClassLoader classloader , String name , byte [ ] bytes ) { ClassLoader parent = classloader . getParent ( ) ; if ( parent != null ) { TypeRegistry typeRegistry = TypeRegistry . getTypeRegistryFor ( parent ) ; if ( typeRegistry != null ) { bytes = typeRegistry . methodCallRewrite ( bytes ) ; } else { if ( GlobalConfiguration . verboseMode ) { System . out . println ( "No type registry found for parent classloader: " + parent ) ; } bytes = MethodInvokerRewriter . rewrite ( null , bytes , true ) ; } } else { bytes = MethodInvokerRewriter . rewrite ( null , bytes , true ) ; } return bytes ; }
/*
The classloader for class artifacts (org/codehaus/groovy/reflection/ClassLoaderForClassArtifacts) is used to load the
generated classes for call sites. We need to rewrite these classes
because they may be either calling something that disappears on a later reload (so need to fail appropriately) or calling
something that is not there on the first load - in this latter case they are changed to route the dynamic executor method.