Example #1
0
        internal static void BindCore(JNIEnv env, BridgeSetup newSetup)
        {
            if (CheckAlreadyLoaded(newSetup, env))
            {
                return;
            }

            if (newSetup.Verbose)
            {
                var homeDll = new Uri(typeof(Bridge).Assembly.GetName().CodeBase).AbsolutePath;
                Console.WriteLine("loading core from " + homeDll);
            }
            setup = newSetup;
            if (!setup.BindCoreOnly)
            {
                RegisterAssembly(typeof(Bridge).Assembly);
            }
            __Bridge.Init(env);

            if (Setup.Verbose)
            {
                Console.WriteLine("Initialized jni4net core");
            }
            if (Setup.BindNative)
            {
                JniLocalHandle br = env.FindClassPtr("net/sf/jni4net/Bridge");
                IntPtr         ir = env.GetStaticFieldIDPtr(br, "isRegistered", "Z");
                env.SetStaticBooleanField(br, ir, true);
                if (!env.GetStaticBooleanField(br, ir))
                {
                    Console.Error.WriteLine("Can't mark bridge");
                }
                Ref.Init();
                Out.Init();
            }
            if (Setup.Verbose)
            {
                var homeDll = new Uri(typeof(Bridge).Assembly.GetName().CodeBase).AbsolutePath;
                Console.WriteLine("core loaded from " + homeDll);
            }

            AppDomain.CurrentDomain.DomainUnload += CurrentDomain_DomainUnload;

            clrLoaded = true;
        }