internal static void RegisterNative(MethodInfo initializer, JNIEnv env, Class jvmProxy, Class jvmInterface)
 {
     var registrations = (List<JNINativeMethod>) initializer.Invoke(null, new object[] {env, jvmProxy});
     if (registrations.Count > 0)
     {
         if (Bridge.Setup.Debug)
         {
             foreach (JNINativeMethod registration in registrations)
             {
                 string n = Marshal.PtrToStringAnsi(registration.name);
                 string s = Marshal.PtrToStringAnsi(registration.signature);
                 if (env.GetMethodIDNoThrow(jvmInterface, n, s) == null)
                 {
                     if (env.GetStaticMethodIDNoThrow(jvmInterface, n, s) == null)
                     {
                         throw new JNIException("Can't find native method" + n + "()" +
                                                s + " in class " + jvmInterface);
                     }
                 }
             }
             /*if (Bridge.clrLoaded)
             {
                 if (!jvmProxy.getClassLoader().equals(ClassLoader.getSystemClassLoader()))
                 {
                     Console.Error.WriteLine("Class " + jvmProxy.toString() +
                                             " is not in system classloader. It may fail binding native methods.");
                 }
             }*/
         }
         try
         {
             JNINativeMethod.Register(registrations, jvmProxy, env);
             if (!nativeMethods.ContainsKey(jvmProxy))
             {
                 nativeMethods.Add(jvmProxy, registrations);
             }
         }
         catch (Exception ex)
         {
             throw new JNIException("Failed binding native methods for " + jvmInterface, ex);
         }
     }
 }
 private static MethodId GetJVMConstructor(JNIEnv env, Class proxy)
 {
     MethodId jvmConstructor = env.GetMethodIDNoThrow(proxy, "<init>", "(Lnet/sf/jni4net/inj/INJEnv;J)V");
     if (jvmConstructor == null)
     {
         if (Bridge.Setup.Verbose)
         {
             Console.WriteLine("Can't find java constructor for " + proxy);
         }
         throw new JNIException("Can't find java constructor for " + proxy);
     }
     return jvmConstructor;
 }
Example #3
0
 private static MethodId GetJVMConstructor(JNIEnv env, Class proxy)
 {
     return env.GetMethodIDNoThrow(proxy, "<init>", "(Lnet/sf/jni4net/inj/INJEnv;J)V");
 }