Example #1
0
        private static Assembly OnTypeResolve(object sender, ResolveEventArgs args)
        {
            TypeWrapper type;

#if CLASSGC
            DynamicClassLoader instance;
            ClassLoaderWrapper loader = ClassLoaderWrapper.GetClassLoaderForDynamicJavaAssembly(args.RequestingAssembly);
            if (loader == null)
            {
                return(null);
            }
            instance = (DynamicClassLoader)loader.GetTypeWrapperFactory();
#endif
            instance.dynamicTypes.TryGetValue(args.Name, out type);
            if (type == null)
            {
                return(null);
            }
            try
            {
                type.Finish();
            }
            catch (RetargetableJavaException x)
            {
                throw x.ToJava();
            }
            // NOTE We used to remove the type from the hashtable here, but that creates a race condition if
            // another thread also fires the OnTypeResolve event while we're baking the type.
            // I really would like to remove the type from the hashtable, but at the moment I don't see
            // any way of doing that that wouldn't cause this race condition.
            // UPDATE since we now also use the dynamicTypes hashtable to keep track of type names that
            // have been used already, we cannot remove the keys.
            return(type.TypeAsTBD.Assembly);
        }
Example #2
0
        private static Assembly OnTypeResolve(object sender, ResolveEventArgs args)
        {
#if CLASSGC
            ClassLoaderWrapper loader = ClassLoaderWrapper.GetClassLoaderForDynamicJavaAssembly(args.RequestingAssembly);
            if (loader == null)
            {
                return(null);
            }
            DynamicClassLoader instance = (DynamicClassLoader)loader.GetTypeWrapperFactory();
            return(Resolve(instance.dynamicTypes, args.Name));
#else
            return(Resolve(dynamicTypes, args.Name));
#endif
        }